Ñò Ã#xPc@sÖddkTddklZlZlZlZlZlZlZddk l Z ddkl Z ddkl Z ddk lZddklZddklZeiioIeiidjo6ydd kZeZWqôej o eZqôXned ƒZd efd„ƒYZdefd„ƒYZde fd„ƒYZ!de"fd„ƒYZ#de$fd„ƒYZ%de&fd„ƒYZ'ei(eƒei(eƒei(e'ƒei(e!ƒei(e#ƒei(e%ƒd S(iÿÿÿÿ(t*(tapitStrtPasswordt DefaultFromt_tngettexttObject(tEnum(tCommand(terrors(tipautil(tutil(tDNtlitetserverNs/ ID ranges Manage ID ranges used to map Posix IDs to SIDs and back. There are two type of ID ranges which are both handled by this utility: - the ID ranges of the local domain - the ID ranges of trusted remote domains Both types have the following attributes in common: - base-id: the first ID of the Posix ID range - range-size: the size of the range With those two attributes a range object can reserve the Posix IDs starting with base-id up to but not including base-id+range-size exclusively. Additionally an ID range of the local domain may set - rid-base: the first RID(*) of the corresponding RID range - secondary-rid-base: first RID of the secondary RID range and an ID range of a trusted domain must set - rid-base: the first RID of the corresponding RID range - dom_sid: domain SID of the trusted domain EXAMPLE: Add a new ID range for a trusted domain Since there might be more than one trusted domain the domain SID must be given while creating the ID range. ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=0 \ --dom-sid=S-1-5-21-123-456-789 trusted_dom_range This ID range is then used by the IPA server and the SSSD IPA provider to assign Posix UIDs to users from the trusted domain. If e.g a range for a trusted domain is configured with the following values: base-id = 1200000 range-size = 200000 rid-base = 0 the RIDs 0 to 199999 are mapped to the Posix ID from 1200000 to 13999999. So RID 1000 <-> Posix ID 1201000 EXAMPLE: Add a new ID range for the local domain To create an ID range for the local domain it is not necessary to specify a domain SID. But since it is possible that a user and a group can have the same value as Posix ID a second RID interval is needed to handle conflicts. ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=1000 \ --secondary-rid-base=1000000 local_range The data from the ID ranges of the local domain are used by the IPA server internally to assign SIDs to IPA users and groups. The SID will then be stored in the user or group objects. If e.g. the ID range for the local domain is configured with the values from the example above then a new user with the UID 1200007 will get the RID 1007. If this RID is already used by a group the RID will be 1000007. This can only happen if a user or a group object was created with a fixed ID because the automatic assignment will not assign the same ID twice. Since there are only users and groups sharing the same ID namespace it is sufficient to have only one fallback range to handle conflicts. To find the Posix ID for a given RID from the local domain it has to be checked first if the RID falls in the primary or secondary RID range and the rid-base or the secondary-rid-base has to be subtracted, respectively, and the base-id has to be added to get the Posix ID. Typically the creation of ID ranges happens behind the scenes and this CLI must not be used at all. The ID range for the local domain will be created during installation or upgrade from an older version. The ID range for a trusted domain will be created together with the trust by 'ipa trust-add ...'. The use cases for this CLI are USE CASES: Add an ID range from a transitively trusted domain If the trusted domain (A) trusts another domain (B) as well and this trust is transitive 'ipa trust-add domain-A' will only create a range for domain A. The ID range for domain B must be added manually. Add an additional ID range for the local domain If the ID range of the local domain is exhausted, i.e. no new IDs can be assigned to Posix users or groups by the DNA plugin, a new range has to be created to allow new users and groups to be added. (Currently there is no connection between this range CLI and the DNA plugin, but a future version might be able to modify the configuration of the DNS plugin as well) In general it is not necessary to modify or delete ID ranges. If there is no other way to achieve a certain configuration than to modify or delete an ID range it should be done with great care. Because UIDs are stored in the file system and are used for access control it might be possible that users are allowed to access files of other users if an ID range got deleted and reused for a different domain. (*) The RID is typically the last integer of a user or group SID which follows the domain SID. E.g. if the domain SID is S-1-5-21-123-456-789 and a user from this domain has the SID S-1-5-21-123-456-789-1010 then 1010 id the RID of the user. RIDs are unique in a domain, 32bit values and are used for users and groups. tidrangec Bs^eZdZd+ZeiiZdZdZ dgZ ddgZ d d d d d ddgZ e dƒZe dƒZed ddde dƒdeƒed ddde dƒƒed ddde dƒƒedddde dƒƒedddde d ƒƒed!dd"de d#ƒƒed$de d%ƒd&d'gƒfZed(„Zd)„Zd*„ZRS(,s Range object. tdomaintadtipatrangetrangest ipaIDrangetipadomainidrangetipatrustedaddomainrangetcnt ipabaseidtipaidrangesizet ipabaseridtipasecondarybaseridtipanttrusteddomainsidt iparangetypes ID RangessID Rangetcli_nametnametlabels Range namet primary_keytbase_idsFirst Posix ID of the ranget range_sizesNumber of IDs in the ranges ipabaserid?trid_bases(First RID of the corresponding RID rangesipasecondarybaserid?tsecondary_rid_bases$First RID of the secondary RID rangesipanttrusteddomainsid?tdom_sids Domain SID of the trusted domains iparangetype?s Range typetflagst no_optioncCs°|idtƒpSd|idgƒjottdƒƒg|d=%(low)d)(uidNumber<=%(high)d))tlowthighs,(&(gidNumber>=%(low)d)(gidNumber<=%(high)d))t|t&tfiltert attrs_listtuidRtbase_dnR!sipabaseid,ipaidrangesizeterrorsRrange modification leaving objects with ID out of the defined range is not allowed(R2tappendtmintmaxtbackendtdicttcombine_filterst find_entriesR Rtenvtcontainer_accountstbasednR tNotFoundtValidationErrorR(R3told_basetold_sizetnew_basetnew_sizet old_intervalt new_intervaltchecked_intervalstlow_difft high_difftldaptid_filter_baset id_filter_idstid_lowtid_hight id_filtertobjectst truncated((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pytcheck_ids_in_modified_rangeÎsT     * *       (cCs—tptidtdƒƒ‚ntii|iƒ}|iƒptidtdƒƒ‚n|i |ƒp"ti dddtdƒƒ‚ndS(NtreasonsŽCannot perform SID validation without Samba 4 support installed. Make sure you have installed server-trust-ad sub-package of IPA on the serversiCross-realm trusts are not configured. Make sure you have run ipa-adtrust-install on the IPA server firstR!s domain SIDR@s9SID is not recognized as a valid SID for a trusted domain( t_dcerpc_bindings_installedR RKRt ipaservertdcerpctDomainValidatorRt is_configuredtis_trusted_sid_validRL(R3tsidtdomain_validator((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pytvalidate_trusted_domain_sids (RRR(t__name__t __module__t__doc__t range_typeRRHtcontainer_rangest container_dnt object_nametobject_name_pluralt object_classtpossible_objectclassestdefault_attributesRR"tlabel_singularRtTruetIntt takes_paramsR/R7R^Rh(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR’sJ                      4t idrange_addcBs2eZedƒZedƒZd„Zd„ZRS(s` Add new ID range. To add a new ID range you always have to specify --base-id --range-size Additionally --rid-base --secondary-rid-base may be given for a new ID range for the local domain while --rid-bas --dom-sid must be given to add a new range for a trusted AD domain. sAdded ID range "%(value)s"cOsût|tƒpt‚d|jo‡d|jo"tidddtdƒƒ‚nd|jo"tidddtdƒƒ‚n|ii|dƒ|d id ƒnMd|jd|jjo"tidddtd ƒƒ‚n|d id ƒ|S( NRRR!sID Range setupR@s>Options dom_sid and secondary_rid_base cannot be used togetherRs2Options dom_sid and rid_base must be used togetherR,Rs=Options secondary_rid_base and rid_base must be used togetherR( t isinstanceR tAssertionErrorR RLRtobjRhRA(R3RVtdnR4R=tkeysR5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyt pre_callback&s   cOs4t|tƒpt‚|ii||dtƒ|S(NR6(RyR RzR{R7Ru(R3RVR|R4R}R5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyt post_callbackBs(RiRjRRkt msg_summaryR~R(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyRxs    t idrange_delcBs)eZedƒZedƒZd„ZRS(sDelete an ID range.sDeleted ID range "%(value)s"c Os¦y"|i|ddgƒ\}}Wn&tij o|ii|ŒnXt|iddgƒdƒ}t|iddgƒdƒ}|ii||ddƒ|S(NRRi(t get_entryR RKR{thandle_not_foundtintR.R^( R3RVR|R}R5told_dnt old_attrst old_base_idtold_range_size((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR~Ls" (RiRjRRkR€R~(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyRGs  t idrange_findcBs8eZedƒZedddƒZd„Zd„ZRS(sSearch for ranges.s%(count)d range matcheds%(count)d ranges matchedicOs4t|tƒpt‚|idƒ|||ifS(NR,(RyR RzRAtSCOPE_ONELEVEL(R3RVtfiltersR=R?tscopetargsR5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR~as cOs.x'|D]\}}|ii||ƒqW|S(N(R{R7(R3RVtentriesR]RR5R|tentry((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyRfs (RiRjRRkRR€R~R(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR‰Xs   t idrange_showcBs&eZedƒZd„Zd„ZRS(s"Display information about a range.cOs(t|tƒpt‚|idƒ|S(NR,(RyR RzRA(R3RVR|R=R}R5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR~ns cOs.t|tƒpt‚|ii||ƒ|S(N(RyR RzR{R7(R3RVR|R4R}R5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyRss(RiRjRRkR~R(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyRks  t idrange_modcBs2eZedƒZedƒZd„Zd„ZRS(sModify ID range.sModified ID range "%(value)s"c OsGt|tƒpt‚|idƒy"|i|ddgƒ\}}Wn&tij o|ii|ŒnXd|jo|ii |dƒnt |i ddgƒdƒ} t |i ddgƒdƒ} |i dƒ} | dj ot | ƒ} n|i dƒ} | dj ot | ƒ} n|ii | | | | ƒ|S(NR,RRRi(RyR RzRAR‚R RKR{RƒRhR„R.R2R^( R3RVR|R4R=R}R5R…R†R‡Rˆt new_base_idtnew_range_size((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR~}s& "    cOs.t|tƒpt‚|ii||ƒ|S(N(RyR RzR{R7(R3RVR|R4R}R5((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR—s(RiRjRRkR€R~R(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyR‘xs   (RR()tipalib.plugins.baseldaptipalibRRRRRRRtipalib.parametersRR R t ipapythonR R t ipapython.dnR RHt in_servertcontexttipaserver.dcerpcRaRuR`t ImportErrorR/Rkt LDAPObjectRt LDAPCreateRxt LDAPDeleteRt LDAPSearchR‰t LDAPRetrieveRt LDAPUpdateR‘tregister(((s:/usr/lib/python2.6/site-packages/ipalib/plugins/idrange.pyts6 4   l |9 $