From 9213df7cdaaa67a6e27e3eecac78abb8d198f5f8 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sat, 27 Oct 2001 02:13:41 +0000 Subject: [PATCH] Explicitly use int32_t for on-disk records for pw_change and pw_expire, since that is what we use now and this insulates us from any time_t tweaks here. We can define a record format that uses 64 bit times if/when we need to. --- lib/libc/gen/getpwent.c | 7 +++++-- usr.sbin/pwd_mkdb/pwd_mkdb.c | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index ae384ba0b076..547675f491bf 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1129,6 +1129,7 @@ __hashpw(key) char *p, *t; static u_int max; static char *buf; + int32_t pw_change, pw_expire; DBT data; switch ((_pw_db->get)(_pw_db, key, &data, 0)) { @@ -1154,13 +1155,15 @@ __hashpw(key) EXPAND(_pw_passwd.pw_passwd); SCALAR(_pw_passwd.pw_uid); SCALAR(_pw_passwd.pw_gid); - SCALAR(_pw_passwd.pw_change); + SCALAR(pw_change); EXPAND(_pw_passwd.pw_class); EXPAND(_pw_passwd.pw_gecos); EXPAND(_pw_passwd.pw_dir); EXPAND(_pw_passwd.pw_shell); - SCALAR(_pw_passwd.pw_expire); + SCALAR(pw_expire); SCALAR(_pw_passwd.pw_fields); + _pw_passwd.pw_change = pw_change; + _pw_passwd.pw_expire = pw_expire; return NS_SUCCESS; } diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 01e52de33425..40dc511c9c53 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -101,6 +101,7 @@ main(argc, argv) FILE *fp, *oldfp; sigset_t set; int ch, cnt, ypcnt, len, makeold, tfd, yp_enabled = 0; + int32_t pw_change, pw_expire; char *p, *t; char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024]; char sbuf[MAX(MAXPATHLEN, LINE_MAX * 2)]; @@ -316,6 +317,8 @@ main(argc, argv) #define COMPACT(e) t = e; while ((*p++ = *t++)); if (!is_comment && (!username || (strcmp(username, pwd.pw_name) == 0))) { + pw_change = pwd.pw_change; + pw_expire = pwd.pw_expire; /* Create insecure data. */ p = buf; COMPACT(pwd.pw_name); @@ -324,14 +327,14 @@ main(argc, argv) p += sizeof(int); memmove(p, &pwd.pw_gid, sizeof(pwd.pw_gid)); p += sizeof(int); - memmove(p, &pwd.pw_change, sizeof(time_t)); - p += sizeof(time_t); + memmove(p, &pw_change, sizeof(pw_change)); + p += sizeof(pw_change); COMPACT(pwd.pw_class); COMPACT(pwd.pw_gecos); COMPACT(pwd.pw_dir); COMPACT(pwd.pw_shell); - memmove(p, &pwd.pw_expire, sizeof(time_t)); - p += sizeof(time_t); + memmove(p, &pw_expire, sizeof(pw_expire)); + p += sizeof(pw_expire); memmove(p, &pwd.pw_fields, sizeof pwd.pw_fields); p += sizeof pwd.pw_fields; data.size = p - buf; @@ -344,14 +347,14 @@ main(argc, argv) p += sizeof(int); memmove(p, &pwd.pw_gid, sizeof(pwd.pw_gid)); p += sizeof(int); - memmove(p, &pwd.pw_change, sizeof(time_t)); - p += sizeof(time_t); + memmove(p, &pw_change, sizeof(pw_change)); + p += sizeof(pw_change); COMPACT(pwd.pw_class); COMPACT(pwd.pw_gecos); COMPACT(pwd.pw_dir); COMPACT(pwd.pw_shell); - memmove(p, &pwd.pw_expire, sizeof(time_t)); - p += sizeof(time_t); + memmove(p, &pw_expire, sizeof(pw_expire)); + p += sizeof(pw_expire); memmove(p, &pwd.pw_fields, sizeof pwd.pw_fields); p += sizeof pwd.pw_fields; sdata.size = p - sbuf;