Ñò
cù¥Oc        
   @   s  d  Z  d g Z d d k l Z l Z l Z l Z l Z l Z l	 Z	 d d k l
 Z
 l Z l Z l Z l Z d d k l Z e e d ƒ ƒ Z e e d ƒ ƒ Z e i Z e
 e _ e e g e _ e i Z e g e _ e e ƒ e _ d Z d	 Z d
 Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ  e e e e e e ƒ ƒ e e e  ƒ ƒ e
 ƒ Z! d e f d „  ƒ  YZ" e i# Z$ e e$ _ e e e e" ƒ e e ƒ g e$ _ e i% Z& e e& _ e e g e& _ d d „ Z' e( d j o* d d k) Z) e' e) i* ƒ  e) i) ƒ  ƒ GHn d S(   sé   
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.
t   authenticateiÿÿÿÿ(   t   CDLLt   POINTERt	   Structuret	   CFUNCTYPEt   castt   pointert   sizeof(   t   c_void_pt   c_uintt   c_char_pt   c_chart   c_int(   t   find_libraryt   pamt   ci   i   i   i   t	   PamHandlec           B   s&   e  Z d  Z d e f g Z d „  Z RS(   s   wrapper class for pam_handle_tt   handlec         C   s   t  i |  ƒ d |  _ d  S(   Ni    (   R   t   __init__R   (   t   self(    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   )   s    (   t   __name__t
   __module__t   __doc__R   t   _fields_R   (    (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   #   s   t
   PamMessagec           B   s/   e  Z d  Z d e f d e f g Z d „  Z RS(   s'   wrapper class for pam_message structuret	   msg_stylet   msgc         C   s   d |  i  |  i f S(   Ns   <PamMessage %i '%s'>(   R   R   (   R   (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyt   __repr__4   s    (   R   R   R   R   R
   R   R   (    (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   -   s   	t   PamResponsec           B   s/   e  Z d  Z d e f d e f g Z d „  Z RS(   s(   wrapper class for pam_response structuret   respt   resp_retcodec         C   s   d |  i  |  i f S(   Ns   <PamResponse %i '%s'>(   R   R   (   R   (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   >   s    (   R   R   R   R
   R   R   R   (    (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   7   s   	t   PamConvc           B   s&   e  Z d  Z d e f d e f g Z RS(   s$   wrapper class for pam_conv structuret   convt   appdata_ptr(   R   R   R   t	   CONV_FUNCR   R   (    (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR   E   s   	t   loginc            sy   t  ‡  f d †  ƒ } t ƒ  } t | d ƒ } t | |  t | ƒ t | ƒ ƒ } | d j o t St | d ƒ } | d j S(   s:  Returns True if the given username and password authenticate for the
    given service.  Returns False otherwise
    
    ``username``: the username to authenticate
    
    ``password``: the password in plain text
    
    ``service``: the PAM service to authenticate against.
                 Defaults to 'login'c            sŸ   t  |  t t ƒ ƒ } t | t t ƒ ƒ | d <xj t |  ƒ D]\ } | | i i t j o? t	 t
 ˆ  ƒ ƒ } t | t ƒ | i | _ d | i | _ q; q; Wd S(   sq   Simple conversation function that responds to any
        prompt where the echo is off with the supplied passwordi    (   t   CALLOCR   R   R   R   t   ranget   contentsR   t   PAM_PROMPT_ECHO_OFFt   STRDUPt   strR
   R   R   (   t
   n_messagest   messagest
   p_responset   app_datat   addrt   it   pw_copy(   t   password(    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyt   my_conv_   s     i    (   R"   R   R   t	   PAM_STARTR   t   Falset   PAM_AUTHENTICATE(   t   usernameR1   t   serviceR2   R   R    t   retval(    (   R1   s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyR    U   s    
	!t   __main__N(+   R   t   __all__t   ctypesR   R   R   R   R   R   R   R   R	   R
   R   R   t   ctypes.utilR   t   LIBPAMt   LIBCt   callocR$   t   restypet   argtypest   strdupR(   t	   argstypesR'   t   PAM_PROMPT_ECHO_ONt   PAM_ERROR_MSGt   PAM_TEXT_INFOR   R   R   R"   R   t	   pam_startR3   t   pam_authenticateR5   R    R   t   getpasst   getuser(    (    (    s`   /afs/sipb.mit.edu/project/zmobile/testing/lib/python2.6/site-packages/pam-0.1.3-py2.6.egg/pam.pyt   <module>   sD   	4(			


				$