Ñò Ã#xPc@s4ddklZlZddklZlZlZddkTddklZlZddk l Z edƒZ edƒZ d„Z d „Zd efd „ƒYZeieƒd efd „ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZeieƒdefd„ƒYZ eie ƒde!fd„ƒYZ"eie"ƒdefd„ƒYZ#eie#ƒd e!fd!„ƒYZ$eie$ƒd"S(#iÿÿÿÿ(tapiterrors(tStrtStrEnumtBool(t*(t_tngettext(tis_allsü SELinux User Mapping Map IPA users to SELinux users by host. Hosts, hostgroups, users and groups can be either defined within the rule or it may point to an existing HBAC rule. When using --hbacrule option to selinuxusermap-find an exact match is made on the HBAC rule name, so only one or zero entries will be returned. EXAMPLES: Create a rule, "test1", that sets all users to xguest_u:s0 on the host "server": ipa selinuxusermap-add --usercat=all --selinuxuser=xguest_u:s0 test1 ipa selinuxusermap-add-host --hosts=server.example.com test1 Create a rule, "test2", that sets all users to guest_u:s0 and uses an existing HBAC rule for users and hosts: ipa selinuxusermap-add --usercat=all --hbacrule=webserver --selinuxuser=guest_u:s0 test2 Display the properties of a rule: ipa selinuxusermap-show test2 Create a rule for a specific user. This sets the SELinux context for user john to unconfined_u:s0-s0:c0.c1023 on any machine: ipa selinuxusermap-add --hostcat=all --selinuxuser=unconfined_u:s0-s0:c0.c1023 john_unconfined ipa selinuxusermap-add-user --users=john john_unconfined Disable a rule: ipa selinuxusermap-disable test1 Enable a rule: ipa selinuxusermap-enable test1 Find a rule referencing a specific HBAC rule: ipa selinuxusermap-find --hbacrule=allow_some Remove a rule: ipa selinuxusermap-del john_unconfined SEEALSO: The list controlling the order in which the SELinux user map is applied and the default SELinux user are available in the config-show command. s.HBAC rule and local members cannot both be setc Csçtidƒ}tidƒ}tidƒ}|diddƒ\}}}}|i|ƒp tdƒS| p|i|ƒ o tdƒS|i|ƒ} |o?| p,| idƒo't| idƒƒd jo td ƒSd S( sÈ An SELinux user has 3 components: user:MLS:MCS. user and MLS are required. user traditionally ends with _u but this is not mandatory. The regex is ^[a-zA-Z][a-zA-Z_]* The MLS part can only be: Level: s[0-15](-s[0-15]) Then MCS could be c[0-1023].c[0-1023] and/or c[0-1023]-c[0-c0123] Meaning s0 s0-s1 s0-s15:c0.c1023 s0-s1:c0,c2,c15.c26 s0-s0:c0.c1023 Returns a message on invalid, returns nothing on valid. s^[a-zA-Z][a-zA-Z_]*$s*^s[0-9][1-5]{0,1}(-s[0-9][1-5]{0,1}){0,1}$s^c(\d+)([.,-]c(\d+))*?$s:::t:is5Invalid SELinux user name, only a-Z and _ are alloweds/Invalid MLS value, must match s[0-15](-s[0-15])iÿsMInvalid MCS value, must match c[0-1023].c[0-1023] and/or c[0-1023]-c[0-c0123]N(tretcompiletsplittmatchRtgrouptinttNone( tugettexttusert regex_namet regex_mlst regex_mcstnametmlstmcstignoretm((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pytvalidate_selinuxuserJs"  ; cCsž|iƒd}|idgƒ}t|ƒdjotidtdƒƒ‚n|didƒ}||jo)tidtdƒtd|ƒƒ‚nd S( sŒ Ensure the user is in the list of allowed SELinux users. Returns nothing if the user is found, raises an exception otherwise. itipaselinuxusermapordertreasons0SELinux user map list not found in configurationit$s<SELinux user %(user)s not found in ordering list (in config)RN(tget_ipa_configtgettlenRtNotFoundRR tdict(tldapRtconfigtitemtuserlist((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pytvalidate_selinuxuser_inlistms   tselinuxusermapcBsJeZdZeiiZedƒZedƒZ ddgZ ddddd dd d d d dg Z dZ dZ hddgd 6ddgd 6ZedƒZedƒZeddddedƒdeƒededddedƒƒeddddedƒd ed!ƒƒed"dd#ded$ƒd ed%ƒd&d@ƒed(dd)ded*ƒd ed+ƒd&dAƒed,dd-ded.ƒƒed/ded0ƒd1d2gƒed3ded4ƒd1d5d6d7gƒed8ded9ƒd1d5d6d7gƒed:ded;ƒd1d5d6d7gƒed<ded=ƒd1d5d6d7gƒf Zd>„Zd?„ZRS(Bs" SELinux User Map object. sSELinux User Map rulesSELinux User Map rulestipaassociationtipaselinuxusermaptcntipaenabledflagt descriptiont usercategoryt hostcategoryt memberusert memberhosttmemberhostgrouptseealsotipaselinuxusert ipauniqueidRRthostt hostgroupsSELinux User MapssSELinux User Maptcli_nameRtlabels Rule namet primary_keyt selinuxusers SELinux Usersseealso?thbacrules HBAC Ruletdocs7HBAC Rule that defines the users, groups and hostgroupss usercategory?tusercats User categorys!User category the rule applies totvaluesualls hostcategory?thostcats Host categorys!Host category the rule applies tos description?tdesct Descriptionsipaenabledflag?tEnabledtflagst no_optionsmemberuser_user?tUserst no_createt no_updatet no_searchsmemberuser_group?s User Groupssmemberhost_host?tHostssmemberhost_hostgroup?s Host Groupsc CsÙ|pdSyt|ƒ}t|ƒSWn¬tj o y[|ii|iidii ||iidi dg|iidi ƒ\}}|}WqÕt i j o,t i dtdƒtd|ƒƒ‚qÕXnX|S(sP Given a HBAC rule name verify its existence and return the dn. R=tRsHBAC rule %(rule)s not foundtruleN(RtDNtstrt ValueErrortbackendtfind_entry_by_attrRtObjectR;Rt object_classt container_dnRR"RR#(tselfR4tdnt entry_attrs((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyt_normalize_seealsoÐs"   /cKsb|idtƒodSd|jo9|i|dddgƒ\}}|dd|dsc3sx|]}ˆ|ƒVqWdS(N((t.0tattr(t is_to_be_set(sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pys s R/R0R4R(s usercategorys hostcategory( t isinstanceRNtAssertionErrorR(tanyRtMutuallyExclusiveErrort notboth_errtobjRY( RVR$RWRXt attrs_listtkeysR]tare_local_members_to_be_settis_hbacrule_to_be_set((RXRusA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyt pre_callbackûs   cOs1t|tƒpt‚|ii||||S(N(RvRNRwR{R`(RVR$RWRXR}R]((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyt post_callbacks(RaRbRRct msg_summaryR€R(((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyRoös   tselinuxusermap_delcBs eZedƒZedƒZRS(sDelete a SELinux User Map.s$Deleted SELinux User Map "%(value)s"(RaRbRRcR‚(((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyRƒs tselinuxusermap_modcBs2eZedƒZedƒZd„Zd„ZRS(sModify a SELinux User Map.s%Modified SELinux User Map "%(value)s"c s†t|tƒpt‚y|i||ƒ\}‰Wn&tij o|ii|ŒnX‡‡fd†‰‡‡‡fd†‰t‡fd†d Dƒƒ}ˆdƒ} |o| oti d t ƒ‚nt ˆdƒo#dˆjoti d d ƒ‚nt ˆdƒo#dˆjoti d d ƒ‚nd ˆjot |ˆd ƒndˆjo|ii ˆdƒˆd8s R/R0R1R2R4RsBuser category cannot be set to 'all' while there are allowed userssBhost category cannot be set to 'all' while there are allowed hostsR5(s usercategorys hostcategorys memberusers memberhost(RvRNRwR\RR"R{thandle_not_foundRxRyRzRR(RY( RVR$RWRXR|R}R]t_dnR~R((RXRuR…R†sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyR€(s0    cOs1t|tƒpt‚|ii||||S(N(RvRNRwR{R`(RVR$RWRXR}R]((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyRSs(RaRbRRcR‚R€R(((sA/usr/lib/python2.6/site-packages/ipalib/plugins/selinuxusermap.pyR„#s   +tselinuxusermap_findcBs8eZedƒZedddƒZd„Zd„ZRS(sSearch for SELinux User Maps.s"%(count)d SELinux User Map matcheds#%(count)d SELinux User Maps matchedicOs›|idƒor|d}y+tid|dtƒd}|d}Wn,tij otdddgdtƒSX||dsB +   # r "  5