ϪfpdZddlmZmZddgZGddZGddZGdd ZGd dZy ) zM L{twisted.python.fakepwd} provides a fake implementation of the L{pwd} API. )ListOptional UserDatabaseShadowDatabasecJeZdZdZdededededededed d fd Zd efd Zd Zy ) _UserRecordz L{_UserRecord} holds the user data for a single user in L{UserDatabase}. It corresponds to the C{passwd} structure from the L{pwd} module. See that module for attribute documentation. namepassworduidgidgecoshomeshellreturnNcf||_||_||_||_||_||_||_yNpw_name pw_passwdpw_uidpw_gidpw_gecospw_dirpw_shell)selfr r r r r rrs 8/usr/lib/python3/dist-packages/twisted/python/fakepwd.py__init__z_UserRecord.__init__s5 !     cy)Nrs r__len__z_UserRecord.__len__'rc|j|j|j|j|j|j |j f|Srrrindexs r __getitem__z_UserRecord.__getitem__*sG LL NN KK KK MM KK MM   r __name__ __module__ __qualname____doc__strintrr#r(r!rrrrsk       $ rrceZdZUdZeeed<dZeed<dZ eed<dd Z dd e d e d e ed e ede de de ddfdZ d edefdZde defdZdeefdZy)rz L{UserDatabase} holds a traditional POSIX user data in memory and makes it available via the same API as L{pwd}. @ivar _users: A C{list} of L{_UserRecord} instances holding all user data added to this database. _usersiu'_lastUIDiN_lastGIDrNcg|_yrr1r"s rrzUserDatabase.__init__C  rr usernamer r r rrc |!|j}|xjdz c_|!|j}|xjdz c_t|||||||}|jj |y)a Add a new user record to this database. @param username: The value for the C{pw_name} field of the user record to add. @param password: The value for the C{pw_passwd} field of the user record to add. @param uid: The value for the C{pw_uid} field of the user record to add. @param gid: The value for the C{pw_gid} field of the user record to add. @param gecos: The value for the C{pw_gecos} field of the user record to add. @param home: The value for the C{pw_dir} field of the user record to add. @param shell: The value for the C{pw_shell} field of the user record to add. N)r2r3rr1append) rr7r r r r rrnewUsers raddUserzUserDatabase.addUserFseD ;--C MMQ M ;--C MMQ Mh#sE4O 7#rc^|jD]}|j|k(s|cSt)zH Return the user record corresponding to the given uid. )r1rKeyError)rr entrys rgetpwuidzUserDatabase.getpwuidqs2[[ E||s"  jrr ct|tstdt||jD]}|j |k(s|cSt )zM Return the user record corresponding to the given username. z%getpwuam() argument must be str, not ) isinstancer. TypeErrortyper1rr>)rr r?s rgetpwnamzUserDatabase.getpwnamzsS$$CDJ<PQ Q[[ E}}$  jrc|jS)z4 Return a list of all user records. r5r"s rgetpwallzUserDatabase.getpwall{{rrN)r NNrJz/bin/sh)r*r+r,r-rr__annotations__r2r/r3rr.rr<r@rErGr!rrrr6s  HcHc #!!)$)$)$c] )$ c] )$  )$)$)$ )$VCK S [ ${+rcReZdZdZdededededededed ed ed d fd Zd efdZdZy ) _ShadowRecordz L{_ShadowRecord} holds the shadow user data for a single user in L{ShadowDatabase}. It corresponds to C{spwd.struct_spwd}. See that class for attribute documentation. r7r lastChangeminmaxwarninactexpireflagrNc ||_||_||_||_||_||_||_||_| |_yr sp_namsp_pwd sp_lstchgsp_minsp_maxsp_warnsp_inact sp_expiresp_flag rr7r rNrOrPrQrRrSrTs rrz_ShadowRecord.__init__sC  #     rcy)N r!r"s rr#z_ShadowRecord.__len__r$rc |j|j|j|j|j|j |j |j|jf |SrrVr&s rr(z_ShadowRecord.__getitem__sU KK KK NN KK KK LL MM NN LL     rr)r!rrrMrMs       , rrMcpeZdZUdZeeed<ddZdedede d e d e d e d e d e de ddfdZ dedefdZ dZ y)rz L{ShadowDatabase} holds a shadow user database in memory and makes it available via the same API as C{spwd}. @ivar _users: A C{list} of L{_ShadowRecord} instances holding all user data added to this database. @since: 12.0 r1rNcg|_yrr5r"s rrzShadowDatabase.__init__r6rr7r rNrOrPrQrRrSrTc \|jjt||||||||| y)a Add a new user record to this database. @param username: The value for the C{sp_nam} field of the user record to add. @param password: The value for the C{sp_pwd} field of the user record to add. @param lastChange: The value for the C{sp_lstchg} field of the user record to add. @param min: The value for the C{sp_min} field of the user record to add. @param max: The value for the C{sp_max} field of the user record to add. @param warn: The value for the C{sp_warn} field of the user record to add. @param inact: The value for the C{sp_inact} field of the user record to add. @param expire: The value for the C{sp_expire} field of the user record to add. @param flag: The value for the C{sp_flag} field of the user record to add. N)r1r:rMr`s rr<zShadowDatabase.addUsers2P  (JS$vt  rct|tstdt||jD]}|j |k(s|cSt |)zT Return the shadow user record corresponding to the given username. z%getspnam() argument must be str, not )rBr.rCrDr1rWr>)rr7r?s rgetspnamzShadowDatabase.getspnamsW(C(CDNCSTU U[[ E||x'  x  rc|jS)z; Return a list of all shadow user records. r5r"s rgetspallzShadowDatabase.getspallrHrrI) r*r+r,r-rrMrKrr.r/r<rhrjr!rrrrs  , , ,  ,  ,  , , , , ,  , \ ! ! !rN) r-typingrr__all__rrrMrr!rrrmsI " + ,%%PSSl++\MMr