diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-06-07 12:29:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-06-07 12:30:23 +0200 |
commit | a5c5dc6f0b96f9ef8c567f40388d91d44aec1eb7 (patch) | |
tree | 3ad2c689d302dae350b23dc3f3c6cb234463d44d /libbb | |
parent | 5c317c0b8d7dd9bb86f220b445472e5d6cd6db02 (diff) | |
download | busybox-a5c5dc6f0b96f9ef8c567f40388d91d44aec1eb7.tar.gz |
passwd: do not set 0 as date of last password change, closes 11951
function old new delta
update_passwd 1491 1505 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/update_passwd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index 95423d19b..dc967683a 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c @@ -270,10 +270,16 @@ int FAST_FUNC update_passwd(const char *filename, if (shadow && *cp == ':') { /* /etc/shadow's field 3 (passwd change date) needs updating */ /* move past old change date */ + unsigned time_days = (unsigned long)(time(NULL)) / (24*60*60); + + if (time_days == 0) { + /* 0 as change date has special meaning, avoid it */ + time_days = 1; + } cp = strchrnul(cp + 1, ':'); /* "name:" + "new_passwd" + ":" + "change date" + ":rest of line" */ fprintf(new_fp, "%s%s:%u%s\n", name_colon, new_passwd, - (unsigned)(time(NULL)) / (24*60*60), cp); + time_days, cp); } else { /* "name:" + "new_passwd" + ":rest of line" */ fprintf(new_fp, "%s%s%s\n", name_colon, new_passwd, cp); |