HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/webutil.cpython-310.pyc
o

�N�g��@sTdZddlZddlZddlZe�e�ZdZdd�Z	ddd�Z
dd
d�Zddd
�ZdS)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.
�NZwebutilcCstjj�d�r	tSdS)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__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/webutil.py�__virtual__sr
�cCs:tj�|�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
    �crz-b�cmd.run_allF��runasZpython_shell)�osr�exists�__salt__)�pwfile�user�password�optsr�cmdrrr	�useradd s!rFcCsPtj�|�sdSdd||g}|rtd||dd�}|Std||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 existrz-Dr
Frzcmd.run)rrrr�
splitlines)rrrZall_resultsr�outrrr	�userdelHs�rcCsPtj�|�sdSdd|��|||g}td||dd�}t�d||�|ddkS)	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
    Frz-bvr
rz,Result of verifying htpasswd for user %s: %s�retcoder)rrrr�log�debug)rrrrrr�retrrr	�verifyks r )rN)NF)
�__doc__�loggingrZsalt.utils.pathr�	getLogger�__name__rrr
rrr rrrr	�<module>s	


(#