Ñò Ã#xPc@sªddklZlZddklZlZlZddkTddklZddkl Z l Z e dƒZ de dƒfZ d „Z d „Zd „Zd „Zd efd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZ eie ƒde!fd„ƒYZ"eie"ƒde#fd „ƒYZ$eie$ƒd!e!fd"„ƒYZ%eie%ƒd#e#fd$„ƒYZ&eie&ƒd%e!fd&„ƒYZ'eie'ƒd'e#fd(„ƒYZ(eie(ƒd)e!fd*„ƒYZ)eie)ƒd+e#fd,„ƒYZ*eie*ƒd-e!fd.„ƒYZ+eie+ƒd/e#fd0„ƒYZ,eie,ƒd1e!fd2„ƒYZ-eie-ƒd3e#fd4„ƒYZ.eie.ƒd5efd6„ƒYZ/eie/ƒd7efd8„ƒYZ0eie0ƒd9S(:iÿÿÿÿ(tapiterrors(tStrtStrEnumtBool(t*(tis_all(t_tngettextsv Sudo Rules Sudo (su "do") allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments. FreeIPA provides a means to configure the various aspects of Sudo: Users: The user(s)/group(s) allowed to invoke Sudo. Hosts: The host(s)/hostgroup(s) which the user is allowed to to invoke Sudo. Allow Command: The specific command(s) permitted to be run via Sudo. Deny Command: The specific command(s) prohibited to be run via Sudo. RunAsUser: The user(s) or group(s) of users whose rights Sudo will be invoked with. RunAsGroup: The group(s) whose gid rights Sudo will be invoked with. Options: The various Sudoers Options that can modify Sudo's behavior. An order can be added to a sudorule to control the order in which they are evaluated (if the client supports it). This order is an integer and must be unique. FreeIPA provides a designated binddn to use with Sudo located at: uid=sudo,cn=sysaccounts,cn=etc,dc=example,dc=com To enable the binddn run the following command to set the password: LDAPTLS_CACERT=/etc/ipa/ca.crt /usr/bin/ldappasswd -S -W -h ipa.example.com -ZZ -D "cn=Directory Manager" uid=sudo,cn=sysaccounts,cn=etc,dc=example,dc=com For more information, see the FreeIPA Documentation to Sudo. tsudos+Commands for controlling sudo configurationcCs"tid|dtdƒƒ‚dS(Ntnameterrors this option has been deprecated.(RtValidationErrorR(t attribute((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyt deprecated<scCstdƒdS(Nt externaluser(R(tugettexttvalue((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytvalidate_externaluser?scCstdƒdS(Ntrunasexternaluser(R(RR((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytvalidate_runasextuserBscCstdƒdS(Ntrunasexternalgroup(R(RR((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytvalidate_runasextgroupEstsudorulec!BsÊeZdZeiiZedƒZedƒZ ddgZ ddddd d d d d ddddddddgZ dZ dZ hddgd 6ddgd 6ddgd6ddgd6ddgd6dgd6ZedƒZedƒZeddd d!ed"ƒd#eƒed$dd%d!ed&ƒƒed'd!ed(ƒd)d*gƒed+dd,d!ed-ƒd.ed/ƒd0dtƒed2dd3d!ed4ƒd.ed5ƒd0duƒed6dd7d!ed8ƒd.ed9ƒd0dvƒed:dd;d!ed<ƒd.ed=ƒd0dwƒed>dd?d!ed@ƒd.edAƒd0dxƒedBddCd!edDƒd.edEƒdFdGdHdGƒedId!edJƒd)dKdLdMgƒedNd!edOƒd)dKdLdMgƒedPd!edQƒd)dKdLdMgƒedRd!edSƒd)dKdLdMgƒedTd!edUƒd)dKdLdMgƒedVd!edWƒd)dKdLdMgƒedXd!edYƒd)dKdLdMgƒedZd!ed[ƒd)dKdLdMgƒed\d!ed]ƒd.ed^ƒd)dKdLdMgƒed_d!ed`ƒd.edaƒd)dKdLdMgƒedbeddd!edcƒd.eddƒƒedeeddfd!edgƒd.edhƒƒedieddjd!edkƒd.edlƒƒedmd!ednƒd)dKdLdMgƒedod!edpƒd.edqƒd)dKdLdMgƒefZedrƒZds„ZRS(ys Sudo Rule object. s sudo rules sudo rulestipaassociationt ipasudoruletcntipaenabledflagRt descriptiont usercategoryt hostcategoryt cmdcategoryt memberusert memberhosttmemberallowcmdt memberdenycmdt ipasudooptt ipasudorunastipasudorunasgrouptipasudorunasusercategorytipasudorunasgroupcategoryt sudoordert ipauniqueidtusertgroupthostt hostgrouptsudocmdt sudocmdgroups Sudo Ruless Sudo Ruletcli_namet sudorule_nametlabels Rule namet primary_keys description?tdesct Descriptionsipaenabledflag?tEnabledtflagst no_options usercategory?tusercats User categorytdocs!User category the rule applies totvaluesualls hostcategory?thostcats Host categorys!Host category the rule applies tos cmdcategory?tcmdcatsCommand categorys$Command category the rule applies tosipasudorunasusercategory?t runasusercatsRunAs User categorys'RunAs User category the rule applies tosipasudorunasgroupcategory?t runasgroupcatsRunAs Group categorys(RunAs Group category the rule applies tos sudoorder?torders Sudo ordersinteger to order the Sudo rulestdefaultitminvaluesmemberuser_user?tUserst no_createt no_updatet no_searchsmemberuser_group?s User Groupssmemberhost_host?tHostssmemberhost_hostgroup?s Host Groupssmemberallowcmd_sudocmd?sSudo Allow Commandssmemberdenycmd_sudocmd?sSudo Deny Commandssmemberallowcmd_sudocmdgroup?sSudo Allow Command Groupssmemberdenycmd_sudocmdgroup?sSudo Deny Command Groupssipasudorunas_user?s RunAs Userss Run as a usersipasudorunas_group?sGroups of RunAs Userss(Run as any user within a specified groups externaluser?s External Users6External User the rule applies to (sudorule-find only)sipasudorunasextuser?RsRunAs External Users:External User the commands can run as (sudorule-find only)sipasudorunasextgroup?RsRunAs External Groups;External Group the commands can run as (sudorule-find only)s ipasudoopt?s Sudo Optionsipasudorunasgroup_group?s RunAs Groupss+Run with the gid of a specified POSIX groupsAorder must be a unique value (%(order)d already used by %(rule)s)cOsŒd|jo{|iid|dƒd}t|ƒdjoG|ddd}tiddd|ih|dd6|d6ƒ‚qˆndS( NR)tresultiRR RAR trule(tmethodstfindtlenRR torder_not_unique_msg(tselftkeystoptionstentriest rule_name((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytcheck_order_uniquenessãs      (uall(uall(uall(uall(uall(t__name__t __module__t__doc__Rtenvtcontainer_sudorulet container_dnRt object_nametobject_name_pluralt object_classtdefault_attributestuuid_attributet rdn_attributetattribute_membersR3tlabel_singularRtTrueRRtIntRRRtexternal_host_paramt takes_paramsRNRT(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRHsî                                                                                t sudorule_addcBs)eZedƒZd„ZedƒZRS(sCreate new Sudo Rule.cOs!|ii||Žd|d<|S(NtTRUER(tobjRT(ROtldaptdnt entry_attrst attrs_listRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyt pre_callbackøs sAdded Sudo Rule "%(value)s"(RURVRRWRnt msg_summary(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRgõs  t sudorule_delcBs eZedƒZedƒZRS(sDelete Sudo Rule.sDeleted Sudo Rule "%(value)s"(RURVRRWRo(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRps t sudorule_modcBs)eZedƒZedƒZd„ZRS(sModify Sudo Rule.sModified Sudo Rule "%(value)s"c Os d|joŒ|idƒ}|iii|dƒd}d|jo<t|ddƒ} | |jo|ii||Žq•q™|ii||Žny"|i||iiƒ\} } Wn&t i j o|ii |ŒnXt |dƒo)d| jot i dtdƒƒ‚nt |d ƒo)d | jot i dtd ƒƒ‚nt |d ƒo0d pd| jot i dtdƒƒ‚nt |dƒo)d| jot i dtdƒƒ‚nt |dƒo)d| jot i dtdƒƒ‚n|S(NR)iÿÿÿÿRIiRR treasonsBuser category cannot be set to 'all' while there are allowed usersRR!sBhost category cannot be set to 'all' while there are allowed hostsRR"tmemberdenywcmdsNcommand category cannot be set to 'all' while there are allow or deny commandsR'R%s@user runAs category cannot be set to 'all' while there are usersR(R&sBgroup runAs category cannot be set to 'all' while there are groups(tgetRtCommandt sudorule_showtintRiRTt get_entryR^RtNotFoundthandle_not_foundRtMutuallyExclusiveErrorR( RORjRkRlRmRPRQt new_ordert old_entryt old_ordert_dnt _entry_attrs((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRns0   " (RURVRRWRoRn(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRq s  t sudorule_findcBs&eZedƒZedddƒZRS(sSearch for Sudo Rule.s%(count)d Sudo Rule matcheds%(count)d Sudo Rules matchedi(RURVRRWRRo(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR1s RvcBseZedƒZRS(sDisplay Sudo Rule.(RURVRRW(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRv;stsudorule_enablecBs&eZedƒZd„Zd„ZRS(sEnable a Sudo Rule.cCsŠ|ii}|ii|ƒ}hdd6}y|i||ƒWn;tij on'tij o|ii|ƒnXtdt ƒS(NRhRRI( Ritbackendtget_dnt update_entryRt EmptyModlistRyRztdictRc(RORRjRkRl((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytexecuteDs  cCs|itdƒ|ƒdS(NsEnabled Sudo Rule "%s"(t print_dashedR(ROttextuiRIR((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytoutput_for_cliSs(RURVRRWRˆR‹(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR‚As  tsudorule_disablecBs&eZedƒZd„Zd„ZRS(sDisable a Sudo Rule.cCsŠ|ii}|ii|ƒ}hdd6}y|i||ƒWn;tij on'tij o|ii|ƒnXtdt ƒS(NtFALSERRI( RiRƒR„R…RR†RyRzR‡Rc(RORRjRkRl((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRˆ\s  cCs|itdƒ|ƒdS(NsDisabled Sudo Rule "%s"(R‰R(RORŠRIR((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR‹ks(RURVRRWRˆR‹(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRŒYs  tsudorule_add_allow_commandcBs,eZedƒZdgZdZd„ZRS(s;Add commands and sudo command groups affected by Sudo Rule.R"s%i object added.s%i objects added.c Os{y"|i||iiƒ\}}Wn&tij o|ii|ŒnXt|dƒotidtdƒƒ‚n|S(NRRrs4commands cannot be added when command category='all'( RxRiR^RRyRzRR{R( RORjRktfoundt not_foundRPRQRR€((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRnws"(s%i object added.s%i objects added.(RURVRRWtmember_attributestmember_count_outRn(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRŽqs  tsudorule_remove_allow_commandcBs#eZedƒZdgZdZRS(s>Remove commands and sudo command groups affected by Sudo Rule.R"s%i object removed.s%i objects removed.(s%i object removed.s%i objects removed.(RURVRRWR‘R’(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR“…s  tsudorule_add_deny_commandcBs,eZedƒZdgZdZd„ZRS(s;Add commands and sudo command groups affected by Sudo Rule.R#s%i object added.s%i objects added.c Os{y"|i||iiƒ\}}Wn&tij o|ii|ŒnXt|dƒotidtdƒƒ‚n|S(NRRrs4commands cannot be added when command category='all'( RxRiR^RRyRzRR{R( RORjRkRRRPRQRR€((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRn”s"(s%i object added.s%i objects added.(RURVRRWR‘R’Rn(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR”Žs  tsudorule_remove_deny_commandcBs#eZedƒZdgZdZRS(s>Remove commands and sudo command groups affected by Sudo Rule.R#s%i object removed.s%i objects removed.(s%i object removed.s%i objects removed.(RURVRRWR‘R’(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR•¡s  tsudorule_add_usercBs5eZedƒZdgZdZd„Zd„ZRS(s+Add users and groups affected by Sudo Rule.R s%i object added.s%i objects added.c Osy"|i||iiƒ\}}Wn&tij o|ii|ŒnXt|dƒotidtdƒƒ‚nt d||||ƒS(NRRrs.users cannot be added when user category='all'R+( RxRiR^RRyRzRR{Rtadd_external_pre_callback( RORjRkRRRPRQRR€((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRn°s"c Os%tddd|||||||ƒ S(NR R+R(tadd_external_post_callback(RORjt completedtfailedRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyt post_callbackºs(s%i object added.s%i objects added.(RURVRRWR‘R’RnR›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR–ªs    tsudorule_remove_usercBs,eZedƒZdgZdZd„ZRS(s.Remove users and groups affected by Sudo Rule.R s%i object removed.s%i objects removed.c Os%tddd|||||||ƒ S(NR R+R(tremove_external_post_callback(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›Çs(s%i object removed.s%i objects removed.(RURVRRWR‘R’R›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRœÁs  tsudorule_add_hostcBs5eZedƒZdgZdZd„Zd„ZRS(s/Add hosts and hostgroups affected by Sudo Rule.R!s%i object added.s%i objects added.c Osy"|i||iiƒ\}}Wn&tij o|ii|ŒnXt|dƒotidtdƒƒ‚nt d||||ƒS(NRRrs.hosts cannot be added when host category='all'R-( RxRiR^RRyRzRR{RR—( RORjRkRRRPRQRR€((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRnÔs"c Os%tddd|||||||ƒ S(NR!R-t externalhost(R˜(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›Þs(s%i object added.s%i objects added.(RURVRRWR‘R’RnR›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRžÎs    tsudorule_remove_hostcBs,eZedƒZdgZdZd„ZRS(s2Remove hosts and hostgroups affected by Sudo Rule.R!s%i object removed.s%i objects removed.c Os%tddd|||||||ƒ S(NR!R-RŸ(R(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›ës(s%i object removed.s%i objects removed.(RURVRRWR‘R’R›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR ås  tsudorule_add_runasusercBs5eZedƒZdgZdZd„Zd„ZRS(s,Add users and groups for Sudo to execute as.R%s%i object added.s%i objects added.c Osvd„}y"|i||iiƒ\}} Wn&tij o|ii|ŒnXt| dƒpt| dƒotidtdƒƒ‚nd|jo[xX|dD]H} || ƒp5ti ddd t td ƒƒt d| ƒƒ‚q¨q¨Wnd |jo[xX|d D]H} || ƒp5ti ddd t td ƒƒt d| ƒƒ‚qqWnt d||||ƒS( NcSs(t|ƒ}|iƒdjotStS(NuALL(tunicodetuppertFalseRc(trunastv((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytcheck_validityùs R'R(RrsCusers cannot be added when runAs user or runAs group category='all'R+R s runas-userR s3RunAsUser does not accept '%(name)s' as a user nameR,s4RunAsUser does not accept '%(name)s' as a group name( RxRiR^RRyRzRR{RR R¢R‡R—( RORjRkRlRmRPRQR§RR€R ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRn÷s. "      c Os%tddd|||||||ƒ S(NR%R+tipasudorunasextuser(R˜(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›s(s%i object added.s%i objects added.(RURVRRWR‘R’RnR›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR¡ñs    tsudorule_remove_runasusercBs,eZedƒZdgZdZd„ZRS(s/Remove users and groups for Sudo to execute as.R%s%i object removed.s%i objects removed.c Os%tddd|||||||ƒ S(NR%R+R¨(R(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›#s(s%i object removed.s%i objects removed.(RURVRRWR‘R’R›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR©s  tsudorule_add_runasgroupcBs5eZedƒZdgZdZd„Zd„ZRS(s!Add group for Sudo to execute as.R&s%i object added.s%i objects added.c Osd„}y"|i||iiƒ\}} Wn&tij o|ii|ŒnXt| dƒpt| dƒotidtdƒƒ‚nd|jo[xX|dD]H} || ƒp5ti ddd t td ƒƒt d| ƒƒ‚q¨q¨Wnt d||||ƒS( NcSs(t|ƒ}|iƒdjotStS(NuALL(R¢R£R¤Rc(R¥R¦((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR§2s R'R(RrsCusers cannot be added when runAs user or runAs group category='all'R,R s runas-groupR s5RunAsGroup does not accept '%(name)s' as a group name( RxRiR^RRyRzRR{RR R¢R‡R—( RORjRkRlRmRPRQR§RR€R ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRn0s  "   c Os%tddd|||||||ƒ S(NR&R,tipasudorunasextgroup(R˜(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›Is(s%i object added.s%i objects added.(RURVRRWR‘R’RnR›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRª*s    tsudorule_remove_runasgroupcBs,eZedƒZdgZdZd„ZRS(s$Remove group for Sudo to execute as.R&s%i object removed.s%i objects removed.c Os%tddd|||||||ƒ S(NR&R,R«(R(RORjR™RšRkRlRPRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR›Vs(s%i object removed.s%i objects removed.(RURVRRWR‘R’R›(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR¬Ps  tsudorule_add_optioncBsGeZedƒZeddddedƒƒfZd„Zd„ZRS(sAdd an option to the Sudo Rule.R$R1t sudooptionR3s Sudo Optionc Ks_|ii}|ii|ƒ}|diƒptiƒ‚n|i|dgƒ\}}yC|d|djo!|idgƒi|dƒn ti ‚Wn0t j o$|idgƒi|dƒnXy|i ||ƒWn;tij on'ti j o|ii |ƒnX|ii}|i||d|iiƒ\}}td|ƒS(NR$t normalizeRI(RiRƒR„tstripRR†Rxt setdefaulttappendtDuplicateEntrytKeyErrorR…RyRzR^t normalize_dnR‡(RORRQRjRkRlRm((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRˆgs.   cKsM|itdƒtd|dd|ƒƒtt|ƒi||||ƒdS(Ns1Added option "%(option)s" to Sudo Rule "%(rule)s"toptionR$RJ(R‰RR‡tsuperR­R‹(RORŠRIRRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR‹‡s(RURVRRWRt takes_optionsRˆR‹(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR­]s    tsudorule_remove_optioncBsGeZedƒZeddddedƒƒfZd„Zd„ZRS(s Remove an option from Sudo Rule.R$R1R®R3s Sudo Optionc Ksh|ii}|ii|ƒ}|diƒptiƒ‚n|i|dgƒ\}}yf|d|djo1|idgƒi|dƒ|i ||ƒnti ddd|dƒ‚Wnht j o }nUt j o#ti ddd|dƒ‚n'ti j o|ii|ƒnX|ii}|i||d|iiƒ\}}td|ƒS(NR$tattrRR¯RI(RiRƒR„R°RR†RxR±tremoveR…tAttrValueNotFoundt ValueErrorR´RyRzR^RµR‡(RORRQRjRkRlteRm((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyRˆ›s2     cKsM|itdƒtd|dd|ƒƒtt|ƒi||||ƒdS(Ns5Removed option "%(option)s" from Sudo Rule "%(rule)s"R¶R$RJ(R‰RR‡R·R¹R‹(RORŠRIRRQ((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR‹¾s(RURVRRWRR¸RˆR‹(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pyR¹‘s    #N(1tipalibRRRRRtipalib.plugins.baseldaptipalib.plugins.hbacruleRRRRWttopicRRRRt LDAPObjectRtregistert LDAPCreateRgt LDAPDeleteRpt LDAPUpdateRqt LDAPSearchRt LDAPRetrieveRvt LDAPQueryR‚RŒt LDAPAddMemberRŽtLDAPRemoveMemberR“R”R•R–RœRžR R¡R©RªR¬R­R¹(((s;/usr/lib/python2.6/site-packages/ipalib/plugins/sudorule.pytsn      ª   "             )  #  1 2