nsswitch: use new internal API (callers)

Stitch new ABI and types throughout all NSS callers.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
DJ Delorie 2020-11-09 22:09:34 -05:00
parent 6eceded941
commit f4f3b09111
26 changed files with 87 additions and 261 deletions

View file

@ -10,7 +10,7 @@ typedef enum nss_status (*get_function) (struct group *, char *,
static enum nss_status static enum nss_status
compat_call (service_user *nip, const char *user, gid_t group, long int *start, compat_call (nss_action_list nip, const char *user, gid_t group, long int *start,
long int *size, gid_t **groupsp, long int limit, int *errnop) long int *size, gid_t **groupsp, long int limit, int *errnop)
{ {
struct group grpbuf; struct group grpbuf;

View file

@ -63,7 +63,6 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
#endif #endif
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more = 0;
/* Never store more than the starting *SIZE number of elements. */ /* Never store more than the starting *SIZE number of elements. */
assert (*size > 0); assert (*size > 0);
@ -71,28 +70,23 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
/* Start is one, because we have the first group as parameter. */ /* Start is one, because we have the first group as parameter. */
long int start = 1; long int start = 1;
if (__nss_initgroups_database == NULL) nss_action_list nip;
{
if (__nss_database_lookup2 ("initgroups", NULL, "",
&__nss_initgroups_database) < 0)
{
if (__nss_group_database == NULL)
no_more = __nss_database_lookup2 ("group", NULL, "files",
&__nss_group_database);
__nss_initgroups_database = __nss_group_database; if (__nss_database_get (nss_database_initgroups, &nip))
} {
else use_initgroups_entry = true;
use_initgroups_entry = true; }
else if (__nss_database_get (nss_database_group, &nip))
{
use_initgroups_entry = false;
} }
else else
/* __nss_initgroups_database might have been set through {
__nss_configure_lookup in which case use_initgroups_entry was nip = __nss_action_parse ("files");
not set here. */ use_initgroups_entry = false;
use_initgroups_entry = __nss_initgroups_database != __nss_group_database; }
service_user *nip = __nss_initgroups_database; while (nip && nip->module)
while (! no_more)
{ {
long int prev_start = start; long int prev_start = start;
@ -134,10 +128,7 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
&& nss_next_action (nip, status) == NSS_ACTION_RETURN) && nss_next_action (nip, status) == NSS_ACTION_RETURN)
break; break;
if (nip->next == NULL) nip++;
no_more = -1;
else
nip = nip->next;
} }
return start; return start;

View file

