[Needs Port to Master] Windows user password not changed by states.user.present
Description of Issue/Question
Setup
As part of deploying a lab domain environment, I want to change the local admin password according to a pillar:
fix_admin_pw:
user.present:
- name: Administrator
- password: {{ pillar['admin_pw'] }}
If I do this for a user other than Administrator (that doesn't exist), it correctly creates that user, with the appropriate password. For Administrator, it says: "User Administrator is present and up to date" instead, and doesn't change the password.
Steps to Reproduce Issue
# salt CRT001 state.apply local-admin
CRT001:
----------
ID: fix_admin_pw
Function: user.present
Name: Administrator
Result: True
Comment: User Administrator is present and up to date
Started: 16:52:37.141000
Duration: 2969.0 ms
Changes:
Summary for CRT001
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 2.969 s
Debug logging on the minion doesn't show anything very useful, as far as I can see:
[INFO ] Executing state user.present for Administrator
[DEBUG ] LazyLoaded shadow.info
[DEBUG ] LazyLoaded user.info
[DEBUG ] LazyLoaded reg.read_value
[DEBUG ] user Administrator with sid=S-1-5-21-3308479896-953009055-3479373179-500 profile is located at "C:\Users\Admi
nistrator"
[DEBUG ] user Administrator with sid=S-1-5-21-3308479896-953009055-3479373179-500 profile is located at "C:\Users\Admi
nistrator"
[DEBUG ] LazyLoaded file.gid_to_group
[DEBUG ] SMBIOS: neither dmidecode nor smbios found!
[DEBUG ] Could not LazyLoad shadow.default_hash: 'shadow.default_hash' is not available.
[DEBUG ] Could not LazyLoad user.chroomnumber: 'user.chroomnumber' is not available.
[DEBUG ] Could not LazyLoad user.chworkphone: 'user.chworkphone' is not available.
[DEBUG ] Could not LazyLoad user.chhomephone: 'user.chhomephone' is not available.
[INFO ] User Administrator is present and up to date
[INFO ] Completed state [Administrator] at time 17:01:10.856000 duration_in_ms=2062.0
[DEBUG ] File c:\salt\var\cache\salt\minion\accumulator\98061840 does not exist, no need to cleanup.
Versions Report
Salt Version:
Salt: 2016.11.4
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: 3.4.3
pygit2: Not Installed
Python: 2.7.5 (default, Nov 6 2016, 00:28:07)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.3.1611 Core
machine: x86_64
release: 3.10.0-514.16.1.el7.x86_64
system: Linux
version: CentOS Linux 7.3.1611 Core
minion is Windows 2012 R2, also running 2016.11.4, installed via Chocolatey.
Hi,
It seems that the state currently does not verify passwords on windows, probably because there is no straight forward way to do so.
I guess one could verify the passwords by calling LogonUser(), though that would be subject to the account lockout threshold (which is disabled/set to 0 by default for local accounts).
@twangboy any ideas here to properly validate the password ?
@howardjones @lubyou @Ch3LL Maybe the fix in the case of Windows is to just set the password each time the state runs... for now... until we can figure out how to generate and compare a hash with the one stored in the SAM database.... which is very much like hacking....
How about an option set_pass_on with option of created (default on win), created_force_chg (force a password change as well) and always (default on Posix, with a note to indicate on windows update on every state run). It would be useful to all platforms.
If the default on win is to be changed provide a warning for a few versions of salt.
It should at least say something in the manual to the effect that it doesn't allow you to modify users, only create them.
For my particular use-case, I don't mind if the password is reset on each run, as there will only be a few runs of state.apply during the provisioning process. I am working with packer-generated OVFs, so they all have a default password of 'vagrant', which isn't ideal :-) I can see it being a pain for someone who cares about audit logs though (my case is for a disposable lab environment).
I can confirm that I also have this issue, I feel like it changed for me once but it's not consistent and in recent tests, it hasn't worked. I'd love to see a way to verify that it's actually been changed.
The win_useradd module seems to change it consistently for me though.
The problem with resetting the password would be that it would run foul of Windows password reuse checks.
you can run net user {username} which has a 'password last set' property
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
I'm running into this on 2019.2.0, any chance we could reopen this one?
Thank you for updating this issue. It is no longer marked as stale.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Thank you for updating this issue. It is no longer marked as stale.
This addresses the issue. We would need to see if we want to backport this to master. https://github.com/saltstack/salt/pull/52566