HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/plugins/__pycache__/cred_unix.cpython-38.pyc
U


W[�@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZdd�Zee�Gd
d�de��ZdZee	ej�Gdd�de��Ze�ZdS)z%
Cred plugin for UNIX user accounts.
�)�absolute_import�division)�implementer)�plugin)�ICheckerFactory)�ICredentialsChecker)�IUsernamePassword)�UnauthorizedLogin)�defer)�
StringTypecCsnzddl}Wntk
r$d}YnX|dkr6td��t|t�sJ|�d�}t|t�s^|�d�}|�||�|kS)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 platform�utf-8)�crypt�ImportError�NotImplementedError�
isinstancer�decode)ZcryptedZpwr
�r�;/usr/lib/python3/dist-packages/twisted/plugins/cred_unix.py�verifyCryptedPasswords




rc@s.eZdZdZefZdd�Zdd�Zdd�ZdS)	�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.
    cCsjz$t|t�s|�d�}|�|�j}Wn tk
rDt�t��YSX|dkrRdSt	||�rft�
|�SdS)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)rrr�getpwnamZ	pw_passwd�KeyErrorr
�failr	r�succeed)�self�pwd�username�password�cryptedPassrrr�checkPwdAs


zUNIXChecker.checkPwdcCszz@t|t�s|�d�}t|jdd�r2|�|�j}n|�|�j}Wn tk
r`t	�
t��YSXt||�rvt	�
|�SdS)aC
        Obtain the encrypted password for C{username} from the
        Unix shadow password database using L{spwd.getspnam},
        and see if it it matches it matches C{password}.

        @param spwd: Module which provides functions which
                    access to the Unix shadow 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�sp_pwdpN)rrr�getattrZstruct_spwdZgetspnamr"Zsp_pwdrr
rr	rr)r�spwdrrr rrr�	checkSpwd]s


zUNIXChecker.checkSpwdcCs�|j|j}}zddl}Wntk
r2d}YnX|dk	rV|�|||�}|dk	rV|Szddl}Wntk
rzd}YnX|dk	r�|�|||�}|dk	r�|St�t	��S)Nr)
rrrrr!r$r%r
rr	)rZcredentialsrrr�checkedr$rrr�requestAvatarId{s$

zUNIXChecker.requestAvatarIdN)	�__name__�
__module__�__qualname__�__doc__r�credentialInterfacesr!r%r'rrrrr3s
	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@s*eZdZdZdZeZdZej	Z	dd�Z
dS)�UNIXCheckerFactoryz'
    A factory for L{UNIXChecker}.
    ZunixzNo argstring required.cCst�S)z�
        This checker factory ignores the argument string. Everything
        needed to generate a user database is pulled out of the local
        UNIX environment.
        )r)rZ	argstringrrr�generateChecker�sz"UNIXCheckerFactory.generateCheckerN)r(r)r*r+ZauthType�unixCheckerFactoryHelpZauthHelpZargStringFormatrr,r.rrrrr-�sr-N)r+Z
__future__rrZzope.interfacerZtwistedrZtwisted.cred.strcredrZtwisted.cred.checkersrZtwisted.cred.credentialsrZtwisted.cred.errorr	Ztwisted.internetr
Ztwisted.python.compatrr�objectrr/ZIPluginr-ZtheUnixCheckerFactoryrrrr�<module>s c