@ -30,9 +30,7 @@ typedef int (*lookup_function) (const char *, struct etherent *, char *, int,
int int
ether_hostton (const char *hostname, struct ether_addr *addr) ether_hostton (const char *hostname, struct ether_addr *addr)
{ {
static service_user *startp; nss_action_list nip;
static lookup_function start_fct;
service_user *nip;
union union
{ {
lookup_function f; lookup_function f;
@ -42,22 +40,7 @@ ether_hostton (const char *hostname, struct ether_addr *addr)
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
struct etherent etherent; struct etherent etherent;
if (startp == NULL) no_more = __nss_ethers_lookup2 (&nip, "gethostton_r", NULL, &fct.ptr);
{
no_more = __nss_ethers_lookup2 (&nip, "gethostton_r", NULL, &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
start_fct = fct.f;
}
}
else
{
fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (no_more == 0) while (no_more == 0)
{ {

View file

@ -31,9 +31,7 @@ typedef int (*lookup_function) (const struct ether_addr *, struct etherent *,
int int
ether_ntohost (char *hostname, const struct ether_addr *addr) ether_ntohost (char *hostname, const struct ether_addr *addr)
{ {
static service_user *startp; nss_action_list nip;
static lookup_function start_fct;
service_user *nip;
union union
{ {
lookup_function f; lookup_function f;
@ -43,22 +41,7 @@ ether_ntohost (char *hostname, const struct ether_addr *addr)
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
struct etherent etherent; struct etherent etherent;
if (startp == NULL) no_more = __nss_ethers_lookup2 (&nip, "getntohost_r", NULL, &fct.ptr);
{
no_more = __nss_ethers_lookup2 (&nip, "getntohost_r", NULL, &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
start_fct = fct.f;
}
}
else
{
fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (no_more == 0) while (no_more == 0)
{ {

View file

@ -39,40 +39,12 @@ static struct __netgrent dataset;
/* Set up NIP to run through the services. Return nonzero if there are no /* Set up NIP to run through the services. Return nonzero if there are no
services (left). */ services (left). */
static int static int
setup (void **fctp, service_user **nipp) setup (void **fctp, nss_action_list *nipp)
{ {
/* Remember the first service_entry, it's always the same. */
static bool startp_initialized;
static service_user *startp;
int no_more; int no_more;
if (!startp_initialized) no_more = __nss_netgroup_lookup2 (nipp, "setnetgrent", NULL, fctp);
{
/* Executing this more than once at the same time must yield the
same result every time. So we need no locking. */
no_more = __nss_netgroup_lookup2 (nipp, "setnetgrent", NULL, fctp);
startp = no_more ? (service_user *) -1 : *nipp;
#ifdef PTR_MANGLE
PTR_MANGLE (startp);
#endif
atomic_write_barrier ();
startp_initialized = true;
}
else
{
service_user *nip = startp;
#ifdef PTR_DEMANGLE
PTR_DEMANGLE (nip);
#endif
if (nip == (service_user *) -1)
/* No services at all. */
return 1;
/* Reset to the beginning of the service list. */
*nipp = nip;
/* Look up the first function. */
no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp);
}
return no_more; return no_more;
} }
@ -100,7 +72,7 @@ endnetgrent_hook (struct __netgrent *datap)
{ {
enum nss_status (*endfct) (struct __netgrent *); enum nss_status (*endfct) (struct __netgrent *);
if (datap->nip == NULL || datap->nip == (service_user *) -1l) if (datap->nip == NULL || datap->nip == (nss_action_list) -1l)
return; return;
endfct = __nss_lookup_function (datap->nip, "endnetgrent"); endfct = __nss_lookup_function (datap->nip, "endnetgrent");
@ -133,7 +105,7 @@ __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
/* Ignore status, we force check in `__nss_next2'. */ /* Ignore status, we force check in `__nss_next2'. */
status = DL_CALL_FCT (*fct.f, (group, datap)); status = DL_CALL_FCT (*fct.f, (group, datap));
service_user *old_nip = datap->nip; nss_action_list old_nip = datap->nip;
no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr, no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr,
status, 0); status, 0);
@ -275,7 +247,7 @@ __internal_getnetgrent_r (char **hostp, char **userp, char **domainp,
/* This bogus function pointer is a special marker left by /* This bogus function pointer is a special marker left by
__nscd_setnetgrent to tell us to use the data it left __nscd_setnetgrent to tell us to use the data it left
before considering any modules. */ before considering any modules. */
if (datap->nip == (service_user *) -1l) if (datap->nip == (nss_action_list) -1l)
fct = nscd_getnetgrent; fct = nscd_getnetgrent;
else else
#endif #endif

View file

@ -64,7 +64,7 @@ struct __netgrent
/* This handle for the NSS data base is shared between all /* This handle for the NSS data base is shared between all
set/get/endXXXent functions. */ set/get/endXXXent functions. */
service_user *nip; struct nss_action *nip;
}; };

View file

@ -71,20 +71,15 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) key); dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) key);
} }
static service_user *hosts_database; nss_action_list nip;
service_user *nip;
int no_more; int no_more;
int rc6 = 0; int rc6 = 0;
int rc4 = 0; int rc4 = 0;
int herrno = 0; int herrno = 0;
if (hosts_database == NULL) no_more = __nss_database_lookup2 ("hosts", NULL,
no_more = __nss_database_lookup2 ("hosts", NULL, "dns [!UNAVAIL=return] files",
"dns [!UNAVAIL=return] files", &nip);
&hosts_database);
else
no_more = 0;
nip = hosts_database;
/* Initialize configurations. */ /* Initialize configurations. */
struct resolv_context *ctx = __resolv_context_get (); struct resolv_context *ctx = __resolv_context_get ();
@ -442,10 +437,10 @@ next_nip:
if (nss_next_action (nip, status[1]) == NSS_ACTION_RETURN) if (nss_next_action (nip, status[1]) == NSS_ACTION_RETURN)
break; break;
if (nip->next == NULL) if (nip[1].module == NULL)
no_more = -1; no_more = -1;
else else
nip = nip->next; ++nip;
} }
/* No result found. Create a negative result record. */ /* No result found. Create a negative result record. */

View file

@ -48,4 +48,4 @@
#include <check_native.c> #include <check_native.c>
/* Some variables normally defined in libc. */ /* Some variables normally defined in libc. */
service_user *__nss_hosts_database attribute_hidden; nss_action_list __nss_hosts_database attribute_hidden;

View file

@ -77,8 +77,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in group cache!"), (char *) key); dbg_log (_("Reloading \"%s\" in group cache!"), (char *) key);
} }
static service_user *group_database; static nss_action_list group_database;
service_user *nip; nss_action_list nip;
int no_more; int no_more;
if (group_database == NULL) if (group_database == NULL)
@ -161,10 +161,10 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
&& nss_next_action (nip, status) == NSS_ACTION_RETURN) && nss_next_action (nip, status) == NSS_ACTION_RETURN)
break; break;
if (nip->next == NULL) if (nip[1].module == NULL)
no_more = -1; no_more = -1;
else else
nip = nip->next; ++nip;
} }
bool all_written; bool all_written;

