Ϫf?dZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZd ZeeGd d Zd Zee ej$Gd dZeZy)z% Cred plugin for UNIX user accounts. ) implementer)plugin)ICredentialsChecker)IUsernamePassword)UnauthorizedLogin)ICheckerFactory)deferc\ ddl}| tdt|tr|j d}t|tr|j d} |j||}t|tr|j d}||k(S#t$rd}YwxYw#t $rYywxYw)a Use L{crypt.crypt} to Verify that an unencrypted password matches the encrypted password. @param crypted: The encrypted password, obtained from the Unix password database or Unix shadow password database. @param pw: The unencrypted password. @return: L{True} if there is successful match, else L{False}. @rtype: L{bool} rNz(cred_unix not supported on this platformutf-8F)crypt ImportErrorNotImplementedError isinstancebytesdecodeOSError)cryptedpwr crypted_checks ;/usr/lib/python3/dist-packages/twisted/plugins/cred_unix.pyverifyCryptedPasswordrs }!"LMM"e YYw '5!..) B0 mU +)009M''  s#B7B BB B+*B+c(eZdZdZefZdZdZdZy) UNIXCheckera A credentials checker for a UNIX server. This will check that an authenticating username/password is a valid user on the system. Does not work on Windows. Right now this supports Python's pwd and spwd modules, if they are installed. It does not support PAM. c" t|tr|jd}|j|j}|dvryt ||rt j|Sy#t$r t jtcYSwxYw)a3 Obtain the encrypted password for C{username} from the Unix password database using L{pwd.getpwnam}, and see if it it matches it matches C{password}. @param pwd: Module which provides functions which access to the Unix password database. @type pwd: C{module} @param username: The user to look up in the Unix password database. @type username: L{unicode}/L{str} or L{bytes} @param password: The password to compare. @type username: L{unicode}/L{str} or L{bytes} r )*xN) rrrgetpwnam pw_passwdrr succeedKeyErrorfailr)selfpwdusernamepassword cryptedPasss rcheckPwdzUNIXChecker.checkPwdCs /(E*#??73,,x0::Kj(&{H=}}X..>  3::/12 2 3sG"zz+-..' C  D s"A2B2 B?B BBN) __name__ __module__ __qualname____doc__rcredentialInterfacesr'r/r3rrr5s!.//6/:/r:ra This checker will attempt to use every resource available to authenticate against the list of users on the local UNIX system. (This does not support Windows servers for very obvious reasons.) Right now, this includes support for: * Python's pwd module (which checks /etc/passwd) * Python's spwd module (which checks /etc/shadow) Future versions may include support for PAM authentication. c:eZdZdZdZeZdZejZ dZ y)UNIXCheckerFactoryz' A factory for L{UNIXChecker}. unixzNo argstring required.ctS)z This checker factory ignores the argument string. Everything needed to generate a user database is pulled out of the local UNIX environment. )r)r" argstrings rgenerateCheckerz"UNIXCheckerFactory.generateCheckers }r:N) r4r5r6r7authTypeunixCheckerFactoryHelpauthHelpargStringFormatrr8r@r9r:rr<r<s)H%H.O&;;r:r<N)r7zope.interfacertwistedrtwisted.cred.checkersrtwisted.cred.credentialsrtwisted.cred.errorrtwisted.cred.strcredrtwisted.internetr rrrBIPluginr<theUnixCheckerFactoryr9r:rrNs  '5600"@ !]/]/"]/@  _fnn-.&+,r: