File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/bsd_shadow.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlZddlmZmZ zddlZW n ey! Y nw zddl ZdZ W n ey5 dZ Y nw dZdd� Zd d � Z ddd �Zdd� Zdd� Zdd� Zdd� Zdd� ZdS )a0 Manage the password database on BSD 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)�CommandExecutionError�SaltInvocationErrorTFZshadowc C s dt �dd�v r tS dS )NZBSD�os� )FzWThe bsd_shadow execution module cannot be loaded: only available on BSD family systems.)� __grains__�get�__virtualname__� r r �K/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/bsd_shadow.py�__virtual__ s r c C s t d �� dkr dS dS )z� Returns the default hash used for unset passwords CLI Example: .. code-block:: bash salt '*' shadow.default_hash r Zfreebsd�*z *************)r �lowerr r r r �default_hash) s r �sha512c C s t std��tjj�|| |�S )a8 Generate hashed password .. note:: When called this function is called directly via remote-execution, the password argument may be displayed in the system's process list. This may be a security risk on certain systems. password Plaintext password to be hashed. crypt_salt Crpytographic salt. If not given, a random 8-character salt will be generated. algorithm The following hash algorithms are supported: * md5 * blowfish (not in mainline glibc, only available in distros that add it) * sha256 * sha512 (default) CLI Example: .. code-block:: bash salt '*' shadow.gen_password 'I_am_password' salt '*' shadow.gen_password 'I_am_password' crypt_salt='I_am_salt' algorithm=sha256 zjgen_password is not available on this operating system because the "crypt" python module is not available.)� HAS_CRYPTr �salt�utilsZpycryptoZgen_hash)�passwordZ crypt_salt� algorithmr r r �gen_password6 s �r c C s� zt �| �}|j|jd�}W n ty ddd� Y S w t| t�s&t| �} d| v r2td| � d���td d�rNtd dd d | gdd�� d�d d� \}}n]t d dv r�zEtjj �dd��3}|D ](}tjj�|�}|�| � d��r�|� d�}|d d� \}}t|d �|d<