View file

@ -124,7 +124,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in netgroup cache!"), key); dbg_log (_("Reloading \"%s\" in netgroup cache!"), key);
} }
static service_user *netgroup_database; static nss_action_list netgroup_database;
time_t timeout; time_t timeout;
struct dataset *dataset; struct dataset *dataset;
bool cacheable = false; bool cacheable = false;
@ -175,7 +175,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
void *ptr; void *ptr;
} setfct; } setfct;
service_user *nip = netgroup_database; nss_action_list nip = netgroup_database;
int no_more = __nss_lookup (&nip, "setnetgrent", NULL, &setfct.ptr); int no_more = __nss_lookup (&nip, "setnetgrent", NULL, &setfct.ptr);
while (!no_more) while (!no_more)
{ {

View file

@ -116,7 +116,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
datap->data_size = datalen; datap->data_size = datalen;
datap->cursor = respdata; datap->cursor = respdata;
datap->first = 1; datap->first = 1;
datap->nip = (service_user *) -1l; datap->nip = (nss_action_list) -1l;
datap->known_groups = NULL; datap->known_groups = NULL;
datap->needed_groups = NULL; datap->needed_groups = NULL;

View file

@ -53,12 +53,11 @@
#endif #endif
int int
DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name, DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name,
void **fctp) void **fctp)
{ {
if (DATABASE_NAME_SYMBOL == NULL if (__nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
&& __nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING, DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
return -1; return -1;
*ni = DATABASE_NAME_SYMBOL; *ni = DATABASE_NAME_SYMBOL;

View file

@ -29,7 +29,7 @@
glibc 2.7 and earlier and glibc 2.8 and later, even on i386. */ glibc 2.7 and earlier and glibc 2.8 and later, even on i386. */
int int
attribute_compat_text_section attribute_compat_text_section
__nss_passwd_lookup (service_user **ni, const char *fct_name, void **fctp) __nss_passwd_lookup (nss_action_list *ni, const char *fct_name, void **fctp)
{ {
__set_errno (ENOSYS); __set_errno (ENOSYS);
return -1; return -1;
@ -46,11 +46,11 @@ compat_symbol (libc, __nss_hosts_lookup, __nss_hosts_lookup, GLIBC_2_0);
/* These functions were exported under a non-GLIBC_PRIVATE version, /* These functions were exported under a non-GLIBC_PRIVATE version,
even though it is not usable externally due to the service_user even though it is not usable externally due to the service_user
type dependency. */ (now nss_action_list) type dependency. */
int int
attribute_compat_text_section attribute_compat_text_section
__nss_next (service_user **ni, const char *fct_name, void **fctp, int status, __nss_next (nss_action_list *ni, const char *fct_name, void **fctp, int status,
int all_values) int all_values)
{ {
return -1; return -1;
@ -60,7 +60,7 @@ compat_symbol (libc, __nss_next, __nss_next, GLIBC_2_0);
int int
attribute_compat_text_section attribute_compat_text_section
__nss_database_lookup (const char *database, const char *alternate_name, __nss_database_lookup (const char *database, const char *alternate_name,
const char *defconfig, service_user **ni) const char *defconfig, nss_action_list *ni)
{ {
*ni = NULL; *ni = NULL;
return -1; return -1;

View file

@ -179,7 +179,7 @@ typedef enum nss_status (*lookup_function) (ADD_PARAMS, LOOKUP_TYPE *, char *,
EXTRA_PARAMS); EXTRA_PARAMS);
/* The lookup function for the first entry of this service. */ /* The lookup function for the first entry of this service. */
extern int DB_LOOKUP_FCT (service_user **nip, const char *name, extern int DB_LOOKUP_FCT (nss_action_list *nip, const char *name,
const char *name2, void **fctp); const char *name2, void **fctp);
libc_hidden_proto (DB_LOOKUP_FCT) libc_hidden_proto (DB_LOOKUP_FCT)
@ -189,10 +189,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM
EXTRA_PARAMS) EXTRA_PARAMS)
{ {
static bool startp_initialized; nss_action_list nip;
static service_user *startp;
static lookup_function start_fct;
service_user *nip;
int do_merge = 0; int do_merge = 0;
LOOKUP_TYPE mergegrp; LOOKUP_TYPE mergegrp;
char *mergebuf = NULL; char *mergebuf = NULL;
@ -227,6 +224,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
PREPROCESS; PREPROCESS;
#endif #endif
#ifdef HANDLE_DIGITS_DOTS #ifdef HANDLE_DIGITS_DOTS
switch (__nss_hostname_digits_dots (name, resbuf, &buffer, NULL, switch (__nss_hostname_digits_dots (name, resbuf, &buffer, NULL,
buflen, result, &status, AF_VAL, buflen, result, &status, AF_VAL,
@ -264,47 +262,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
} }
#endif #endif
if (! startp_initialized) no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING,
{ REENTRANT2_NAME_STRING, &fct.ptr);
no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING,
REENTRANT2_NAME_STRING, &fct.ptr);
if (no_more)
{
void *tmp_ptr = (service_user *) -1l;
#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
#endif
startp = tmp_ptr;
}
else
{
void *tmp_ptr = fct.l;
#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
#endif
start_fct = tmp_ptr;
tmp_ptr = nip;
#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
#endif
startp = tmp_ptr;
}
/* Make sure start_fct and startp are written before
startp_initialized. */
atomic_write_barrier ();
startp_initialized = true;
}
else
{
fct.l = start_fct;
nip = startp;
#ifdef PTR_DEMANGLE
PTR_DEMANGLE (fct.l);
PTR_DEMANGLE (nip);
#endif
no_more = nip == (service_user *) -1l;
}
while (no_more == 0) while (no_more == 0)
{ {

View file

@ -95,11 +95,11 @@
/* This handle for the NSS data base is shared between all /* This handle for the NSS data base is shared between all
set/get/endXXXent functions. */ set/get/endXXXent functions. */
static service_user *nip; static nss_action_list nip;
/* Remember the last service used since the last call to `endXXent'. */ /* Remember the last service used since the last call to `endXXent'. */
static service_user *last_nip; static nss_action_list last_nip;
/* Remember the first service_entry, it's always the same. */ /* Remember the first service_entry across set/get/endent. */
static service_user *startp; static nss_action_list startp;
#ifdef STAYOPEN_TMP #ifdef STAYOPEN_TMP
/* We need to remember the last `stayopen' flag given by the user /* We need to remember the last `stayopen' flag given by the user
@ -112,7 +112,7 @@ static STAYOPEN_TMP;
__libc_lock_define_initialized (static, lock) __libc_lock_define_initialized (static, lock)
/* The lookup function for the first entry of this service. */ /* The lookup function for the first entry of this service. */
extern int DB_LOOKUP_FCT (service_user **nip, const char *name, extern int DB_LOOKUP_FCT (nss_action_list *nip, const char *name,
const char *name2, void **fctp); const char *name2, void **fctp);
libc_hidden_proto (DB_LOOKUP_FCT) libc_hidden_proto (DB_LOOKUP_FCT)

View file

@ -25,20 +25,20 @@
services (left). */ services (left). */
static int static int
setup (const char *func_name, db_lookup_function lookup_fct, setup (const char *func_name, db_lookup_function lookup_fct,
void **fctp, service_user **nip, service_user **startp, int all) void **fctp, nss_action_list *nip, nss_action_list *startp, int all)
{ {
int no_more; int no_more;
if (*startp == NULL) if (*startp == NULL || all)
{ {
no_more = lookup_fct (nip, func_name, NULL, fctp); no_more = lookup_fct (nip, func_name, NULL, fctp);
*startp = no_more ? (service_user *) -1l : *nip; *startp = no_more ? (nss_action_list) -1l : *nip;
} }
else if (*startp == (service_user *) -1l) else if (*startp == (nss_action_list) -1l)
/* No services at all. */ /* No services at all. */
return 1; return 1;
else else
{ {
if (all || !*nip) if (!*nip)
/* Reset to the beginning of the service list. */ /* Reset to the beginning of the service list. */
*nip = *startp; *nip = *startp;
/* Look up the first function. */ /* Look up the first function. */
@ -49,8 +49,8 @@ setup (const char *func_name, db_lookup_function lookup_fct,
void void
__nss_setent (const char *func_name, db_lookup_function lookup_fct, __nss_setent (const char *func_name, db_lookup_function lookup_fct,
service_user **nip, service_user **startp, nss_action_list *nip, nss_action_list *startp,
service_user **last_nip, int stayopen, int *stayopen_tmp, nss_action_list *last_nip, int stayopen, int *stayopen_tmp,
int res) int res)
{ {
union union
@ -110,8 +110,8 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
void void
__nss_endent (const char *func_name, db_lookup_function lookup_fct, __nss_endent (const char *func_name, db_lookup_function lookup_fct,
service_user **nip, service_user **startp, nss_action_list *nip, nss_action_list *startp,
service_user **last_nip, int res) nss_action_list *last_nip, int res)
{ {
union union
{ {
@ -154,8 +154,8 @@ int
__nss_getent_r (const char *getent_func_name, __nss_getent_r (const char *getent_func_name,
const char *setent_func_name, const char *setent_func_name,
db_lookup_function lookup_fct, db_lookup_function lookup_fct,
service_user **nip, service_user **startp, nss_action_list *nip, nss_action_list *startp,
service_user **last_nip, int *stayopen_tmp, int res, nss_action_list *last_nip, int *stayopen_tmp, int res,
void *resbuf, char *buffer, size_t buflen, void *resbuf, char *buffer, size_t buflen,
void **result, int *h_errnop) void **result, int *h_errnop)
{ {

View file

@ -30,7 +30,7 @@
NSS_DECLARE_MODULE_FUNCTIONS (compat) NSS_DECLARE_MODULE_FUNCTIONS (compat)
static service_user *ni; static nss_action_list ni;
static enum nss_status (*setgrent_impl) (int stayopen); static enum nss_status (*setgrent_impl) (int stayopen);
static enum nss_status (*getgrnam_r_impl) (const char *name, static enum nss_status (*getgrnam_r_impl) (const char *name,
struct group * grp, char *buffer, struct group * grp, char *buffer,

View file

@ -33,7 +33,7 @@
NSS_DECLARE_MODULE_FUNCTIONS (compat) NSS_DECLARE_MODULE_FUNCTIONS (compat)
static service_user *ni; static nss_action_list ni;
static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t, static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t,
long int *, long int *, long int *, long int *,
gid_t **, long int, int *); gid_t **, long int, int *);

View file

@ -34,7 +34,7 @@
NSS_DECLARE_MODULE_FUNCTIONS (compat) NSS_DECLARE_MODULE_FUNCTIONS (compat)
static service_user *ni; static nss_action_list ni;
static enum nss_status (*setpwent_impl) (int stayopen); static enum nss_status (*setpwent_impl) (int stayopen);
static enum nss_status (*getpwnam_r_impl) (const char *name, static enum nss_status (*getpwnam_r_impl) (const char *name,
struct passwd * pwd, char *buffer, struct passwd * pwd, char *buffer,

View file

@ -34,7 +34,7 @@
NSS_DECLARE_MODULE_FUNCTIONS (compat) NSS_DECLARE_MODULE_FUNCTIONS (compat)
static service_user *ni; static nss_action_list ni;
static enum nss_status (*setspent_impl) (int stayopen); static enum nss_status (*setspent_impl) (int stayopen);
static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp, static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp,
char *buffer, size_t buflen, char *buffer, size_t buflen,

View file

@ -58,7 +58,7 @@ _res_hconf_init (void)
#undef USE_NSCD #undef USE_NSCD
#include "../sysdeps/posix/getaddrinfo.c" #include "../sysdeps/posix/getaddrinfo.c"
service_user *__nss_hosts_database attribute_hidden; nss_action_list __nss_hosts_database attribute_hidden;
/* This is the beginning of the real test code. The above defines /* This is the beginning of the real test code. The above defines
(among other things) the function rfc3484_sort. */ (among other things) the function rfc3484_sort. */

View file

@ -58,7 +58,7 @@ _res_hconf_init (void)
#undef USE_NSCD #undef USE_NSCD
#include "../sysdeps/posix/getaddrinfo.c" #include "../sysdeps/posix/getaddrinfo.c"
service_user *__nss_hosts_database attribute_hidden; nss_action_list __nss_hosts_database attribute_hidden;
/* This is the beginning of the real test code. The above defines /* This is the beginning of the real test code. The above defines
(among other things) the function rfc3484_sort. */ (among other things) the function rfc3484_sort. */

View file

@ -58,7 +58,7 @@ _res_hconf_init (void)
#undef USE_NSCD #undef USE_NSCD
#include "../sysdeps/posix/getaddrinfo.c" #include "../sysdeps/posix/getaddrinfo.c"
service_user *__nss_hosts_database attribute_hidden; nss_action_list __nss_hosts_database attribute_hidden;
/* This is the beginning of the real test code. The above defines /* This is the beginning of the real test code. The above defines
(among other things) the function rfc3484_sort. */ (among other things) the function rfc3484_sort. */

View file

@ -145,9 +145,7 @@ int
netname2user (const char *netname, uid_t * uidp, gid_t * gidp, netname2user (const char *netname, uid_t * uidp, gid_t * gidp,
int *gidlenp, gid_t * gidlist) int *gidlenp, gid_t * gidlist)
{ {
static service_user *startp; nss_action_list nip;
static netname2user_function start_fct;
service_user *nip;
union union
{ {
netname2user_function f; netname2user_function f;
@ -156,22 +154,7 @@ netname2user (const char *netname, uid_t * uidp, gid_t * gidp,
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more; int no_more;
if (startp == NULL) no_more = __nss_publickey_lookup2 (&nip, "netname2user", NULL, &fct.ptr);
{
no_more = __nss_publickey_lookup2 (&nip, "netname2user", NULL, &fct.ptr);
if (no_more)
startp = (service_user *) - 1;
else
{
startp = nip;
start_fct = fct.f;
}
}
else
{
fct.f = start_fct;
no_more = (nip = startp) == (service_user *) - 1;
}
while (!no_more) while (!no_more)
{ {

View file

@ -34,9 +34,7 @@ typedef int (*secret_function) (const char *, char *, const char *, int *);
int int
getpublickey (const char *name, char *key) getpublickey (const char *name, char *key)
{ {
static service_user *startp; nss_action_list nip;
static public_function start_fct;
service_user *nip;
union union
{ {
public_function f; public_function f;
@ -45,22 +43,7 @@ getpublickey (const char *name, char *key)
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more; int no_more;
if (startp == NULL) no_more = __nss_publickey_lookup2 (&nip, "getpublickey", NULL, &fct.ptr);
{
no_more = __nss_publickey_lookup2 (&nip, "getpublickey", NULL, &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
start_fct = fct.f;
}
}
else
{
fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (! no_more) while (! no_more)
{ {
@ -77,9 +60,7 @@ libc_hidden_nolink_sunrpc (getpublickey, GLIBC_2_0)
int int
getsecretkey (const char *name, char *key, const char *passwd) getsecretkey (const char *name, char *key, const char *passwd)
{ {
static service_user *startp; nss_action_list nip;
static secret_function start_fct;
service_user *nip;
union union
{ {
secret_function f; secret_function f;
@ -88,22 +69,7 @@ getsecretkey (const char *name, char *key, const char *passwd)
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more; int no_more;
if (startp == NULL) no_more = __nss_publickey_lookup2 (&nip, "getsecretkey", NULL, &fct.ptr);
{
no_more = __nss_publickey_lookup2 (&nip, "getsecretkey", NULL, &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
start_fct = fct.f;
}
}
else
{
fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (! no_more) while (! no_more)
{ {

View file

@ -307,7 +307,7 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
memory allocation failure. The returned string is allocated on the memory allocation failure. The returned string is allocated on the
heap; the caller has to free it. */ heap; the caller has to free it. */
static char * static char *
getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name) getcanonname (nss_action_list nip, struct gaih_addrtuple *at, const char *name)
{ {
nss_getcanonname_r *cfct = __nss_lookup_function (nip, "getcanonname_r"); nss_getcanonname_r *cfct = __nss_lookup_function (nip, "getcanonname_r");
char *s = (char *) name; char *s = (char *) name;
@ -538,7 +538,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
struct gaih_addrtuple **pat = &at; struct gaih_addrtuple **pat = &at;
int no_data = 0; int no_data = 0;
int no_inet6_data = 0; int no_inet6_data = 0;
service_user *nip; nss_action_list nip;
enum nss_status inet6_status = NSS_STATUS_UNAVAIL; enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
enum nss_status status = NSS_STATUS_UNAVAIL; enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more; int no_more;
@ -720,13 +720,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
} }
#endif #endif
if (__nss_hosts_database == NULL) no_more = __nss_database_lookup2 ("hosts", NULL,
no_more = __nss_database_lookup2 ("hosts", NULL, "dns [!UNAVAIL=return] files",
"dns [!UNAVAIL=return] files", &nip);
&__nss_hosts_database);
else
no_more = 0;
nip = __nss_hosts_database;
/* If we are looking for both IPv4 and IPv6 address we don't /* If we are looking for both IPv4 and IPv6 address we don't
want the lookup functions to automatically promote IPv4 want the lookup functions to automatically promote IPv4
@ -905,10 +901,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
if (nss_next_action (nip, status) == NSS_ACTION_RETURN) if (nss_next_action (nip, status) == NSS_ACTION_RETURN)
break; break;
if (nip->next == NULL) nip++;
if (nip->module == NULL)
no_more = -1; no_more = -1;
else
nip = nip->next;
} }
__resolv_context_put (res_ctx); __resolv_context_put (res_ctx);