diff options
author | nectar <nectar@FreeBSD.org> | 2000-11-10 19:11:14 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2000-11-10 19:11:14 +0000 |
commit | 8bab29b1ff0be158088bf6caeef425f66cf0655d (patch) | |
tree | a8078aa76627b63f6e49c0460c9467e563f39dfd /lib/libc | |
parent | 5cf8cc343e7b16cbee005ec248653b56ef3062e8 (diff) | |
download | FreeBSD-src-8bab29b1ff0be158088bf6caeef425f66cf0655d.zip FreeBSD-src-8bab29b1ff0be158088bf6caeef425f66cf0655d.tar.gz |
Fix passwd entry `prototypes' in compat mode. I broke this in revision
1.55 when importing nsswitch from NetBSD.
Reported by: Naoki Kobayashi <shibata@geo.titech.ac.jp>
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getpwent.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index c46c5a2..85bb988 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -82,7 +82,6 @@ static struct passwd _pw_passwd = { "", "", 0, 0, 0, "", "", "", "", 0, 0 }; static DB *_pw_db; /* password database */ static int _pw_keynum; /* key counter. no more records if -1 */ static int _pw_stayopen; /* keep fd's open */ -static int _pw_flags; /* password flags */ static int __hashpw __P((DBT *)); static int __initdb __P((void)); @@ -184,7 +183,9 @@ __pwexclude_is(name) } /* - * setup the compat mode prototype template + * Setup the compat mode prototype template that may be used in + * __pwparse. Only pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, and + * pw_shell are used. The other fields are zero'd. */ static void __pwproto_set() @@ -198,36 +199,23 @@ __pwproto_set() /* first allocate the struct. */ __pwproto = (struct passwd *)(void *)ptr; ptr += sizeof(struct passwd); + memset(__pwproto, 0, sizeof(*__pwproto)); + + __pwproto_flags = 0; - /* name */ - if(pw->pw_name && (pw->pw_name)[0]) { - ptr = (char *)ALIGN((u_long)ptr); - memmove(ptr, pw->pw_name, strlen(pw->pw_name) + 1); - __pwproto->pw_name = ptr; - ptr += (strlen(pw->pw_name) + 1); - } else - __pwproto->pw_name = (char *)NULL; - /* password */ if(pw->pw_passwd && (pw->pw_passwd)[0]) { ptr = (char *)ALIGN((u_long)ptr); memmove(ptr, pw->pw_passwd, strlen(pw->pw_passwd) + 1); __pwproto->pw_passwd = ptr; ptr += (strlen(pw->pw_passwd) + 1); - } else - __pwproto->pw_passwd = (char *)NULL; + __pwproto_flags |= _PWF_PASSWD; + } - /* uid */ + /* uid, gid */ __pwproto->pw_uid = pw->pw_uid; - - /* gid */ __pwproto->pw_gid = pw->pw_gid; - - /* change (ignored anyway) */ - __pwproto->pw_change = pw->pw_change; - - /* class (ignored anyway) */ - __pwproto->pw_class = ""; + __pwproto_flags |= _PWF_UID | _PWF_GID; /* gecos */ if(pw->pw_gecos && (pw->pw_gecos)[0]) { @@ -235,8 +223,8 @@ __pwproto_set() memmove(ptr, pw->pw_gecos, strlen(pw->pw_gecos) + 1); __pwproto->pw_gecos = ptr; ptr += (strlen(pw->pw_gecos) + 1); - } else - __pwproto->pw_gecos = (char *)NULL; + __pwproto_flags |= _PWF_GECOS; + } /* dir */ if(pw->pw_dir && (pw->pw_dir)[0]) { @@ -244,8 +232,8 @@ __pwproto_set() memmove(ptr, pw->pw_dir, strlen(pw->pw_dir) + 1); __pwproto->pw_dir = ptr; ptr += (strlen(pw->pw_dir) + 1); - } else - __pwproto->pw_dir = (char *)NULL; + __pwproto_flags |= _PWF_DIR; + } /* shell */ if(pw->pw_shell && (pw->pw_shell)[0]) { @@ -253,14 +241,8 @@ __pwproto_set() memmove(ptr, pw->pw_shell, strlen(pw->pw_shell) + 1); __pwproto->pw_shell = ptr; ptr += (strlen(pw->pw_shell) + 1); - } else - __pwproto->pw_shell = (char *)NULL; - - /* expire (ignored anyway) */ - __pwproto->pw_expire = pw->pw_expire; - - /* flags */ - __pwproto_flags = _pw_flags; + __pwproto_flags |= _PWF_SHELL; + } } static int |