/etc/shadow date of last password change—UTC or local time?
Solution 1
The "seconds since 1970" timestamp is specifically defined as UTC in most usages. In particular, you may notice that date +%s
gives the same result as date -u +%s
.
The relevant line where this is set in the shadow password utilities is"
nsp->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
Which would make it UTC. SCALE is defined as 86400 (except via a specific ifdef that I can't quite trace what circumstances cause to be defined)
Solution 2
By "days" it means 86,400 second intervals. By "January 1, 1970", it means 00:00:00 UTC. This is basically standard UNIX time, also known as POSIX time.
Related videos on Youtube
me_and
L3 support engineer for Metaswitch Networks (stuff posted here isn't on behalf of my company &c. &c.). I hack around in Python, spend more time than I'd like with shell, and am proficient if somewhat rusty with C. I'm also the Git maintainer for Cygwin and a contributor to Dreamwidth. You can also find me in a wide variety of larp fields, or on Twitter, Facebook, Google+, Wikipedia (which has by far the most complete profile), and other places by request.
Updated on September 18, 2022Comments
-
me_and over 1 year
man 5 shadow
gives the following description of the third field in each line:The date of the last password change, expressed as the number of days since Jan 1, 1970.
The value 0 has a special meaning, which is that the user should change her pasword the next time she will log in the system.
An empty field means that password aging features are disabled.
Does this refer to times in UTC or the local timezone? In particular, if I want to calculate comparable numbers using something like
$(( $(date +%s) / 86400 ))
, do I need to passdate
the-u
option?