1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Set user expires on FreeBSD using UTC. (#52276)

This commit is contained in:
Matt Clay 2019-02-18 06:59:13 -08:00 committed by Sam Doran
parent f6ba9be141
commit 687279c7bd
3 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- user - on FreeBSD set the user expiration time as seconds since the epoch in UTC to avoid timezone issues

View file

@ -404,6 +404,7 @@ uid:
import errno
import grp
import calendar
import os
import re
import pty
@ -1150,7 +1151,7 @@ class FreeBsdUser(User):
if self.expires < time.gmtime(0):
cmd.append('0')
else:
cmd.append(time.strftime(self.DATE_FORMAT, self.expires))
cmd.append(str(calendar.timegm(self.expires)))
# system cannot be handled currently - should we error if its requested?
# create the user
@ -1268,7 +1269,7 @@ class FreeBsdUser(User):
# Current expires is negative or we compare year, month, and day only
if current_expires <= 0 or current_expire_date[:3] != self.expires[:3]:
cmd.append('-e')
cmd.append(time.strftime(self.DATE_FORMAT, self.expires))
cmd.append(str(calendar.timegm(self.expires)))
# modify the user if cmd will do anything
if cmd_len != len(cmd):

View file

@ -364,7 +364,7 @@
- name: BSD | Ensure proper expiration date was set
assert:
that:
- bsd_account_expiration.stdout == '2529878400'
- bsd_account_expiration.stdout == '2529881062'
when: ansible_facts.os_family == 'FreeBSD'
- name: Change timezone