From b247a8eceb9c3e969e834d08d3dfb56b4e5fca81 Mon Sep 17 00:00:00 2001 From: lukem Date: Tue, 19 Jan 1999 08:30:46 +0000 Subject: [PATCH] * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis' * constify ns_dtab defs --- lib/libc/gen/getgrent.c | 8 ++++---- lib/libc/gen/getnetgrent.c | 6 +++--- lib/libc/gen/getpwent.c | 32 ++++++++++++++++++++------------ lib/libc/gen/getusershell.c | 6 +++--- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index ca8b32866541..f7e5f5391a64 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getgrent.c,v 1.30 1999/01/19 08:07:58 lukem Exp $ */ +/* $NetBSD: getgrent.c,v 1.31 1999/01/19 08:30:46 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: getgrent.c,v 1.30 1999/01/19 08:07:58 lukem Exp $"); +__RCSID("$NetBSD: getgrent.c,v 1.31 1999/01/19 08:30:46 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -428,7 +428,7 @@ __grscancompat(search, gid, name) gid_t gid; const char *name; { - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_bad_grscan, "files") NS_DNS_CB(_dns_grscan, NULL) NS_NIS_CB(_nis_grscan, NULL) @@ -536,7 +536,7 @@ grscan(search, gid, name) const char *name; { int r; - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_grscan, NULL) NS_DNS_CB(_dns_grscan, NULL) NS_NIS_CB(_nis_grscan, NULL) diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 03241d384a1a..64c0835655f6 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getnetgrent.c,v 1.19 1999/01/19 08:07:58 lukem Exp $ */ +/* $NetBSD: getnetgrent.c,v 1.20 1999/01/19 08:30:47 lukem Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -33,7 +33,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getnetgrent.c,v 1.19 1999/01/19 08:07:58 lukem Exp $"); +__RCSID("$NetBSD: getnetgrent.c,v 1.20 1999/01/19 08:30:47 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -299,7 +299,7 @@ lookup(name, line, bywhat) int bywhat; { int r; - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_lookup, NULL) NS_DNS_CB(_nis_lookup, NULL) { 0 } diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index c1547fcd670f..2aa689ed37ed 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpwent.c,v 1.35 1999/01/19 08:04:27 lukem Exp $ */ +/* $NetBSD: getpwent.c,v 1.36 1999/01/19 08:30:47 lukem Exp $ */ /* * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: getpwent.c,v 1.35 1999/01/19 08:04:27 lukem Exp $"); +__RCSID("$NetBSD: getpwent.c,v 1.36 1999/01/19 08:30:47 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -96,6 +96,10 @@ static int __hashpw __P((DBT *)); static int __initdb __P((void)); const char __yp_token[] = "__YP!"; /* Let pwd_mkdb pull this in. */ +static const ns_src compatsrc[] = { + { NSSRC_COMPAT, NS_SUCCESS }, + { 0 } +}; #ifdef YP static char *__ypcurrent, *__ypdomain; @@ -667,24 +671,28 @@ __getpwcompat(type, uid, name) uid_t uid; const char *name; { - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_bad_getpw, "files") NS_DNS_CB(_dns_getpw, NULL) NS_NIS_CB(_nis_getpw, NULL) NS_COMPAT_CB(_bad_getpw, "compat") { 0 } }; + static const ns_src defaultnis[] = { + { NSSRC_NIS, NS_SUCCESS }, + { 0 } + }; switch (type) { case _PW_KEYBYNUM: return nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "getpwcompat", - __nsdefaultsrc, type); + defaultnis, type); case _PW_KEYBYNAME: return nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "getpwcompat", - __nsdefaultsrc, type, name); + defaultnis, type, name); case _PW_KEYBYUID: return nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "getpwcompat", - __nsdefaultsrc, type, uid); + defaultnis, type, uid); default: abort(); } @@ -962,7 +970,7 @@ struct passwd * getpwent() { int r; - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_getpw, NULL) NS_DNS_CB(_dns_getpw, NULL) NS_NIS_CB(_nis_getpw, NULL) @@ -971,7 +979,7 @@ getpwent() }; _pw_none = 0; - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent", __nsdefaultsrc, + r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent", compatsrc, _PW_KEYBYNUM); if (_pw_none || r != NS_SUCCESS) return (struct passwd *)NULL; @@ -983,7 +991,7 @@ getpwnam(name) const char *name; { int r; - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_getpw, NULL) NS_DNS_CB(_dns_getpw, NULL) NS_NIS_CB(_nis_getpw, NULL) @@ -994,7 +1002,7 @@ getpwnam(name) if (name == NULL || name[0] == '\0') return (struct passwd *)NULL; - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam", __nsdefaultsrc, + r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam", compatsrc, _PW_KEYBYNAME, name); return (r == NS_SUCCESS ? &_pw_passwd : (struct passwd *)NULL); } @@ -1004,7 +1012,7 @@ getpwuid(uid) uid_t uid; { int r; - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_getpw, NULL) NS_DNS_CB(_dns_getpw, NULL) NS_NIS_CB(_nis_getpw, NULL) @@ -1012,7 +1020,7 @@ getpwuid(uid) { 0 } }; - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultsrc, + r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", compatsrc, _PW_KEYBYUID, uid); return (r == NS_SUCCESS ? &_pw_passwd : (struct passwd *)NULL); } diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c index ba5d94e4cf6a..08346441e287 100644 --- a/lib/libc/gen/getusershell.c +++ b/lib/libc/gen/getusershell.c @@ -1,4 +1,4 @@ -/* $NetBSD: getusershell.c,v 1.14 1999/01/19 08:07:58 lukem Exp $ */ +/* $NetBSD: getusershell.c,v 1.15 1999/01/19 08:30:48 lukem Exp $ */ /* * Copyright (c) 1985, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: getusershell.c,v 1.14 1999/01/19 08:07:58 lukem Exp $"); +__RCSID("$NetBSD: getusershell.c,v 1.15 1999/01/19 08:30:48 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -257,7 +257,7 @@ _nis_initshells(rv, cb_data, ap) static const char *const * initshells() { - static ns_dtab dtab[] = { + static const ns_dtab dtab[] = { NS_FILES_CB(_local_initshells, NULL) NS_DNS_CB(_dns_initshells, NULL) NS_NIS_CB(_nis_initshells, NULL)