Ñò ìÿÒXc@sßdZddklZddklZlZlZddklZlZddkl Z l Z l Z l Z ddk lZddklZddklZlZdd klZdd kTdd klZd Zhd eedIeiieiiƒƒd6d eedJeiieiiƒƒd6d eedKeiieiiƒƒd6d eedLeiieiiƒƒd6d eedMeiieiiƒƒd6d eedNeii eiiƒƒd6d eedOeii!eiiƒƒd6Z"ddddd gZ#dPZ$d%ei%fd&„ƒYZ&ei%d'e'd(ƒei(ei)fZ*d)„Z+d*„Z,d+„Z-d,„Z.e/e/d-„Z0d.„Z1d/„Z2d0„Z3d1„Z4e d2d3d4d5ed6ƒd7ed8ƒd9e$ƒZ5d:efd;„ƒYZ6ei7e6ƒd<ei8fd=„ƒYZ9ei7e9ƒd>ei:fd?„ƒYZ;ei7e;ƒd@ei<fdA„ƒYZ=ei7e=ƒdBei>fdC„ƒYZ?ei7e?ƒdDei@fdE„ƒYZAei7eAƒdFei<fdG„ƒYZBei7eBƒdHS(Qs  Directory Server Access Control Instructions (ACIs) ACIs are used to allow or deny access to information. This module is currently designed to allow, not deny, access. The aci commands are designed to grant permissions that allow updating existing entries or adding or deleting new ones. The goal of the ACIs that ship with IPA is to provide a set of low-level permissions that grant access to special groups called taskgroups. These low-level permissions can be combined into roles that grant broader access. These roles are another type of group, roles. For example, if you have taskgroups that allow adding and modifying users you could create a role, useradmin. You would assign users to the useradmin role to allow them to do the operations defined by the taskgroups. You can create ACIs that delegate permission so users in group A can write attributes on group B. The type option is a map that applies to all entries in the users, groups or host location. It is primarily designed to be used when granting add permissions (to write new entries). An ACI consists of three parts: 1. target 2. permissions 3. bind rules The target is a set of rules that define which LDAP objects are being targeted. This can include a list of attributes, an area of that LDAP tree or an LDAP filter. The targets include: - attrs: list of attributes affected - type: an object type (user, group, host, service, etc) - memberof: members of a group - targetgroup: grant access to modify a specific group. This is primarily designed to enable users to add or remove members of a specific group. - filter: A legal LDAP filter used to narrow the scope of the target. - subtree: Used to apply a rule across an entire set of objects. For example, to allow adding users you need to grant "add" permission to the subtree ldap://uid=*,cn=users,cn=accounts,dc=example,dc=com. The subtree option is a fail-safe for objects that may not be covered by the type option. The permissions define what the ACI is allowed to do, and are one or more of: 1. write - write one or more attributes 2. read - read one or more attributes 3. add - add a new entry to the tree 4. delete - delete an existing entry 5. all - all permissions are granted Note the distinction between attributes and entries. The permissions are independent, so being able to add a user does not mean that the user will be editable. The bind rule defines who this ACI grants permissions to. The LDAP server allows this to be any valid LDAP entry but we encourage the use of taskgroups so that the rights can be easily shared through roles. For a more thorough description of access controls see http://www.redhat.com/docs/manuals/dir-server/ag/8.0/Managing_Access_Control.html EXAMPLES: NOTE: ACIs are now added via the permission plugin. These examples are to demonstrate how the various options work but this is done via the permission command-line now (see last example). Add an ACI so that the group "secretaries" can update the address on any user: ipa group-add --desc="Office secretaries" secretaries ipa aci-add --attrs=streetAddress --memberof=ipausers --group=secretaries --permissions=write --prefix=none "Secretaries write addresses" Show the new ACI: ipa aci-show --prefix=none "Secretaries write addresses" Add an ACI that allows members of the "addusers" permission to add new users: ipa aci-add --type=user --permission=addusers --permissions=add --prefix=none "Add new users" Add an ACI that allows members of the editors manage members of the admins group: ipa aci-add --permissions=write --attrs=member --targetgroup=admins --group=editors --prefix=none "Editors manage admins" Add an ACI that allows members of the admins group to manage the street and zip code of those in the editors group: ipa aci-add --permissions=write --memberof=editors --group=admins --attrs=street,postalcode --prefix=none "admins edit the address of editors" Add an ACI that allows the admins group manage the street and zipcode of those who work for the boss: ipa aci-add --permissions=write --group=admins --attrs=street,postalcode --filter="(manager=uid=boss,cn=users,cn=accounts,dc=example,dc=com)" --prefix=none "Edit the address of those who work for the boss" Add an entirely new kind of record to IPA that isn't covered by any of the --type options, creating a permission: ipa permission-add --permissions=add --subtree="cn=*,cn=orange,cn=accounts,dc=example,dc=com" --desc="Add Orange Entries" add_orange The show command shows the raw 389-ds ACI. IMPORTANT: When modifying the target attributes of an existing ACI you must include all existing attributes as well. When doing an aci-mod the targetattr REPLACES the current attributes, it does not add to them. iÿÿÿÿ(tdeepcopy(tapitcrudterrors(tObjecttCommand(tFlagtInttStrtStrEnum(tACI(toutput(t_tngettext(tgen_pkey_only_option(t*(tDNt:sldap:///tuidRtusertcntgrouptfqdnthostt hostgrouptkrbprincipalnametservicet ipauniqueidtnetgrouptidnsnamet dnsrecordureaduwriteuaddudeleteuallu permissionu delegationu selfserviceunonet ListOfACIcBs)eZeefZedƒZd„ZRS(sA list of ACI valuesc Cs‰t||iƒpt‚xht|ƒD]Z\}}t|tƒp>tti|i|i i |i|tt|ƒ|fƒ‚q'q'WdS(N( t isinstancettypetAssertionErrort enumeratetunicodet TypeErrorR temsgtnamet __class__t__name__(tselftcmdtentriestitentry((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pytvalidateœs  (R)t __module__tlistttupleR!R tdocR/(((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyR˜s  tresultsA string representing the ACIcCs|djo|S|t|S(s: Given a name and a prefix construct an ACI name. unone(tACI_NAME_PREFIX_SEP(t aciprefixtaciname((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyt_make_aci_name¬s cCs;|itƒ}|dpd|dfS|d|dfS(sj Parse the raw ACI name and return a tuple containing the ACI prefix and the actual ACI name. iunonei(t partitionR5(R7taciparts((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyt_parse_aci_nameµs cCsR|idƒ}|djotidi|ƒS|id|ƒ}||d|!S(s6 Pull the group name out of a memberOf filter s memberOf=iÿÿÿÿRt)i (tfindRRtget_dn(tmemberoftstten((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyt_group_from_memberofÁs  cCsˆddddddg}h}x=|D]5}||jo||d(j || Given a name and a set of keywords construct an ACI. R!tfiltertsubtreet targetgrouptattrsR?iR'ttargetterrors<type, filter, subtree and targetgroup are mutually exclusiveR6sACI prefix is requiredisSat least one of: type, filter, subtree, targetgroup, attrs or memberof are requireds*filter and memberof are mutually exclusiveRt permissiontselfacis1group, permission and self are mutually exclusives,One of group, permission or self is requiredtpermission_showR4ttestRtdntreasonsGroup '%s' does not existt permissionssuserdn = "ldap:///self"sgroupdn = "ldap:///%s"s memberOf=%stutinfos empty filters ldap:///%ssldap:///sSyntax Error: %(error)sN(RPNu("tNonetFalseRtValidationErrorR tsumt itervaluestTrueRRtNotFoundtgetRtenvtcontainer_permissionRtget_dn_if_existsR R8R'ROt set_bindruletset_target_attrthandle_not_foundRBtset_target_filtertBadSearchFiltert find_entriest _type_mapt set_targett startswitht SyntaxErrortdicttstr(tldaptcurrentR7tkwt checked_argstvalidtargRRIRJt entry_attrstetgroup_dntaRMtgroupdnR,RG((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyt _make_aciÌs˜ )" """  "" /)           6c Cs’h}t|iƒ\|d<|d<|o|St|iƒ|dnXtii| jo|d d|d|D]6}|iƒiƒ}||jo|i|ƒqqWdi|ƒS(NR“(R|R”R‘R‹tjoin(ROR—R˜((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyt_normalize_permissions‘s R6tcli_nametprefixtlabels ACI prefixR3sPPrefix used to distinguish ACI types (permission, delegation, selfservice, none)tvaluestacicBs*eZdZeZedƒZeddddedƒdedd=ƒed dd ded ƒd edƒdd>ƒeddddedƒd edƒdd?ƒededddedƒd edƒdede dd@ƒeddddedƒd edƒdeddAƒe ddddedƒd ed ƒd!dBddCƒed)dd*ded+ƒd ed,ƒddDƒed-dd.ded/ƒd ed0ƒddEƒed1dd2ded3ƒd ed4ƒddFƒed5dd6ded7ƒd ed8ƒddGƒe d9dd:ded;ƒd ed<ƒddHƒf Z RS(Is ACI object. tACIsR7RœR'RžsACI namet primary_keytflagstvirtual_attributes permission?RIt PermissionR3sPermission ACI grants access tosgroup?Rs User groupsUser group ACI grants access tos permissions+ROt PermissionssKcomma-separated list of permissions to grant(read, write, add, delete, all)tcsvt normalizersattrs*RFt Attributess"Comma-separated list of attributesstype?R!tTypesDtype of IPA object (user, group, host, hostgroup, service, netgroup)RŸuuserugroupuhostuserviceu hostgroupunetgroupu dnsrecords memberof?R?s Member ofsMember of a groupsfilter?RCtFilters'Legal LDAP filter (e.g. ou=Engineering)ssubtree?RDtSubtreesSubtree to apply ACI tos targetgroup?REs Target groupsGroup to apply ACI tosselfaci?R*sTarget your own entry (self)s"Apply ACI to your own entry (self)(R¤(R¤(R¤(R¤(R¤(uuserugroupuhostuserviceu hostgroupunetgroupu dnsrecord(R¤(R¤(R¤(R¤(R¤(R¤( R)R0t__doc__RWtNO_CLIR RžRR™R›R Rt takes_params(((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyR ¢s|                                 taci_addcBsMeZdZeZedƒZeeddedƒde ƒfZ d„Z RS(s Create new ACI. sCreated ACI "%(value)s"stest?R3s,Test the ACI syntax but don't write anythingtdefaultc KsYd|jpt‚|iii}t|d||ƒ}|i|iiidgƒ\}}t |i dgƒƒ}xA|D]9}|i |ƒp|i |i jot iƒ‚q{q{Wt|ƒ} |di| ƒ|i dtƒp|i||ƒn|i dtƒotdt| ƒƒ} nt|||i dtƒƒ} td| d|ƒS(së Execute the aci-create operation. Returns the entry as it will be created in LDAP. :param aciname: The name of the ACI being added. :param kw: Keyword arguments for the other LDAP attributes. R7R RLtrawR4tvalueN(R"RtBackendtldap2RtRRR„RZRRRYtisequalR'RtDuplicateEntryR$R‹RSt update_entryRgRŠ( R*R7RkRitnewaciRMRoRRrt newaci_strR4((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pytexecutes& $# ( R)R0R­RWR®R t msg_summaryt_prefix_optionRRSt takes_optionsR»(((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyR°ös    taci_delcBs;eZdZeZeiZedƒZ e fZ d„Z RS(s Delete ACI. sDeleted ACI "%(value)s"c CsÏ|iii}|i|iiidgƒ\}}|idgƒ}t|ƒ}t|||ƒ}x<|D]4} t | ƒ} |i | ƒo|i | ƒPqjqjW||d<|i ||ƒt dtd|ƒS(s™ Execute the aci-delete operation. :param aciname: The name of the ACI being deleted. :param aciprefix: The ACI prefix. R R4R³(RR´RµR„RZRRYRR’R R¶tremoveR¸RgRW( R*R7R6RiRMRoRŽRR Rrt candidate((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyR»7s $     ( R)R0R­RWR®R tstandard_booleant has_outputR R¼R½R¾R»(((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyR¿-s    taci_modcBsVeZdZeZeddedƒƒfZefZ dgZ edƒZ d„Z RS(s Modify ACI. R RžR trenamesModified ACI "%(value)s"c Ksä|d}|iii}|i|iiidgƒ\}}t|idgƒƒ}t|||ƒ}t ||ƒ} t | ƒ} | idt ƒot |d $   ! ( R)R0R­RWR®RR thas_output_paramsR½R¾tinternal_optionsR¼R»(((s6/usr/lib/python2.6/site-packages/ipalib/plugins/aci.pyRÄWs    taci_findcBsPeZdZeZedddƒZeidde ƒe dƒfZ d„Z RS(sX Search for ACIs. Returns a list of ACIs EXAMPLES: To find all ACIs that apply directly to members of the group ipausers: ipa aci-find --memberof=ipausers To find all ACIs that grant add access: ipa aci-find --permissions=add Note that the find command only looks for the given text in the set of ACIs, it does not evaluate the ACIs to see if something would apply. For example, searching on memberof=ipausers will find all ACIs that have ipausers as a memberof. There may be other ACIs that apply to members of that group indirectly. s%(count)d ACI matcheds%(count)d ACIs matchedis aciprefix?trequiredR'c)KsX |iii}|i|iiidgƒ\}}t|idgƒƒ}g}|oj|iƒ}xK|D]C}|i iƒi |ƒdjo||jo|i |ƒqkqkWt |ƒ}n t |ƒ}|idƒoXxE|D]=}t |i ƒ\} } | |djo|i|ƒqåqåWt |ƒ}n|idƒoXxE|D]=}t |i ƒ\} } | |djo|i|ƒqMqMWt |ƒ}n|idƒoèxÕ|D]Í}d|ijo|i|ƒqµntg} |iddD]} | | iƒqø~ ƒ} tg}|dD]} || iƒq)~ƒ}tt| ƒt|ƒ@ƒt|ƒjo|i|ƒqµqµWt |ƒ}n|idƒoy|iid |dƒWntij oq%Xx7|D]/}|idd |jo|i|ƒqâqâWt |ƒ}n|id ƒozxg|D]_}t|iƒ} t|d ƒ}tt| ƒt|ƒ@ƒt|ƒjo|i|ƒq<q<Wt |ƒ}n|id ƒoœyt|d ƒ}Wntij oq[Xd |}xb|D]V}d|ijo3|idd}||jo|i|ƒqSqý|i|ƒqýWn|idƒoÆxÃ|D]·}d|ijo|idd}n|i|ƒqrt}xAtiƒD]3}t||jo|d|jo t}PqÀqÀW|p+y|i|ƒWq)tj oq)XqrqrWn|idtƒtjoTxQ|D]E}|iddjo+y|i|ƒWq–tj oq–XqQqQWn|idƒo·x´|D]¨}|id}t|iddƒƒ}y|dd}Wnt t!fj o d}nX|djp||djo+y|i|ƒWq]tj oq]XqµqµWn|idƒox|D]ù}t}d|ijo«|idd}t|iddƒƒ}ttii#tiiƒ}|i$|ƒoSy|dd}Wnt t!fj o d}nX||djo t}q?qCn|p+y|i|ƒWqutj oquXq|q|Wn|idƒo™|di%dƒp t&d|ddƒ|dwsj" )))))),  fG      R 4 ' B Ë ' <