File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/webutil.cpython-310.pyc
Back
o ;j� � @ sT d Z ddlZddlZddlZe�e�ZdZdd� Z ddd�Z dd d�Zddd �ZdS )a Support for htpasswd command. Requires the apache2-utils package for Debian-based distros. .. versionadded:: 2014.1.0 The functions here will load inside the webutil module. This allows other functions that don't use htpasswd to use the webutil module name. � NZwebutilc C s t jj�d�r tS dS )z7 Only load the module if htpasswd is installed �htpasswd)FzKThe htpasswd execution mdule cannot be loaded: htpasswd binary not in path.)�salt�utils�path�which�__virtualname__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/webutil.py�__virtual__ s r � c C s: t j�| �s |d7 }dd|� �| ||g}td ||dd�S )aU Add a user to htpasswd file using the htpasswd command. If the htpasswd file does not exist, it will be created. pwfile Path to htpasswd file user User name password User password opts Valid options that can be passed are: - `n` Don't update file; display results on stdout. - `m` Force MD5 encryption of the password (default). - `d` Force CRYPT encryption of the password. - `p` Do not encrypt the password (plaintext). - `s` Force SHA encryption of the password. runas The system user to run htpasswd command with CLI Examples: .. code-block:: bash salt '*' webutil.useradd /etc/httpd/htpasswd larry badpassword salt '*' webutil.useradd /etc/httpd/htpasswd larry badpass opts=ns �cr z-b�cmd.run_allF��runasZpython_shell)�osr �exists�__salt__)�pwfile�user�password�optsr �cmdr r r �useradd s !r Fc C sP t j�| �sdS dd| |g}|rtd ||dd�}|S td ||dd��� }|S )au Delete a user from the specified htpasswd file. pwfile Path to htpasswd file user User name runas The system user to run htpasswd command with all_results Return stdout, stderr, and retcode, not just stdout CLI Examples: .. code-block:: bash salt '*' webutil.userdel /etc/httpd/htpasswd larry z1Error: The specified htpasswd file does not existr z-Dr Fr zcmd.run)r r r r � splitlines)r r r Zall_resultsr �outr r r �userdelH s �r c C sP t j�| �sdS dd|� �| ||g}td ||dd�}t�d||� |d dkS ) a Return True if the htpasswd file exists, the user has an entry, and their password matches. pwfile Fully qualified path to htpasswd file user User name password User password opts Valid options that can be passed are: - `m` Force MD5 encryption of the password (default). - `d` Force CRYPT encryption of the password. - `p` Do not encrypt the password (plaintext). - `s` Force SHA encryption of the password. runas The system user to run htpasswd command with CLI Examples: .. code-block:: bash salt '*' webutil.verify /etc/httpd/htpasswd larry maybepassword salt '*' webutil.verify /etc/httpd/htpasswd larry maybepassword opts=ns Fr z-bvr r z,Result of verifying htpasswd for user %s: %s�retcoder )r r r r �log�debug)r r r r r r �retr r r �verifyk s r )r N)NF) �__doc__�loggingr Zsalt.utils.pathr � getLogger�__name__r r r r r r r r r r �<module> s (#
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings