allow non-integer values in /etc/default/passwd to mirror solaris behavior

This commit is contained in:
bengerman 2018-05-17 08:57:24 -07:00 committed by Brian Coca
parent de8b6b55f7
commit 82f6f08712

View file

@ -1459,11 +1459,23 @@ class SunOS(User):
fields[1] = self.password fields[1] = self.password
fields[2] = str(int(time.time() // 86400)) fields[2] = str(int(time.time() // 86400))
if minweeks: if minweeks:
try:
fields[3] = str(int(minweeks) * 7) fields[3] = str(int(minweeks) * 7)
except ValueError:
# mirror solaris, which allows for any value in this field, and ignores anything that is not an int.
pass
if maxweeks: if maxweeks:
try:
fields[4] = str(int(maxweeks) * 7) fields[4] = str(int(maxweeks) * 7)
except ValueError:
# mirror solaris, which allows for any value in this field, and ignores anything that is not an int.
pass
if warnweeks: if warnweeks:
try:
fields[5] = str(int(warnweeks) * 7) fields[5] = str(int(warnweeks) * 7)
except ValueError:
# mirror solaris, which allows for any value in this field, and ignores anything that is not an int.
pass
line = ':'.join(fields) line = ':'.join(fields)
lines.append('%s\n' % line) lines.append('%s\n' % line)
open(self.SHADOWFILE, 'w+').writelines(lines) open(self.SHADOWFILE, 'w+').writelines(lines)