salt icon indicating copy to clipboard operation
salt copied to clipboard

webutils.user_exits does not enforce password updates

Open paul-mulvihill opened this issue 10 years ago • 3 comments

Description of Issue/Question

The webutils user_exists feature doesn't appear to enforce the password for a htpasswd user. It will ensure it exists but will not update the password if the source password value changes. If i use the force=True option it changes the file every run which is also not desirable.. As this will report changes when there shouldn't be any.

Setup

SLS file: {% for user, pass in salt.pillar.get('web:users').iteritems() %} {{ user }}: webutil.user_exists: - password: {{ pass }} - htpasswd_file: /etc/st2/htpasswd - options: d

{% endfor %}

Pillar: users: st2admin: test st2user: vegetable

Steps to Reproduce Issue

Use the webutils.user_exists feature to add a users to a htpasswd file. Change the password and then re run state file. The password is not checked/revalidate/enforced to the best i can see

Versions Report

Master: Salt Version: Salt: 2015.8.8.2

Dependency Versions: Jinja2: unknown M2Crypto: Not Installed Mako: Not Installed PyYAML: 3.11 PyZMQ: 14.5.0 Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) RAET: Not Installed Tornado: 4.2.1 ZMQ: 4.0.5 cffi: Not Installed cherrypy: Not Installed dateutil: Not Installed gitdb: 0.5.4 gitpython: 0.3.2 RC1 ioflo: Not Installed libgit2: Not Installed libnacl: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.6 mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed python-gnupg: Not Installed smmap: 0.8.1 timelib: Not Installed

System Versions: dist: centos 6.7 Final machine: x86_64 release: 2.6.32-573.12.1.el6.x86_64 system: CentOS 6.7 Final

minion: [root@salt Debian]# salt 'INS-4132' test.version INS-4132: 2016.3.1 Ubuntu 14.04

paul-mulvihill avatar Aug 15 '16 12:08 paul-mulvihill

@paul-mulvihill looks like you are correct. Glancing at the code here It just checks to see if the user already exists in the htpasswd file. If user exists then it does not update the information.

Ch3LL avatar Aug 16 '16 17:08 Ch3LL

@paul-mulvihill @Ch3LL I think if you apply force: True the htpasswd file will be updated even if the user already exists, as you can see from the explanation:

    force
        Touch the file even if user already created

So, I guess the behavior that @paul-mulvihill experienced is by design. For more details, you can check here

hu-dabao avatar Aug 19 '16 04:08 hu-dabao

Hi @hu-dabao Yeah i'm aware of the force option, i mention it in my original post. My concern with using that is that it will apply a change EVERY run rather than when it is needed. If i have the highstate applying on a scheduled and the logs being passed into my logging infrastructure it will be reporting changes being applied when there is no need for them to be. Which makes any reporting inaccurate. I'm after finding out if this is the intended end design for this state/module functionality. if not are there plans to make it so passwords can be managed/maintained without forcing a change every run. if this is the intended end design of the feature I may need to review how I use it to manage the htpaswd file. I don't want salt to apply a change if there isn't one required as it will skew any reporting I have to report drift.

paul-mulvihill avatar Aug 19 '16 07:08 paul-mulvihill