diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-04-04 05:36:16 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-04-04 05:36:16 +0000 |
commit | fd72f57342162b4d6d9fddb7dbb789e23e3edf80 (patch) | |
tree | a09863032a50b1e4a5a2e09112bd00a360d9aa08 /lib | |
parent | d5e3b4577028238a0c0130fdb7cc0189a4d34067 (diff) | |
download | FreeBSD-src-fd72f57342162b4d6d9fddb7dbb789e23e3edf80.zip FreeBSD-src-fd72f57342162b4d6d9fddb7dbb789e23e3edf80.tar.gz |
getpwent.c: fix problem with emacs dumping core when NIS is enabled. Also
add #includes for YP headers when compiling with -DYP to avoid some implicit
declarations.
getgrent.c & getnetgrent.c: add some #includes to avoid implicit declarations
of YP functions.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/getgrent.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/getnetgrent.c | 12 | ||||
-rw-r--r-- | lib/libc/gen/getpwent.c | 36 |
3 files changed, 34 insertions, 21 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index dfcabb0..8c60361 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -46,9 +46,12 @@ static struct group _gr_group; static int _gr_stayopen; static int grscan(), start_gr(); #ifdef YP +#include <rpc/rpc.h> +#include <rpcsvc/yp_prot.h> +#include <rpcsvc/ypclnt.h> static int _gr_stepping_yp; static int _gr_yp_enabled; -static int _getypgroup(struct group *, const char *, const char *); +static int _getypgroup(struct group *, const char *, char *); static int _nextypgroup(struct group *); #endif @@ -316,7 +319,7 @@ _gr_breakout_yp(struct group *gr, char *result) static char *_gr_yp_domain; static int -_getypgroup(struct group *gr, const char *name, const char *map) +_getypgroup(struct group *gr, const char *name, char *map) { char *result, *s; static char resultbuf[1024]; diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 1b581cf..c60cc4e 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -40,6 +40,15 @@ static char sccsid[] = "@(#)getnetgrent.c 8.1 (Berkeley) 6/4/93"; #include <stdio.h> #include <strings.h> +#include <stdlib.h> +#include <unistd.h> + +#ifdef YP +#include <rpc/rpc.h> +#include <rpcsvc/yp_prot.h> +#include <rpcsvc/ypclnt.h> +static int _netgr_yp_enabled; +#endif #define _PATH_NETGROUP "/etc/netgroup" @@ -77,9 +86,6 @@ static struct { }; static FILE *netf = (FILE *)0; static int parse_netgrp(); -#ifdef YP -static int _netgr_yp_enabled; -#endif static struct linelist *read_for_group(); void setnetgrent(), endnetgrent(); int getnetgrent(), innetgr(); diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 1f9b4d6..7c693e3 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -35,6 +35,7 @@ static char sccsid[] = "@(#)getpwent.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <stdio.h> #include <sys/param.h> #include <fcntl.h> #include <db.h> @@ -46,12 +47,16 @@ static char sccsid[] = "@(#)getpwent.c 8.1 (Berkeley) 6/4/93"; #include <stdlib.h> #include <string.h> #include <limits.h> +#include <grp.h> static struct passwd _pw_passwd; /* password structure */ static DB *_pw_db; /* password database */ static int _pw_keynum; /* key counter */ static int _pw_stayopen; /* keep fd's open */ #ifdef YP +#include <rpc/rpc.h> +#include <rpcsvc/yp_prot.h> +#include <rpcsvc/ypclnt.h> struct _namelist { char *name; struct _namelist *next; @@ -70,7 +75,7 @@ static int _pw_stepping_yp; /* set true when stepping thru map */ #endif static int __hashpw(), __initdb(); -static int _havemaster(const char *); +static int _havemaster(char *); static int _getyppass(struct passwd *, const char *, const char *); static int _nextyppass(struct passwd *); @@ -89,9 +94,9 @@ getpwent() _pw_passwd = _pw_copy; return (_nextyppass(&_pw_passwd) ? &_pw_passwd : 0); } -#endif - +#else tryagain: +#endif ++_pw_keynum; bf[0] = _PW_KEYBYNUM; bcopy((char *)&_pw_keynum, bf + 1, sizeof(_pw_keynum)); @@ -307,14 +312,12 @@ __hashpw(key) * database though getpwent() very slow. +user/-user entries are treated * like @groups/@netgroups with only one member. */ -#include <grp.h> static void _createcaches() { DBT key, data; int i; char bf[UT_NAMESIZE + 2]; - char entry[UT_NAMESIZE]; struct _pw_cache *p, *m; struct _namelist *n, *namehead; char *user, *host, *domain; @@ -552,12 +555,11 @@ _pw_breakout_yp(struct passwd *pw, char *result, int master) static char *_pw_yp_domain; static int -_havemaster(const char *_pw_yp_domain) +_havemaster(char *_pw_yp_domain) { - char *result; int *order; - if (yp_order(_pw_yp_domain, "master.passwd.byname", &order)) { + if (yp_order(_pw_yp_domain, "master.passwd.byname", (int *)&order)) { free(order); return 0; } @@ -576,6 +578,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) int gotmaster = 0; struct _pw_cache *m, *p; struct _namelist *n; + char user[UT_NAMESIZE]; if(!_pw_yp_domain) { if(yp_get_default_domain(&_pw_yp_domain)) @@ -591,7 +594,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) gotmaster++; } - if(yp_match(_pw_yp_domain, &mastermap, name, strlen(name), + if(yp_match(_pw_yp_domain, (char *)&mastermap, name, strlen(name), &result, &resultlen)) return 0; @@ -600,14 +603,14 @@ _getyppass(struct passwd *pw, const char *name, const char *map) if(resultlen >= sizeof resultbuf) return 0; strcpy(resultbuf, result); - s = strsep(&result,":"); + sprintf (user, "%.*s", (strchr(result, ':') - result), result); _pw_passwd.pw_fields = 0; if (_minuscnt && _minushead) { m = _minushead; while (m) { n = m->namelist; while (n) { - if (!strcmp(n->name, s) || *n->name == '\0') { + if (!strcmp(n->name,user) || *n->name == '\0') { free(result); return (0); } @@ -621,7 +624,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) while (p) { n = p->namelist; while (n) { - if (!strcmp(n->name, s) || *n->name == '\0') + if (!strcmp(n->name, user) || *n->name == '\0') bcopy((char *)&p->pw_entry, (char *)&_pw_passwd, sizeof(p->pw_entry)); n = n->next; @@ -639,7 +642,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) static int _nextyppass(struct passwd *pw) { - static char *key, *s; + static char *key; static int keylen; char *lastkey, *result; static char resultbuf[1024]; @@ -649,6 +652,7 @@ _nextyppass(struct passwd *pw) int gotmaster = 0; struct _pw_cache *m, *p; struct _namelist *n; + char user[UT_NAMESIZE]; if(!_pw_yp_domain) { if(yp_get_default_domain(&_pw_yp_domain)) @@ -689,14 +693,14 @@ unpack: } strcpy(resultbuf, result); - s = strsep(&result,":"); + sprintf(user, "%.*s", (strchr(result, ':') - result), result); _pw_passwd.pw_fields = 0; if (_minuscnt && _minushead) { m = _minushead; while (m) { n = m->namelist; while (n) { - if (!strcmp(n->name, s) || *n->name == '\0') { + if (!strcmp(n->name, user) || *n->name == '\0') { free(result); goto tryagain; } @@ -710,7 +714,7 @@ unpack: while (p) { n = p->namelist; while (n) { - if (!strcmp(n->name, s) || *n->name == '\0') + if (!strcmp(n->name, user) || *n->name == '\0') bcopy((char *)&p->pw_entry, (char*)&_pw_passwd, sizeof(p->pw_entry)); n = n->next; |