Viewing File: /opt/alt/python38/lib/python3.8/site-packages/__pycache__/pam.cpython-38.pyc

U

$[@sdZdgZdZdZdZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZmZmZmZdd	lmZdd
lmZGddde	ZGd
dde	ZGddde	Ze
eeeeeeeeeZGddde	ZdZdZdZdZdZeedZ eedZ!e j"Z"ee"_#eege"_$e%e!dr:e!j&Z&ee&_#eege&_$e!j'Z'ee'_#eeeeeege'_$e!j(Z(ee(_#eege(_$e!j)Z)ee)_#eege)_$e!j*Z*ee*_#eege*_$GdddZ+ddZ,e-dkrddl.Z.ddl/Z/ddZ0e+Z+e0d e/1Z2e+,e2e//e3d!4e+j5e+j6dS)"z
PAM module for python

Provides an authenticate function that will allow the caller to authenticate
a user against the Pluggable Authentication Modules (PAM) on the system.

Implemented using ctypes, so no compilation is necessary.
pamz1.8.4z David Ford <david@blue-labs.org>z2018 June 15N)CDLLPOINTER	Structure	CFUNCTYPEcastbyrefsizeof)c_void_pc_size_tc_char_pc_charc_int)memmove)find_libraryc@s"eZdZdZdefgZddZdS)	PamHandlez&wrapper class for pam_handle_t pointerhandlecCst|d|_dS)Nr)r__init__rselfr/pam.pyr's
zPamHandle.__init__N)__name__
__module____qualname____doc__r
_fields_rrrrrr#s
rc@s(eZdZdZdefdefgZddZdS)
PamMessagez'wrapper class for pam_message structure	msg_stylemsgcCsd|j|jfS)Nz<PamMessage %i '%s'>)rrrrrr__repr__/szPamMessage.__repr__N)rrrrrrrr rrrrr+src@s(eZdZdZdefdefgZddZdS)PamResponsez(wrapper class for pam_response structurerespresp_retcodecCsd|j|jfS)Nz<PamResponse %i '%s'>)r#r"rrrrr 6szPamResponse.__repr__N)rrrrrrrr rrrrr!2sr!c@s eZdZdZdefdefgZdS)PamConvz$wrapper class for pam_conv structureconvZappdata_ptrN)rrrr	conv_funcr
rrrrrr$;sr$cpam_endc@s&eZdZdZdZddZd
dd	ZdS)rrNcCsdSNrrrrrrgszpam.__init__loginutf-8Tcsttfdd}tjdkrZt|tr0||}ttrD|t|tr||}n<t|trn||}ttr|t|tr||}d|ksdksd|krd|_d|_dSt	t
}t|d}t||t
|t
|}	|	dkr|	|_d	|_dSt|d}	|	dk}
|
r.|r.t|t}	|	|_t||	|_tjdkrZ|j||_ttd
rpt||	|
S)ausername and password authentication for the given service.

           Returns True for success, or False for failure.

           self.code (integer) and self.reason (string) are always stored and may
           be referenced for the reason why authentication failed. 0/'Success' will
           be stored for success.

           Python3 expects bytes() for ctypes inputs.  This function will make
           necessary conversions using the supplied encoding.

        Inputs:
          username: username to authenticate
          password: password in plain text
          service:  PAM service to authenticate against, defaults to 'login'

        Returns:
          success:  True
          failure:  False
        cst|tt}t|tt}||d<t|D]N}||jjtkr,tt	dtt
}t|t	|||_d||_
q,dS)zxSimple conversation function that responds to any
               prompt where the echo is off with the supplied passwordrr')callocr	r!rrrangecontentsrPAM_PROMPT_ECHO_OFFlenr
rr"r#)Z
n_messagesZmessagesZ
p_responseZapp_dataZaddrZresponseiZdstZ	cpasswordpasswordrrmy_convs
z!pam.authenticate.<locals>.my_convr)r*zstrings may not contain NULFrzpam_start() failedr-)r&sysversion_info
isinstancestrencodeZunicodecodereasonrrr$	pam_startrpam_authenticatepam_setcredPAM_REINITIALIZE_CREDpam_strerrordecodehasattrlibpamr-)rusernamer8ZserviceencodingZ
resetcredsr9rr%ZretvalZauth_successrr7rauthenticatejsL
















zpam.authenticate)r/r0T)rrrrArBrrMrrrrrcscOstj||S)zB
    Compatibility function for older versions of python-pam.
    )rrM)ZvargsZdargsrrrrMsrM__main__cs>fdd}t|tjdkr*t|}nt|}t|S)NcsttdSr.)readlineZinsert_textZ	redisplayrtextrrhooks
z input_with_prefill.<locals>.hookr:)rOZset_pre_input_hookr<r=inputZ	raw_input)promptrQrRresultrrPrinput_with_prefills


rVz
Username: z{} {})7r__all____version__
__author__Z__released__r<Zctypesrrrrrrr	r
rrr
rrZctypes.utilrrrr!r&r$r4ZPAM_PROMPT_ECHO_ONZ
PAM_ERROR_MSGZ
PAM_TEXT_INFOrFZlibcrJr1ZrestypeZargtypesrIr-rCrErGrDrrMrrOZgetpassrVZgetuserrKprintformatrArBrrrr<module>sb	$ 




_

Back to Directory File Manager