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.
This commit is contained in:
Peter Wemm 2001-10-27 02:13:41 +00:00
parent 935fe01014
commit 9213df7cda
2 changed files with 16 additions and 10 deletions

View File

@ -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;
}

View File

@ -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;