user: Handle exception when /etc/shadow file is missing (#63888)

Added exception handling when module tries to modify user details,
and /etc/shadow file is missing or not found.

Fixes: #63490

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2019-10-25 00:52:41 +05:30 committed by Matt Martz
parent 7f5d1ab2b7
commit af0d70cb6f
2 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Handle exception when /etc/shadow file is missing or not found, while operating user operation in user module (https://github.com/ansible/ansible/issues/63490).

View file

@ -911,7 +911,7 @@ class User(object):
# Python 3.6 raises PermissionError instead of KeyError
# Due to absence of PermissionError in python2.7 need to check
# errno
if e.errno in (errno.EACCES, errno.EPERM):
if e.errno in (errno.EACCES, errno.EPERM, errno.ENOENT):
return passwd, expires
raise