Begin closing out PR #1519 (this requires a change to chpass too,
and both changes need to be pulled into the stable branch). The problem here is that when pwd_mkdb creates /etc/passwd, it turns empty UID and GID fields into zeroes. To fix this, we check the _PWF_UID and _PWF_GID bits in the pw_fields flag: if the bits are not set, we print an empty field instead of a zero. This way, you don't get zeroes in the UID or GID fields unless you explicit want them.
This commit is contained in:
parent
0fef6071c4
commit
46b1a4aff5
@ -373,10 +373,18 @@ main(argc, argv)
|
||||
}
|
||||
}
|
||||
/* Create original format password file entry */
|
||||
if (makeold)
|
||||
(void)fprintf(oldfp, "%s:*:%d:%d:%s:%s:%s\n",
|
||||
pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos,
|
||||
pwd.pw_dir, pwd.pw_shell);
|
||||
if (makeold) {
|
||||
char uidstr[20];
|
||||
char gidstr[20];
|
||||
|
||||
snprintf(uidstr, sizeof(uidstr), "%d", pwd.pw_uid);
|
||||
snprintf(gidstr, sizeof(gidstr), "%d", pwd.pw_gid);
|
||||
|
||||
(void)fprintf(oldfp, "%s:*:%s:%s:%s:%s:%s\n",
|
||||
pwd.pw_name, pwd.pw_fields & _PWF_UID ? uidstr : "",
|
||||
pwd.pw_fields & _PWF_GID ? gidstr : "",
|
||||
pwd.pw_gecos, pwd.pw_dir, pwd.pw_shell);
|
||||
}
|
||||
}
|
||||
/* If YP enabled, set flag. */
|
||||
if (yp_enabled) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user