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/states/__pycache__/webutil.cpython-310.pyc
o

�N�gc�@s<dZddlZdZdd�Z						ddd	�Zd
d
d�ZdS)a+
Support for htpasswd module. Requires the apache2-utils package for Debian-based distros.

.. versionadded:: 2014.7.0

.. code-block:: yaml

    username:
      webutil.user_exists:
        - password: secr3t
        - htpasswd_file: /etc/nginx/htpasswd
        - options: d
        - force: true

�NZwebutilcCstjj�d�r	tSdS)z#
    depends on webutil module
    Zhtpasswd)FzCommand not found: htpasswd)�salt�utils�path�which�__virtualname__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/webutil.py�__virtual__sr	�FcCs,|iddd�}td|�rtd|d|�d��dd	k}nd
}d
}	|r3|r3|s3td|||||d�}	|r9|	s9|rtd
rPd|d<d�|�|d<|di|d<|Std|||||d�}
|
dd	krsd|d<|
d|d<|di|d<|Sd
|d<|
d|d<|Std
r�|dr�d|d<nd|d<d|d<|S)a
    Make sure the user is inside the specified htpasswd file

    name
        User name

    password
        User password

    htpasswd_file
        Path to the htpasswd file

    options
        See :mod:`salt.modules.htpasswd.useradd`

    force
        Touch the file even if user already created

    runas
        The system user to run htpasswd command with

    update
        Update an existing user's password if it's different from what's in
        the htpasswd file (unlike force, which updates regardless)

    r
N��name�changes�comment�resultzfile.file_exists�	file.grep�^�:�retcoderFzwebutil.verify)�opts�runas�testrz-User '{}' is set to be added to htpasswd filerTr
zwebutil.useradd�stderrzUser already known�Z__salt__Z__opts__�format)r�password�
htpasswd_file�options�forcer�update�ret�existsZpassword_changedZuseradd_retrrr�user_existssB# 
��
�
r!cCs�|iddd�}td|d|�d��ddk}|s+td	r!d|d
<nd|d
<d|d
<|Std	rBd|d
<d�|�|d
<|di|d<|Std|||dd�}|ddk|d
<|d|d
<|d
rd|di|d<|S)z�
    Make sure the user is not in the specified htpasswd file

    name
        User name

    htpasswd_file
        Path to the htpasswd file

    runas
        The system user to run htpasswd command with

    r
NrrrrrrrrTzUser already not in filerz1User '{}' is set to be removed from htpasswd filer
zwebutil.userdel)rZall_resultsrr)rrrrr Zuserdel_retrrr�user_absentos.
����r")NNr
FNF)NN)�__doc__Zsalt.utils.pathrrr	r!r"rrrr�<module>s
�P