Support for htpasswd command. Requires the apache2-utils package for Debian-based distros.
New in version 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.
Add a user to htpasswd file using the htpasswd command. If the htpasswd file does not exist, it will be created.
Path to htpasswd file
User name
User password
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.
The system user to run htpasswd command with
CLI Examples:
salt '*' webutil.useradd /etc/httpd/htpasswd larry badpassword
salt '*' webutil.useradd /etc/httpd/htpasswd larry badpass opts=ns
Delete a user from the specified htpasswd file.
Path to htpasswd file
User name
The system user to run htpasswd command with
Return stdout, stderr, and retcode, not just stdout
CLI Examples:
salt '*' webutil.userdel /etc/httpd/htpasswd larry
Return True if the htpasswd file exists, the user has an entry, and their password matches.
Fully qualified path to htpasswd file
User name
User password
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.
The system user to run htpasswd command with
CLI Examples:
salt '*' webutil.verify /etc/httpd/htpasswd larry maybepassword
salt '*' webutil.verify /etc/httpd/htpasswd larry maybepassword opts=ns