File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/solaris_shadow.cpython-310.pyc
Back
o ;j � @ s� d Z ddlZddlZddlmZ zddlZdZW n ey3 dZzddl Z W n ey0 Y nw Y nw zddl ZdZW n eyG dZY nw dZdd� Z d d � Zdd� Zd d� Zdd� Zddd�Zdd� Zdd� Zdd� ZdS )a4 Manage the password database on Solaris systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-override>`. � N)�CommandExecutionErrorTFZshadowc C s t �dd�dkr tS dS )z) Only work on POSIX-like systems Zkernel� �SunOS)FzVThe solaris_shadow execution module failed to load: only available on Solaris systems.)Z __grains__�get�__virtualname__� r r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/solaris_shadow.py�__virtual__) s r c C s dS )z� Returns the default hash used for unset passwords CLI Example: .. code-block:: bash salt '*' shadow.default_hash �!r r r r r �default_hash6 s r c C s� t r3zt�| �}|j|j|j|j|j|j|j |j d�}W |S ty2 ddddddddd�}Y |S w ddddddddd�}zt� | �}|�d| i� W n tyW | Y S w d}tj�|�sb|S tjj�|d��#}|D ]}|�� �d�}|d | kr�|�d|d i� qmW d � n1 s�w Y td d| � �d d�}|d dkr�|S |d �� }t|�dkr�|S |�|j|d t|d �t|d �t|d �ddd�� |S )z� Return information for the specified user CLI Example: .. code-block:: bash salt '*' shadow.info root )�name�passwd�lstchg�min�max�warn�inact�expirer r �/etc/shadow�r�:r r � Nzcmd.run_allz passwd -s F��python_shell�retcode�stdout� � � � )r r r r r r r )�HAS_SPWD�spwdZgetspnamZsp_namZsp_pwdZ sp_lstchgZsp_minZsp_maxZsp_warnZsp_inactZ sp_expire�KeyError�pwd�getpwnam�update�os�path�isfile�salt�utils�files�fopen�strip�split�__salt__�len�pw_name�int) r �data�ret�s_file�ifile�line�comps�output�fieldsr r r �infoC s� ��� �� ���� ��r; c C s` t | �}||d krdS d|� d| � �}td |dd� t | �}|d |d kr.|d |kS dS ) z� Set the maximum number of days during which a password is valid. See man passwd. CLI Example: .. code-block:: bash salt '*' shadow.set_maxdays username 90 r Tz passwd -x � �cmd.runFr N�r; r/ )r Zmaxdays�pre_info�cmd� post_infor r r �set_maxdays� s �rB c C �` t | �}||d krdS d|� d| � �}td |dd� t | �}|d |d kr.|d |kS dS )z� Set the minimum number of days between password changes. See man passwd. CLI Example: .. code-block:: bash salt '*' shadow.set_mindays username 7 r Tz passwd -n r<