diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-10-22 03:18:11 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-10-22 03:18:11 +0000 |
commit | 46b1a4aff5e09034c419fdd939643679e5164dba (patch) | |
tree | da5886c89d80d96d74e19203f4391fa329e253b7 /usr.sbin | |
parent | 0fef6071c45d0ef2107c8f9255c052c59668a6b7 (diff) | |
download | FreeBSD-src-46b1a4aff5e09034c419fdd939643679e5164dba.zip FreeBSD-src-46b1a4aff5e09034c419fdd939643679e5164dba.tar.gz |
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.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pwd_mkdb/pwd_mkdb.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 03d24b9..5b9fe28 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -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) { |