NetBSD-current has recently switched time_t to be a 64-bit type on all platforms to cope with the year-2038 problem. This is causing all sorts of trouble, and a problem I found yesterday was that, after a clean install of NetBSD/amd64, it was impossible to change the data of any user through chfn. The command failed with:
chfn: /etc/master.passwd: entry root inconsistent expire
chfn: /etc/master.passwd: unchanged
Suspiciously, the data presented by chfn showed an expiration date for root set in a seemingly-random day (October 14th, 2021). That seemed like some part of the system not parsing the user database correctly and generating random values. A sample test program that walked through the passwords database with getpwent(3) showed an invalid expiration date for root, even when /etc/master.passwd had a 0 in that field.
After some debugging, I found out that libc tries to be compatible with old-format binary password databases (those generated by pwd_mkdb). In order to deal with compatibility, libc checks to see if the database has a VERSION field set in it. If not, it assumes it is an old version and thus time_t may not be 64-bit. If the VERSION field is set, it uses the new time_t.
So what was the problem? pwd_mkdb did not set the VERSION field even though it wrote a new-format database. libc assumed it was laid out according to the old format but it was not, so it got garbage data during parsing. After some hacking, I fixed it as described in a post to current-users.
Soon after, Christos Zoulas (the one who did all the time_t work) told me that he had already done these changes in his branch but forgot to merge them. He did now, and the code in the main branch should work fine. I still think there is a minor problem in it, but the major issue after installation should be gone.
Comments from the original Blogger-hosted post: