From 55436fde26c57588a62c31a754a3dc3c1d62d4cd Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 30 Jan 2019 17:26:23 -0500 Subject: [PATCH] Use correct property name (#51511) Add missing variable for storing returned file object. This prevents an I/O error because the f.writelines() call will be against a closed file. --- lib/ansible/modules/system/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index 129fdcce30..e2f7d0e269 100644 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -1909,7 +1909,7 @@ class SunOS(User): fields[5] = str(int(warnweeks) * 7) line = ':'.join(fields) lines.append('%s\n' % line) - with open(self.SHADOWFILE, 'w+'): + with open(self.SHADOWFILE, 'w+') as f: f.writelines(lines) rc = 0 except Exception as err: @@ -1928,7 +1928,7 @@ class SunOS(User): with open(self.USER_ATTR, 'r') as file_handler: for line in file_handler: lines = line.strip().split('::::') - if lines[0] == self.user: + if lines[0] == self.name: tmp = dict(x.split('=') for x in lines[1].split(';')) info[0] = tmp.get('profiles', '') info[1] = tmp.get('auths', '')