o
    >h                     @   sX   d Z ddlmZmZ ddgZG dd dZG dd dZG dd	 d	ZG d
d dZdS )zM
L{twisted.python.fakepwd} provides a fake implementation of the L{pwd} API.
    )ListOptionalUserDatabaseShadowDatabasec                   @   sP   e Zd ZdZdededededededed	d
fddZd	efddZdd Zd
S )_UserRecordz
    L{_UserRecord} holds the user data for a single user in L{UserDatabase}.
    It corresponds to the C{passwd} structure from the L{pwd} module.
    See that module for attribute documentation.
    namepassworduidgidgecoshomeshellreturnNc                 C   s.   || _ || _|| _|| _|| _|| _|| _d S Npw_name	pw_passwdpw_uidpw_gidpw_gecospw_dirpw_shell)selfr   r   r	   r
   r   r   r    r   v/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/python/fakepwd.py__init__   s   

z_UserRecord.__init__c                 C      dS )N   r   r   r   r   r   __len__'      z_UserRecord.__len__c                 C   s$   | j | j| j| j| j| j| jf| S r   r   r   indexr   r   r   __getitem__*   s   z_UserRecord.__getitem__	__name__
__module____qualname____doc__strintr   r   r#   r   r   r   r   r      s*    	
r   c                   @   s   e Zd ZU dZee ed< dZeed< dZ	eed< dd	d
Z
						ddededee dee dedededdfddZdedefddZdedefddZdee fddZdS )r   z
    L{UserDatabase} holds a traditional POSIX user data in memory and makes it
    available via the same API as L{pwd}.

    @ivar _users: A C{list} of L{_UserRecord} instances holding all user data
        added to this database.
    _usersiu'  _lastUIDiN  _lastGIDr   Nc                 C   
   g | _ d S r   r+   r   r   r   r   r   C      
zUserDatabase.__init__r    /bin/shusernamer	   r
   r   r   r   c           	      C   s\   |du r| j }|  j d7  _ |du r| j}|  jd7  _t|||||||}| j| dS )a  
        Add a new user record to this database.

        @param username: The value for the C{pw_name} field of the user
            record to add.

        @param password: The value for the C{pw_passwd} field of the user
            record to add.

        @param uid: The value for the C{pw_uid} field of the user record to
            add.

        @param gid: The value for the C{pw_gid} field of the user record to
            add.

        @param gecos: The value for the C{pw_gecos} field of the user record
            to add.

        @param home: The value for the C{pw_dir} field of the user record to
            add.

        @param shell: The value for the C{pw_shell} field of the user record to
            add.
        N   )r,   r-   r   r+   append)	r   r3   r   r	   r
   r   r   r   newUserr   r   r   addUserF   s   "zUserDatabase.addUserc                 C   s$   | j D ]}|j|kr|  S qt )zH
        Return the user record corresponding to the given uid.
        )r+   r   KeyError)r   r	   entryr   r   r   getpwuidq   s
   

zUserDatabase.getpwuidr   c                 C   s@   t |tstdt| | jD ]}|j|kr|  S qt )zM
        Return the user record corresponding to the given username.
        z%getpwuam() argument must be str, not )
isinstancer)   	TypeErrortyper+   r   r8   )r   r   r9   r   r   r   getpwnamz   s   


zUserDatabase.getpwnamc                 C      | j S )z4
        Return a list of all user records.
        r/   r   r   r   r   getpwall      zUserDatabase.getpwallr   N)r   NNr1   r1   r2   )r%   r&   r'   r(   r   r   __annotations__r,   r*   r-   r   r)   r   r7   r:   r>   r@   r   r   r   r   r   6   s@   
 
	
+	c                   @   sX   e Zd ZdZdededededededed	ed
eddfddZdefddZdd ZdS )_ShadowRecordz
    L{_ShadowRecord} holds the shadow user data for a single user in
    L{ShadowDatabase}.  It corresponds to C{spwd.struct_spwd}.  See that class
    for attribute documentation.
    r3   r   
lastChangeminmaxwarninactexpireflagr   Nc
           
      C   s:   || _ || _|| _|| _|| _|| _|| _|| _|	| _d S r   	sp_namsp_pwd	sp_lstchgsp_minsp_maxsp_warnsp_inact	sp_expiresp_flag
r   r3   r   rE   rF   rG   rH   rI   rJ   rK   r   r   r   r      s   
z_ShadowRecord.__init__c                 C   r   )N	   r   r   r   r   r   r      r    z_ShadowRecord.__len__c              	   C   s,   | j | j| j| j| j| j| j| j| jf	| S r   rL   r!   r   r   r   r#      s   
z_ShadowRecord.__getitem__r$   r   r   r   r   rD      s2    	

rD   c                   @   st   e Zd ZU dZee ed< dddZdeded	e	d
e	de	de	de	de	de	ddfddZ
dedefddZdd ZdS )r   z
    L{ShadowDatabase} holds a shadow user database in memory and makes it
    available via the same API as C{spwd}.

    @ivar _users: A C{list} of L{_ShadowRecord} instances holding all user data
        added to this database.

    @since: 12.0
    r+   r   Nc                 C   r.   r   r/   r   r   r   r   r      r0   zShadowDatabase.__init__r3   r   rE   rF   rG   rH   rI   rJ   rK   c
           
      C   s$   | j t|||||||||		 dS )a  
        Add a new user record to this database.

        @param username: The value for the C{sp_nam} field of the user record to
            add.

        @param password: The value for the C{sp_pwd} field of the user record to
            add.

        @param lastChange: The value for the C{sp_lstchg} field of the user
            record to add.

        @param min: The value for the C{sp_min} field of the user record to add.

        @param max: The value for the C{sp_max} field of the user record to add.

        @param warn: The value for the C{sp_warn} field of the user record to
            add.

        @param inact: The value for the C{sp_inact} field of the user record to
            add.

        @param expire: The value for the C{sp_expire} field of the user record
            to add.

        @param flag: The value for the C{sp_flag} field of the user record to
            add.
        N)r+   r5   rD   rV   r   r   r   r7      s
   (zShadowDatabase.addUserc                 C   sB   t |tstdt| | jD ]}|j|kr|  S qt|)zT
        Return the shadow user record corresponding to the given username.
        z%getspnam() argument must be str, not )r;   r)   r<   r=   r+   rM   r8   )r   r3   r9   r   r   r   getspnam   s   


zShadowDatabase.getspnamc                 C   r?   )z;
        Return a list of all shadow user records.
        r/   r   r   r   r   getspall  rA   zShadowDatabase.getspallrB   )r%   r&   r'   r(   r   rD   rC   r   r)   r*   r7   rX   rY   r   r   r   r   r      s6   
 

	

.N)	r(   typingr   r   __all__r   r   rD   r   r   r   r   r   <module>   s   (V.