summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getpwent.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-11 11:52:33 +0000
committerpeter <peter@FreeBSD.org>1997-03-11 11:52:33 +0000
commit0b3e1277b4e3cc3bb2575162ec238cac00b15a18 (patch)
tree30be23b5b8ddeb71e0495f1655cf455ef58c410f /lib/libc/gen/getpwent.c
parent9234fe208b22e039265244d8a518ff096d630a44 (diff)
downloadFreeBSD-src-0b3e1277b4e3cc3bb2575162ec238cac00b15a18.zip
FreeBSD-src-0b3e1277b4e3cc3bb2575162ec238cac00b15a18.tar.gz
Merge from Lite2:
filesystem include updates, duplicate group suppression, cleanups, filesystem whiteout support (unionfs), bidir popen().
Diffstat (limited to 'lib/libc/gen/getpwent.c')
-rw-r--r--lib/libc/gen/getpwent.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 66ed5c0..3cd9fdc 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getpwent.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -53,6 +53,11 @@ extern void setnetgrent __P(( char * ));
extern int getnetgrent __P(( char **, char **, char ** ));
extern int innetgr __P(( const char *, const char *, const char *, const char * ));
+/*
+ * The lookup techniques and data extraction code here must be kept
+ * in sync with that in `pwd_mkdb'.
+ */
+
static struct passwd _pw_passwd; /* password structure */
static DB *_pw_db; /* password database */
static int _pw_keynum; /* key counter */
@@ -162,12 +167,8 @@ getpwnam(name)
}
struct passwd *
-#ifdef __STDC__
-getpwuid(uid_t uid)
-#else
getpwuid(uid)
- int uid;
-#endif
+ uid_t uid;
{
DBT key;
int keyuid, rval;
@@ -295,22 +296,20 @@ __hashpw(key)
if (data.size > max && !(line = realloc(line, max += 1024)))
return(0);
+ /* THIS CODE MUST MATCH THAT IN pwd_mkdb. */
t = line;
#define EXPAND(e) e = t; while ( (*t++ = *p++) );
+#define SCALAR(v) memmove(&(v), p, sizeof v); p += sizeof v
EXPAND(_pw_passwd.pw_name);
EXPAND(_pw_passwd.pw_passwd);
- bcopy(p, (char *)&_pw_passwd.pw_uid, sizeof(int));
- p += sizeof(int);
- bcopy(p, (char *)&_pw_passwd.pw_gid, sizeof(int));
- p += sizeof(int);
- bcopy(p, (char *)&_pw_passwd.pw_change, sizeof(time_t));
- p += sizeof(time_t);
+ SCALAR(_pw_passwd.pw_uid);
+ SCALAR(_pw_passwd.pw_gid);
+ SCALAR(_pw_passwd.pw_change);
EXPAND(_pw_passwd.pw_class);
EXPAND(_pw_passwd.pw_gecos);
EXPAND(_pw_passwd.pw_dir);
EXPAND(_pw_passwd.pw_shell);
- bcopy(p, (char *)&_pw_passwd.pw_expire, sizeof(time_t));
- p += sizeof(time_t);
+ SCALAR(_pw_passwd.pw_expire);
bcopy(p, (char *)&_pw_passwd.pw_fields, sizeof _pw_passwd.pw_fields);
p += sizeof _pw_passwd.pw_fields;
return(1);
OpenPOWER on IntegriCloud