nss_compat: Do not use nss_* names for function pointers

A future commit will use these names for types of functions
in NSS service modules.

Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
Florian Weimer 2020-02-12 11:30:06 +01:00
parent 9333498794
commit 8a92214150
4 changed files with 112 additions and 113 deletions

View File

@ -28,16 +28,16 @@
#include <kernel-features.h>
static service_user *ni;
static enum nss_status (*nss_setgrent) (int stayopen);
static enum nss_status (*nss_getgrnam_r) (const char *name,
static enum nss_status (*setgrent_impl) (int stayopen);
static enum nss_status (*getgrnam_r_impl) (const char *name,
struct group * grp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_getgrgid_r) (gid_t gid, struct group * grp,
static enum nss_status (*getgrgid_r_impl) (gid_t gid, struct group * grp,
char *buffer, size_t buflen,
int *errnop);
static enum nss_status (*nss_getgrent_r) (struct group * grp, char *buffer,
static enum nss_status (*getgrent_r_impl) (struct group * grp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_endgrent) (void);
static enum nss_status (*endgrent_impl) (void);
/* Get the declaration of the parser function. */
#define ENTNAME grent
@ -80,11 +80,11 @@ init_nss_interface (void)
{
if (__nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
{
nss_setgrent = __nss_lookup_function (ni, "setgrent");
nss_getgrnam_r = __nss_lookup_function (ni, "getgrnam_r");
nss_getgrgid_r = __nss_lookup_function (ni, "getgrgid_r");
nss_getgrent_r = __nss_lookup_function (ni, "getgrent_r");
nss_endgrent = __nss_lookup_function (ni, "endgrent");
setgrent_impl = __nss_lookup_function (ni, "setgrent");
getgrnam_r_impl = __nss_lookup_function (ni, "getgrnam_r");
getgrgid_r_impl = __nss_lookup_function (ni, "getgrgid_r");
getgrent_r_impl = __nss_lookup_function (ni, "getgrent_r");
endgrent_impl = __nss_lookup_function (ni, "endgrent");
}
}
@ -117,8 +117,8 @@ internal_setgrent (ent_t *ent, int stayopen, int needent)
else
rewind (ent->stream);
if (needent && status == NSS_STATUS_SUCCESS && nss_setgrent)
ent->setent_status = nss_setgrent (stayopen);
if (needent && status == NSS_STATUS_SUCCESS && setgrent_impl)
ent->setent_status = setgrent_impl (stayopen);
return status;
}
@ -170,8 +170,8 @@ _nss_compat_endgrent (void)
__libc_lock_lock (lock);
if (nss_endgrent)
nss_endgrent ();
if (endgrent_impl)
endgrent_impl ();
result = internal_endgrent (&ext_ent);
@ -185,7 +185,7 @@ static enum nss_status
getgrent_next_nss (struct group *result, ent_t *ent, char *buffer,
size_t buflen, int *errnop)
{
if (!nss_getgrent_r)
if (!getgrent_r_impl)
return NSS_STATUS_UNAVAIL;
/* If the setgrent call failed, say so. */
@ -196,7 +196,7 @@ getgrent_next_nss (struct group *result, ent_t *ent, char *buffer,
{
enum nss_status status;
if ((status = nss_getgrent_r (result, buffer, buflen, errnop))
if ((status = getgrent_r_impl (result, buffer, buflen, errnop))
!= NSS_STATUS_SUCCESS)
return status;
}
@ -210,10 +210,10 @@ static enum nss_status
getgrnam_plusgroup (const char *name, struct group *result, ent_t *ent,
char *buffer, size_t buflen, int *errnop)
{
if (!nss_getgrnam_r)
if (!getgrnam_r_impl)
return NSS_STATUS_UNAVAIL;
enum nss_status status = nss_getgrnam_r (name, result, buffer, buflen,
enum nss_status status = getgrnam_r_impl (name, result, buffer, buflen,
errnop);
if (status != NSS_STATUS_SUCCESS)
return status;
@ -578,11 +578,11 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent,
/* +:... */
if (result->gr_name[0] == '+' && result->gr_name[1] == '\0')
{
if (!nss_getgrgid_r)
if (!getgrgid_r_impl)
return NSS_STATUS_UNAVAIL;
enum nss_status status = nss_getgrgid_r (gid, result, buffer, buflen,
errnop);
enum nss_status status = getgrgid_r_impl (gid, result,
buffer, buflen, errnop);
if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
return NSS_STATUS_NOTFOUND;
else

View File

@ -31,20 +31,19 @@
#include <scratch_buffer.h>
static service_user *ni;
/* Type of the lookup function. */
static enum nss_status (*nss_initgroups_dyn) (const char *, gid_t,
static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t,
long int *, long int *,
gid_t **, long int, int *);
static enum nss_status (*nss_getgrnam_r) (const char *name,
static enum nss_status (*getgrnam_r_impl) (const char *name,
struct group * grp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_getgrgid_r) (gid_t gid, struct group * grp,
static enum nss_status (*getgrgid_r_impl) (gid_t gid, struct group * grp,
char *buffer, size_t buflen,
int *errnop);
static enum nss_status (*nss_setgrent) (int stayopen);
static enum nss_status (*nss_getgrent_r) (struct group * grp, char *buffer,
static enum nss_status (*setgrent_impl) (int stayopen);
static enum nss_status (*getgrent_r_impl) (struct group * grp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_endgrent) (void);
static enum nss_status (*endgrent_impl) (void);
/* Protect global state against multiple changers. */
__libc_lock_define_initialized (static, lock)
@ -91,12 +90,12 @@ init_nss_interface (void)
if (ni == NULL
&& __nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
{
nss_initgroups_dyn = __nss_lookup_function (ni, "initgroups_dyn");
nss_getgrnam_r = __nss_lookup_function (ni, "getgrnam_r");
nss_getgrgid_r = __nss_lookup_function (ni, "getgrgid_r");
nss_setgrent = __nss_lookup_function (ni, "setgrent");
nss_getgrent_r = __nss_lookup_function (ni, "getgrent_r");
nss_endgrent = __nss_lookup_function (ni, "endgrent");
initgroups_dyn_impl = __nss_lookup_function (ni, "initgroups_dyn");
getgrnam_r_impl = __nss_lookup_function (ni, "getgrnam_r");
getgrgid_r_impl = __nss_lookup_function (ni, "getgrgid_r");
setgrent_impl = __nss_lookup_function (ni, "setgrent");
getgrent_r_impl = __nss_lookup_function (ni, "getgrent_r");
endgrent_impl = __nss_lookup_function (ni, "endgrent");
}
__libc_lock_unlock (lock);
@ -151,8 +150,8 @@ internal_endgrent (ent_t *ent)
else
ent->blacklist.current = 0;
if (ent->need_endgrent && nss_endgrent != NULL)
nss_endgrent ();
if (ent->need_endgrent && endgrent_impl != NULL)
endgrent_impl ();
return NSS_STATUS_SUCCESS;
}
@ -244,7 +243,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
getgrent_r through the whole group database. But for large
group databases this is faster, since the user can only be
in a limited number of groups. */
if (nss_initgroups_dyn (user, group, &mystart, &mysize, &mygroups,
if (initgroups_dyn_impl (user, group, &mystart, &mysize, &mygroups,
limit, errnop) == NSS_STATUS_SUCCESS)
{
status = NSS_STATUS_NOTFOUND;
@ -264,7 +263,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
for (int i = 0; i < mystart; i++)
{
while ((status = nss_getgrgid_r (mygroups[i], &grpbuf,
while ((status = getgrgid_r_impl (mygroups[i], &grpbuf,
tmpbuf, tmplen, errnop))
== NSS_STATUS_TRYAGAIN
&& *errnop == ERANGE)
@ -301,9 +300,9 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
&& check_and_add_group (user, group, start, size,
groupsp, limit, &grpbuf))
{
if (nss_setgrent != NULL)
if (setgrent_impl != NULL)
{
nss_setgrent (1);
setgrent_impl (1);
ent->need_endgrent = true;
}
ent->skip_initgroups_dyn = true;
@ -334,7 +333,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
iter:
do
{
if ((status = nss_getgrent_r (&grpbuf, buffer, buflen, errnop))
if ((status = getgrent_r_impl (&grpbuf, buffer, buflen, errnop))
!= NSS_STATUS_SUCCESS)
break;
}
@ -426,9 +425,9 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user,
/* Store the group in the blacklist for the "+" at the end of
/etc/group */
blacklist_store_name (&grpbuf.gr_name[1], ent);
if (nss_getgrnam_r == NULL)
if (getgrnam_r_impl == NULL)
return NSS_STATUS_UNAVAIL;
else if (nss_getgrnam_r (&grpbuf.gr_name[1], &grpbuf, buffer,
else if (getgrnam_r_impl (&grpbuf.gr_name[1], &grpbuf, buffer,
buflen, errnop) != NSS_STATUS_SUCCESS)
continue;
@ -444,16 +443,16 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user,
/* If the selected module does not support getgrent_r or
initgroups_dyn, abort. We cannot find the needed group
entries. */
if (nss_initgroups_dyn == NULL || nss_getgrgid_r == NULL)
if (initgroups_dyn_impl == NULL || getgrgid_r_impl == NULL)
{
if (nss_setgrent != NULL)
if (setgrent_impl != NULL)
{
nss_setgrent (1);
setgrent_impl (1);
ent->need_endgrent = true;
}
ent->skip_initgroups_dyn = true;
if (nss_getgrent_r == NULL)
if (getgrent_r_impl == NULL)
return NSS_STATUS_UNAVAIL;
}

View File

@ -32,16 +32,16 @@
#include "nisdomain.h"
static service_user *ni;
static enum nss_status (*nss_setpwent) (int stayopen);
static enum nss_status (*nss_getpwnam_r) (const char *name,
static enum nss_status (*setpwent_impl) (int stayopen);
static enum nss_status (*getpwnam_r_impl) (const char *name,
struct passwd * pwd, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_getpwuid_r) (uid_t uid, struct passwd * pwd,
static enum nss_status (*getpwuid_r_impl) (uid_t uid, struct passwd * pwd,
char *buffer, size_t buflen,
int *errnop);
static enum nss_status (*nss_getpwent_r) (struct passwd * pwd, char *buffer,
static enum nss_status (*getpwent_r_impl) (struct passwd * pwd, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_endpwent) (void);
static enum nss_status (*endpwent_impl) (void);
/* Get the declaration of the parser function. */
#define ENTNAME pwent
@ -90,11 +90,11 @@ init_nss_interface (void)
{
if (__nss_database_lookup2 ("passwd_compat", NULL, "nis", &ni) >= 0)
{
nss_setpwent = __nss_lookup_function (ni, "setpwent");
nss_getpwnam_r = __nss_lookup_function (ni, "getpwnam_r");
nss_getpwuid_r = __nss_lookup_function (ni, "getpwuid_r");
nss_getpwent_r = __nss_lookup_function (ni, "getpwent_r");
nss_endpwent = __nss_lookup_function (ni, "endpwent");
setpwent_impl = __nss_lookup_function (ni, "setpwent");
getpwnam_r_impl = __nss_lookup_function (ni, "getpwnam_r");
getpwuid_r_impl = __nss_lookup_function (ni, "getpwuid_r");
getpwent_r_impl = __nss_lookup_function (ni, "getpwent_r");
endpwent_impl = __nss_lookup_function (ni, "endpwent");
}
}
@ -234,8 +234,8 @@ internal_setpwent (ent_t *ent, int stayopen, int needent)
give_pwd_free (&ent->pwd);
if (needent && status == NSS_STATUS_SUCCESS && nss_setpwent)
ent->setent_status = nss_setpwent (stayopen);
if (needent && status == NSS_STATUS_SUCCESS && setpwent_impl)
ent->setent_status = setpwent_impl (stayopen);
return status;
}
@ -294,8 +294,8 @@ _nss_compat_endpwent (void)
__libc_lock_lock (lock);
if (nss_endpwent)
nss_endpwent ();
if (endpwent_impl)
endpwent_impl ();
result = internal_endpwent (&ext_ent);
@ -316,7 +316,7 @@ getpwent_next_nss_netgr (const char *name, struct passwd *result, ent_t *ent,
/* Leave function if NSS module does not support getpwnam_r,
we need this function here. */
if (!nss_getpwnam_r)
if (!getpwnam_r_impl)
return NSS_STATUS_UNAVAIL;
if (ent->first)
@ -370,7 +370,7 @@ getpwent_next_nss_netgr (const char *name, struct passwd *result, ent_t *ent,
p2 = buffer + (buflen - p2len);
buflen -= p2len;
if (nss_getpwnam_r (user, result, buffer, buflen, errnop)
if (getpwnam_r_impl (user, result, buffer, buflen, errnop)
!= NSS_STATUS_SUCCESS)
continue;
@ -397,7 +397,7 @@ getpwent_next_nss (struct passwd *result, ent_t *ent, char *buffer,
size_t p2len;
/* Return if NSS module does not support getpwent_r. */
if (!nss_getpwent_r)
if (!getpwent_r_impl)
return NSS_STATUS_UNAVAIL;
/* If the setpwent call failed, say so. */
@ -418,7 +418,7 @@ getpwent_next_nss (struct passwd *result, ent_t *ent, char *buffer,
do
{
if ((status = nss_getpwent_r (result, buffer, buflen, errnop))
if ((status = getpwent_r_impl (result, buffer, buflen, errnop))
!= NSS_STATUS_SUCCESS)
return status;
}
@ -434,7 +434,7 @@ static enum nss_status
getpwnam_plususer (const char *name, struct passwd *result, ent_t *ent,
char *buffer, size_t buflen, int *errnop)
{
if (!nss_getpwnam_r)
if (!getpwnam_r_impl)
return NSS_STATUS_UNAVAIL;
struct passwd pwd;
@ -451,7 +451,7 @@ getpwnam_plususer (const char *name, struct passwd *result, ent_t *ent,
char *p = buffer + (buflen - plen);
buflen -= plen;
enum nss_status status = nss_getpwnam_r (name, result, buffer, buflen,
enum nss_status status = getpwnam_r_impl (name, result, buffer, buflen,
errnop);
if (status != NSS_STATUS_SUCCESS)
return status;
@ -836,7 +836,7 @@ getpwuid_plususer (uid_t uid, struct passwd *result, char *buffer,
char *p;
size_t plen;
if (!nss_getpwuid_r)
if (!getpwuid_r_impl)
return NSS_STATUS_UNAVAIL;
memset (&pwd, '\0', sizeof (struct passwd));
@ -852,7 +852,7 @@ getpwuid_plususer (uid_t uid, struct passwd *result, char *buffer,
p = buffer + (buflen - plen);
buflen -= plen;
if (nss_getpwuid_r (uid, result, buffer, buflen, errnop) ==
if (getpwuid_r_impl (uid, result, buffer, buflen, errnop) ==
NSS_STATUS_SUCCESS)
{
copy_pwd_changes (result, &pwd, p, plen);

View File

@ -32,13 +32,13 @@
#include "nisdomain.h"
static service_user *ni;
static enum nss_status (*nss_setspent) (int stayopen);
static enum nss_status (*nss_getspnam_r) (const char *name, struct spwd * sp,
static enum nss_status (*setspent_impl) (int stayopen);
static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp,
char *buffer, size_t buflen,
int *errnop);
static enum nss_status (*nss_getspent_r) (struct spwd * sp, char *buffer,
static enum nss_status (*getspent_r_impl) (struct spwd * sp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_endspent) (void);
static enum nss_status (*endspent_impl) (void);
/* Get the declaration of the parser function. */
#define ENTNAME spent
@ -88,10 +88,10 @@ init_nss_interface (void)
if (__nss_database_lookup2 ("shadow_compat", "passwd_compat",
"nis", &ni) >= 0)
{
nss_setspent = __nss_lookup_function (ni, "setspent");
nss_getspnam_r = __nss_lookup_function (ni, "getspnam_r");
nss_getspent_r = __nss_lookup_function (ni, "getspent_r");
nss_endspent = __nss_lookup_function (ni, "endspent");
setspent_impl = __nss_lookup_function (ni, "setspent");
getspnam_r_impl = __nss_lookup_function (ni, "getspnam_r");
getspent_r_impl = __nss_lookup_function (ni, "getspent_r");
endspent_impl = __nss_lookup_function (ni, "endspent");
}
}
@ -190,8 +190,8 @@ internal_setspent (ent_t *ent, int stayopen, int needent)
give_spwd_free (&ent->pwd);
if (needent && status == NSS_STATUS_SUCCESS && nss_setspent)
ent->setent_status = nss_setspent (stayopen);
if (needent && status == NSS_STATUS_SUCCESS && setspent_impl)
ent->setent_status = setspent_impl (stayopen);
return status;
}
@ -251,8 +251,8 @@ _nss_compat_endspent (void)
__libc_lock_lock (lock);
if (nss_endspent)
nss_endspent ();
if (endspent_impl)
endspent_impl ();
result = internal_endspent (&ext_ent);
@ -270,7 +270,7 @@ getspent_next_nss_netgr (const char *name, struct spwd *result, ent_t *ent,
char *curdomain = NULL, *host, *user, *domain, *p2;
size_t p2len;
if (!nss_getspnam_r)
if (!getspnam_r_impl)
return NSS_STATUS_UNAVAIL;
/* If the setpwent call failed, say so. */
@ -330,7 +330,7 @@ getspent_next_nss_netgr (const char *name, struct spwd *result, ent_t *ent,
p2 = buffer + (buflen - p2len);
buflen -= p2len;
if (nss_getspnam_r (user, result, buffer, buflen, errnop)
if (getspnam_r_impl (user, result, buffer, buflen, errnop)
!= NSS_STATUS_SUCCESS)
continue;
@ -356,7 +356,7 @@ getspent_next_nss (struct spwd *result, ent_t *ent,
char *p2;
size_t p2len;
if (!nss_getspent_r)
if (!getspent_r_impl)
return NSS_STATUS_UNAVAIL;
p2len = spwd_need_buflen (&ent->pwd);
@ -369,7 +369,7 @@ getspent_next_nss (struct spwd *result, ent_t *ent,
buflen -= p2len;
do
{
if ((status = nss_getspent_r (result, buffer, buflen, errnop))
if ((status = getspent_r_impl (result, buffer, buflen, errnop))
!= NSS_STATUS_SUCCESS)
return status;
}
@ -386,7 +386,7 @@ static enum nss_status
getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
char *buffer, size_t buflen, int *errnop)
{
if (!nss_getspnam_r)
if (!getspnam_r_impl)
return NSS_STATUS_UNAVAIL;
struct spwd pwd;
@ -407,7 +407,7 @@ getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
char *p = buffer + (buflen - plen);
buflen -= plen;
enum nss_status status = nss_getspnam_r (name, result, buffer, buflen,
enum nss_status status = getspnam_r_impl (name, result, buffer, buflen,
errnop);
if (status != NSS_STATUS_SUCCESS)
return status;