%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/plugins/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/plugins/__pycache__/cred_unix.cpython-312.pyc

�

Ϫ�f?����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZd	�Zee�Gd
�d��ZdZeeej$�Gd
�d��Ze�Zy)z%
Cred plugin for UNIX user accounts.
�)�implementer)�plugin)�ICredentialsChecker)�IUsernamePassword)�UnauthorizedLogin)�ICheckerFactory)�deferc�\�	ddl}|�td��t|t�r|jd�}t|t�r|jd�}	|j||�}t|t�r|jd�}||k(S#t$rd}Y��wxYw#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 platform�utf-8F)�crypt�ImportError�NotImplementedError�
isinstance�bytes�decode�OSError)�crypted�pwr�
crypted_checks    �;/usr/lib/python3/dist-packages/twisted/plugins/cred_unix.py�verifyCryptedPasswordrs�����
�}�!�"L�M�M��"�e��
�Y�Y�w�
���'�5�!��.�.��)������B��0�
��m�U�+�)�0�0��9�M���'�'������������s#�B�7B�B�B�	B+�*B+c�(�eZdZdZefZd�Zd�Zd�Zy)�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|t�r|jd�}|j|�j}|dvryt||�rt
j|�Sy#t$r t
jt��cYSwxYw)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�getpwnam�	pw_passwdrr	�succeed�KeyError�failr)�self�pwd�username�password�cryptedPasss     r�checkPwdzUNIXChecker.checkPwdCs���	/��(�E�*�#�?�?�7�3���,�,�x�0�:�:�K��j�(��&�{�H�=��}�}�X�.�.�>��
�	3��:�:�/�1�2�2�	3�s�<A%�%&B�
Bc�~�	t|t�r|jd�}t|jdd�r|j|�j}n|j|�j}t||�rtj|�Sy#t$r tjt��cYSwxYw)aE
        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 spwd: 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�getattr�struct_spwd�getspnamr)�sp_pwdrr	rr r!r)r"�spwdr$r%r&s     r�	checkSpwdzUNIXChecker.checkSpwd^s���
	/��(�E�*�#�?�?�7�3���t�'�'��D�9�"�m�m�H�5�=�=��#�m�m�H�5�<�<��%�[�(�;��}�}�X�.�.�<���	3��:�:�/�1�2�2�	3�s�A/B�&B<�;B<c�(�|j|j}}	ddl}|�|j	|||�}|�|S	ddl}|�|j
|||�}|�|Stjt��S#t$rd}Y�awxYw#t$rd}Y�TwxYw)Nr)
r$r%r#r
r'r.r/r	r!r)r"�credentialsr$r%r#�checkedr.s       r�requestAvatarIdzUNIXChecker.requestAvatarId{s���(�1�1�;�3G�3G�(��	���?��m�m�C��8�<�G��"���	�����n�n�T�8�X�>�G��"����z�z�+�-�.�.��'�	��C�	���	��D�	�s"�A2�B�2B�?B�B�BN)	�__name__�
__module__�__qualname__�__doc__r�credentialInterfacesr'r/r3��rrr5s!���.�/��/�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	d�Z
y)�UNIXCheckerFactoryz'
    A factory for L{UNIXChecker}.
    �unixzNo argstring required.c��t�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)r"�	argstrings  r�generateCheckerz"UNIXCheckerFactory.generateChecker�s���}�r:N)r4r5r6r7�authType�unixCheckerFactoryHelp�authHelp�argStringFormatrr8r@r9r:rr<r<�s)����H�%�H�.�O�&�;�;��r:r<N)r7�zope.interfacer�twistedr�twisted.cred.checkersr�twisted.cred.credentialsr�twisted.cred.errorr�twisted.cred.strcredr�twisted.internetr	rrrB�IPluginr<�theUnixCheckerFactoryr9r:r�<module>rNs����
'��5�6�0�0�"��@
�
 �!�]/�]/�"�]/�@��
�_�f�n�n�-���.��&+�,�r:

Zerion Mini Shell 1.0