OwlCyberSecurity - MANAGER
Edit File: cred_unix.pyc
� `��ac @` s d Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d � Z e e � d e f d � � Y� Z d Z e e e j � d e f d � � Y� Z e � Z d S( s% Cred plugin for UNIX user accounts. i ( t absolute_importt division( t implementer( t plugin( t ICheckerFactory( t ICredentialsChecker( t IUsernamePassword( t UnauthorizedLogin( t defer( t StringTypec C` s� y d d l } Wn t k r) d } n X| d k rE t d � � n t | t � sf | j d � } n t | t � s� | j d � } n | j | | � | k S( s� 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} i Ns( cred_unix not supported on this platforms utf-8( t cryptt ImportErrort Nonet NotImplementedErrort isinstanceR t decode( t cryptedt pwR ( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/plugins/cred_unix.pyt verifyCryptedPassword s t UNIXCheckerc B` s2 e Z d Z e f Z d � Z d � Z d � Z RS( s 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 C` s� y7 t | t � s$ | j d � } n | j | � j } Wn t k rW t j t � � SX| d k rh d St | | � r� t j | � Sd S( s3 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} s utf-8t *t xN( R R ( R R R t getpwnamt pw_passwdt KeyErrorR t failR R R t succeed( t selft pwdt usernamet passwordt cryptedPass( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/plugins/cred_unix.pyt checkPwdA s c C` s� ya t | t � s$ | j d � } n t | j d d � rN | j | � j } n | j | � j } Wn t k r� t j t � � SXt | | � r� t j | � Sd S( sC 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} s utf-8t sp_pwdpN( R R R t getattrt struct_spwdR t getspnamR! t sp_pwdR R R R R R ( R t spwdR R R ( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/plugins/cred_unix.pyt checkSpwd] s c C` s� | j | j } } y d d l } Wn t k r<