* [PATCH 0/7] More type safety for NSS modules
@ 2020-02-12 14:34 Florian Weimer
2020-02-12 14:34 ` [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers Florian Weimer
` (8 more replies)
0 siblings, 9 replies; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
This series adds a macro NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h>.
Module authors can use this macro to declare all the possible functions
for a module, and define only the function they need. This avoids type
mismatches in these interfaces.
As a side effect, we now have what is hopefully a complete list of all
such module functions. This should help with re-architecting the
internal NSS functions for nsswitch.conf reloading.
Thanks,
Florian
Florian Weimer (7):
nss_compat: Do not use nss_* names for function pointers
nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to
<nss.h>
nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS
nss_compat: Use NSS_DECLARE_MODULE_FUNCTIONS
nss_db: Use NSS_DECLARE_MODULE_FUNCTIONS
nss_files: Use NSS_DECLARE_MODULE_FUNCTIONS
nss_dns: Use NSS_DECLARE_MODULE_FUNCTIONS
hesiod/nss_hesiod/hesiod-grp.c | 2 +
hesiod/nss_hesiod/hesiod-proto.c | 2 +
hesiod/nss_hesiod/hesiod-pwd.c | 2 +
hesiod/nss_hesiod/hesiod-service.c | 2 +
nscd/aicache.c | 23 +---
nss/nss.h | 203 ++++++++++++++++++++++++++++-
nss/nss_compat/compat-grp.c | 56 ++++----
nss/nss_compat/compat-initgroups.c | 73 ++++++-----
nss/nss_compat/compat-pwd.c | 58 +++++----
nss/nss_compat/compat-spwd.c | 46 +++----
nss/nss_db/db-init.c | 2 +
nss/nss_db/db-initgroups.c | 1 -
nss/nss_db/nss_db.h | 1 +
nss/nss_files/files-alias.c | 2 +
nss/nss_files/files-ethers.c | 3 +
nss/nss_files/files-grp.c | 3 +
nss/nss_files/files-hosts.c | 2 +
nss/nss_files/files-init.c | 3 +
nss/nss_files/files-initgroups.c | 3 +
nss/nss_files/files-key.c | 2 +
nss/nss_files/files-netgrp.c | 2 +
nss/nss_files/files-network.c | 3 +
nss/nss_files/files-proto.c | 2 +
nss/nss_files/files-pwd.c | 3 +
nss/nss_files/files-rpc.c | 2 +
nss/nss_files/files-service.c | 2 +
nss/nss_files/files-sgrp.c | 3 +
nss/nss_files/files-spwd.c | 3 +
resolv/nss_dns/dns-canon.c | 2 +
resolv/nss_dns/dns-host.c | 2 +
resolv/nss_dns/dns-network.c | 2 +
sysdeps/posix/getaddrinfo.c | 18 +--
32 files changed, 384 insertions(+), 149 deletions(-)
--
2.24.1
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-12 22:36 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h> Florian Weimer
` (7 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
A future commit will use these names for types of functions
in NSS service modules.
---
nss/nss_compat/compat-grp.c | 54 +++++++++++------------
nss/nss_compat/compat-initgroups.c | 71 +++++++++++++++---------------
nss/nss_compat/compat-pwd.c | 56 +++++++++++------------
nss/nss_compat/compat-spwd.c | 44 +++++++++---------
4 files changed, 112 insertions(+), 113 deletions(-)
diff --git a/nss/nss_compat/compat-grp.c b/nss/nss_compat/compat-grp.c
index a8de1e03b3..561511c91a 100644
--- a/nss/nss_compat/compat-grp.c
+++ b/nss/nss_compat/compat-grp.c
@@ -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,
- struct group * grp, char *buffer,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_getgrgid_r) (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,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_endgrent) (void);
+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 (*getgrgid_r_impl) (gid_t gid, struct group * grp,
+ char *buffer, size_t buflen,
+ int *errnop);
+static enum nss_status (*getgrent_r_impl) (struct group * grp, char *buffer,
+ size_t buflen, int *errnop);
+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,11 +210,11 @@ 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,
- errnop);
+ 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
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
index 939b25b33b..d2a280d9c3 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -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,
- long int *, long int *,
- gid_t **, long int, int *);
-static enum nss_status (*nss_getgrnam_r) (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,
- 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,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_endgrent) (void);
+static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t,
+ long int *, long int *,
+ gid_t **, long int, int *);
+static enum nss_status (*getgrnam_r_impl) (const char *name,
+ struct group * grp, char *buffer,
+ size_t buflen, int *errnop);
+static enum nss_status (*getgrgid_r_impl) (gid_t gid, struct group * grp,
+ char *buffer, size_t buflen,
+ int *errnop);
+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 (*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,8 +243,8 @@ 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,
- limit, errnop) == NSS_STATUS_SUCCESS)
+ if (initgroups_dyn_impl (user, group, &mystart, &mysize, &mygroups,
+ limit, errnop) == NSS_STATUS_SUCCESS)
{
status = NSS_STATUS_NOTFOUND;
@@ -264,8 +263,8 @@ 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,
- tmpbuf, tmplen, errnop))
+ 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,10 +425,10 @@ 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,
- buflen, errnop) != NSS_STATUS_SUCCESS)
+ else if (getgrnam_r_impl (&grpbuf.gr_name[1], &grpbuf, buffer,
+ buflen, errnop) != NSS_STATUS_SUCCESS)
continue;
check_and_add_group (user, group, start, size, groupsp,
@@ -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;
}
diff --git a/nss/nss_compat/compat-pwd.c b/nss/nss_compat/compat-pwd.c
index ec3f35c594..b964e6f644 100644
--- a/nss/nss_compat/compat-pwd.c
+++ b/nss/nss_compat/compat-pwd.c
@@ -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,
- struct passwd * pwd, char *buffer,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_getpwuid_r) (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,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_endpwent) (void);
+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 (*getpwuid_r_impl) (uid_t uid, struct passwd * pwd,
+ char *buffer, size_t buflen,
+ int *errnop);
+static enum nss_status (*getpwent_r_impl) (struct passwd * pwd, char *buffer,
+ size_t buflen, int *errnop);
+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,8 +451,8 @@ 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,
- errnop);
+ 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);
diff --git a/nss/nss_compat/compat-spwd.c b/nss/nss_compat/compat-spwd.c
index f6b7a1ef15..15f5b95bb0 100644
--- a/nss/nss_compat/compat-spwd.c
+++ b/nss/nss_compat/compat-spwd.c
@@ -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,
- char *buffer, size_t buflen,
- int *errnop);
-static enum nss_status (*nss_getspent_r) (struct spwd * sp, char *buffer,
- size_t buflen, int *errnop);
-static enum nss_status (*nss_endspent) (void);
+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 (*getspent_r_impl) (struct spwd * sp, char *buffer,
+ size_t buflen, int *errnop);
+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,8 +407,8 @@ 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,
- errnop);
+ enum nss_status status = getspnam_r_impl (name, result, buffer, buflen,
+ errnop);
if (status != NSS_STATUS_SUCCESS)
return status;
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h>
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
2020-02-12 14:34 ` [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:10 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS Florian Weimer
` (6 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
This macro allows to add type safety to the implementation of NSS
service modules.
---
nscd/aicache.c | 23 +---
nss/nss.h | 203 +++++++++++++++++++++++++++++++++++-
sysdeps/posix/getaddrinfo.c | 18 +---
3 files changed, 209 insertions(+), 35 deletions(-)
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 46db40fceb..ee9c9b8843 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -33,19 +33,6 @@
#include "nscd.h"
-typedef enum nss_status (*nss_gethostbyname4_r)
- (const char *name, struct gaih_addrtuple **pat,
- char *buffer, size_t buflen, int *errnop,
- int *h_errnop, int32_t *ttlp);
-typedef enum nss_status (*nss_gethostbyname3_r)
- (const char *name, int af, struct hostent *host,
- char *buffer, size_t buflen, int *errnop,
- int *h_errnop, int32_t *, char **);
-typedef enum nss_status (*nss_getcanonname_r)
- (const char *name, char *buffer, size_t buflen, char **result,
- int *errnop, int *h_errnop);
-
-
static const ai_response_header notfound =
{
.version = NSCD_VERSION,
@@ -127,8 +114,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
char *canon = NULL;
size_t canonlen;
- nss_gethostbyname4_r fct4 = __nss_lookup_function (nip,
- "gethostbyname4_r");
+ nss_gethostbyname4_r *fct4 = __nss_lookup_function (nip,
+ "gethostbyname4_r");
if (fct4 != NULL)
{
struct gaih_addrtuple atmem;
@@ -212,8 +199,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
{
/* Prefer the function which also returns the TTL and
canonical name. */
- nss_gethostbyname3_r fct = __nss_lookup_function (nip,
- "gethostbyname3_r");
+ nss_gethostbyname3_r *fct
+ = __nss_lookup_function (nip, "gethostbyname3_r");
if (fct == NULL)
fct = __nss_lookup_function (nip, "gethostbyname2_r");
@@ -279,7 +266,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
if (canon == NULL)
{
/* Determine the canonical name. */
- nss_getcanonname_r cfct;
+ nss_getcanonname_r *cfct;
cfct = __nss_lookup_function (nip, "getcanonname_r");
if (cfct != NULL)
{
diff --git a/nss/nss.h b/nss/nss.h
index 390ea34aaf..80422975e5 100644
--- a/nss/nss.h
+++ b/nss/nss.h
@@ -19,10 +19,12 @@
and for implementors of new services. */
#ifndef _NSS_H
-#define _NSS_H 1
+#define _NSS_H 1
#include <features.h>
+#include <stddef.h>
#include <stdint.h>
+#include <sys/types.h>
__BEGIN_DECLS
@@ -56,7 +58,204 @@ struct gaih_addrtuple
Attention: Using this function repeatedly will slowly eat up the
whole memory since previous selection data cannot be freed. */
extern int __nss_configure_lookup (const char *__dbname,
- const char *__string) __THROW;
+ const char *__string) __THROW;
+
+/* NSS-related types. */
+struct __netgrent;
+struct aliasent;
+struct ether_addr;
+struct etherent;
+struct group;
+struct hostent;
+struct netent;
+struct passwd;
+struct protoent;
+struct rpcent;
+struct servent;
+struct sgrp;
+struct spwd;
+struct traced_file;
+
+/* Types of functions exported from NSS service modules. */
+typedef enum nss_status nss_endaliasent (void);
+typedef enum nss_status nss_endetherent (void);
+typedef enum nss_status nss_endgrent (void);
+typedef enum nss_status nss_endhostent (void);
+typedef enum nss_status nss_endnetent (void);
+typedef enum nss_status nss_endnetgrent (struct __netgrent *);
+typedef enum nss_status nss_endprotoent (void);
+typedef enum nss_status nss_endpwent (void);
+typedef enum nss_status nss_endrpcent (void);
+typedef enum nss_status nss_endservent (void);
+typedef enum nss_status nss_endsgent (void);
+typedef enum nss_status nss_endspent (void);
+typedef enum nss_status nss_getaliasbyname_r (const char *, struct aliasent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getaliasent_r (struct aliasent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getcanonname_r (const char *, char *, size_t,
+ char **, int *, int *);
+typedef enum nss_status nss_getetherent_r (struct etherent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getgrent_r (struct group *, char *, size_t, int *);
+typedef enum nss_status nss_getgrgid_r (__gid_t, struct group *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getgrnam_r (const char *, struct group *,
+ char *, size_t, int *);
+typedef enum nss_status nss_gethostbyaddr2_r (const void *, __socklen_t, int,
+ struct hostent *, char *, size_t,
+ int *, int *, int32_t *);
+typedef enum nss_status nss_gethostbyaddr_r (const void *, __socklen_t, int,
+ struct hostent *, char *, size_t,
+ int *, int *);
+typedef enum nss_status nss_gethostbyname2_r (const char *, int,
+ struct hostent *, char *, size_t,
+ int *, int *);
+typedef enum nss_status nss_gethostbyname3_r (const char *, int,
+ struct hostent *, char *, size_t,
+ int *, int *, int32_t *,
+ char **);
+typedef enum nss_status nss_gethostbyname4_r (const char *,
+ struct gaih_addrtuple **,
+ char *, size_t,
+ int *, int *, int32_t *);
+typedef enum nss_status nss_gethostbyname_r (const char *, struct hostent *,
+ char *, size_t, int *, int *);
+typedef enum nss_status nss_gethostent_r (struct hostent *, char *, size_t,
+ int *, int *);
+typedef enum nss_status nss_gethostton_r (const char *, struct etherent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getnetbyaddr_r (uint32_t, int, struct netent *,
+ char *, size_t, int *, int *);
+typedef enum nss_status nss_getnetbyname_r (const char *, struct netent *,
+ char *, size_t, int *, int *);
+typedef enum nss_status nss_getnetent_r (struct netent *,
+ char *, size_t, int *, int *);
+typedef enum nss_status nss_getnetgrent_r (struct __netgrent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getntohost_r (const struct ether_addr *,
+ struct etherent *, char *, size_t,
+ int *);
+typedef enum nss_status nss_getprotobyname_r (const char *, struct protoent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getprotobynumber_r (int, struct protoent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getprotoent_r (struct protoent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getpublickey (const char *, char *, int *);
+typedef enum nss_status nss_getpwent_r (struct passwd *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getpwnam_r (const char *, struct passwd *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getpwuid_r (__uid_t, struct passwd *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getrpcbyname_r (const char *, struct rpcent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getrpcbynumber_r (int, struct rpcent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getrpcent_r (struct rpcent *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getsecretkey (const char *, char *, char *, int *);
+typedef enum nss_status nss_getservbyname_r (const char *, const char *,
+ struct servent *, char *, size_t,
+ int *);
+typedef enum nss_status nss_getservbyport_r (int, const char *,
+ struct servent *, char *, size_t,
+ int *);
+typedef enum nss_status nss_getservent_r (struct servent *, char *, size_t,
+ int *);
+typedef enum nss_status nss_getsgent_r (struct sgrp *, char *, size_t, int *);
+typedef enum nss_status nss_getsgnam_r (const char *, struct sgrp *,
+ char *, size_t, int *);
+typedef enum nss_status nss_getspent_r (struct spwd *, char *, size_t, int *);
+typedef enum nss_status nss_getspnam_r (const char *, struct spwd *,
+ char *, size_t, int *);
+typedef void nss_init (void (*) (size_t, struct traced_file *));
+typedef enum nss_status nss_initgroups_dyn (const char *, __gid_t, long int *,
+ long int *, __gid_t **, long int,
+ int *);
+typedef enum nss_status nss_netname2user (char [], __uid_t *, __gid_t *,
+ int *, __gid_t *, int *);
+typedef enum nss_status nss_setaliasent (void);
+typedef enum nss_status nss_setetherent (int);
+typedef enum nss_status nss_setgrent (int);
+typedef enum nss_status nss_sethostent (int);
+typedef enum nss_status nss_setnetent (int);
+typedef enum nss_status nss_setnetgrent (const char *, struct __netgrent *);
+typedef enum nss_status nss_setprotoent (int);
+typedef enum nss_status nss_setpwent (int);
+typedef enum nss_status nss_setrpcent (int);
+typedef enum nss_status nss_setservent (int);
+typedef enum nss_status nss_setsgent (int);
+typedef enum nss_status nss_setspent (int);
+
+/* Declare all NSS functions for MODULE. */
+#define NSS_DECLARE_MODULE_FUNCTIONS(module) \
+ extern nss_endaliasent _nss_##module##_endaliasent; \
+ extern nss_endetherent _nss_##module##_endetherent; \
+ extern nss_endgrent _nss_##module##_endgrent; \
+ extern nss_endhostent _nss_##module##_endhostent; \
+ extern nss_endnetent _nss_##module##_endnetent; \
+ extern nss_endnetgrent _nss_##module##__endnetgrent; \
+ extern nss_endprotoent _nss_##module##_endprotoent; \
+ extern nss_endpwent _nss_##module##_endpwent; \
+ extern nss_endrpcent _nss_##module##_endrpcent; \
+ extern nss_endservent _nss_##module##_endservent; \
+ extern nss_endsgent _nss_##module##_endsgent; \
+ extern nss_endspent _nss_##module##_endspent; \
+ extern nss_getaliasbyname_r _nss_##module##_getaliasbyname_r; \
+ extern nss_getaliasent_r _nss_##module##_getaliasent_r; \
+ extern nss_getcanonname_r _nss_##module##_getcanonname_r; \
+ extern nss_getetherent_r _nss_##module##_getetherent_r; \
+ extern nss_getgrent_r _nss_##module##_getgrent_r; \
+ extern nss_getgrgid_r _nss_##module##_getgrgid_r; \
+ extern nss_getgrnam_r _nss_##module##_getgrnam_r; \
+ extern nss_gethostbyaddr2_r _nss_##module##_gethostbyaddr2_r; \
+ extern nss_gethostbyaddr_r _nss_##module##_gethostbyaddr_r; \
+ extern nss_gethostbyname2_r _nss_##module##_gethostbyname2_r; \
+ extern nss_gethostbyname3_r _nss_##module##_gethostbyname3_r; \
+ extern nss_gethostbyname4_r _nss_##module##_gethostbyname4_r; \
+ extern nss_gethostbyname_r _nss_##module##_gethostbyname_r; \
+ extern nss_gethostent_r _nss_##module##_gethostent_r; \
+ extern nss_gethostton_r _nss_##module##_gethostton_r; \
+ extern nss_getnetbyaddr_r _nss_##module##_getnetbyaddr_r; \
+ extern nss_getnetbyname_r _nss_##module##_getnetbyname_r; \
+ extern nss_getnetent_r _nss_##module##_getnetent_r; \
+ extern nss_getnetgrent_r _nss_##module##_getnetgrent_r; \
+ extern nss_getntohost_r _nss_##module##_getntohost_r; \
+ extern nss_getprotobyname_r _nss_##module##_getprotobyname_r; \
+ extern nss_getprotobynumber_r _nss_##module##_getprotobynumber_r; \
+ extern nss_getprotoent_r _nss_##module##_getprotoent_r; \
+ extern nss_getpublickey _nss_##module##_getpublickey; \
+ extern nss_getpwent_r _nss_##module##_getpwent_r; \
+ extern nss_getpwnam_r _nss_##module##_getpwnam_r; \
+ extern nss_getpwuid_r _nss_##module##_getpwuid_r; \
+ extern nss_getrpcbyname_r _nss_##module##_getrpcbyname_r; \
+ extern nss_getrpcbynumber_r _nss_##module##_getrpcbynumber_r; \
+ extern nss_getrpcent_r _nss_##module##_getrpcent_r; \
+ extern nss_getsecretkey _nss_##module##_getsecretkey; \
+ extern nss_getservbyname_r _nss_##module##_getservbyname_r; \
+ extern nss_getservbyport_r _nss_##module##_getservbyport_r; \
+ extern nss_getservent_r _nss_##module##_getservent_r; \
+ extern nss_getsgent_r _nss_##module##_getsgent_r; \
+ extern nss_getsgnam_r _nss_##module##_getsgnam_r; \
+ extern nss_getspent_r _nss_##module##_getspent_r; \
+ extern nss_getspnam_r _nss_##module##_getspnam_r; \
+ extern nss_init _nss_##module##_init; \
+ extern nss_initgroups_dyn _nss_##module##_initgroups_dyn; \
+ extern nss_netname2user _nss_##module##_netname2user; \
+ extern nss_setaliasent _nss_##module##_setaliasent; \
+ extern nss_setetherent _nss_##module##_setetherent; \
+ extern nss_setgrent _nss_##module##_setgrent; \
+ extern nss_sethostent _nss_##module##_sethostent; \
+ extern nss_setnetent _nss_##module##_setnetent; \
+ extern nss_setnetgrent _nss_##module##_setnetgrent; \
+ extern nss_setprotoent _nss_##module##_setprotoent; \
+ extern nss_setpwent _nss_##module##_setpwent; \
+ extern nss_setrpcent _nss_##module##_setrpcent; \
+ extern nss_setservent _nss_##module##_setservent; \
+ extern nss_setsgent _nss_##module##_setsgent; \
+ extern nss_setspent _nss_##module##_setspent; \
__END_DECLS
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 538691a598..ed04e564f9 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -300,18 +300,6 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
}
-typedef enum nss_status (*nss_gethostbyname4_r)
- (const char *name, struct gaih_addrtuple **pat,
- char *buffer, size_t buflen, int *errnop,
- int *h_errnop, int32_t *ttlp);
-typedef enum nss_status (*nss_gethostbyname3_r)
- (const char *name, int af, struct hostent *host,
- char *buffer, size_t buflen, int *errnop,
- int *h_errnop, int32_t *ttlp, char **canonp);
-typedef enum nss_status (*nss_getcanonname_r)
- (const char *name, char *buffer, size_t buflen, char **result,
- int *errnop, int *h_errnop);
-
/* This function is called if a canonical name is requested, but if
the service function did not provide it. It tries to obtain the
name using getcanonname_r from the same service NIP. If the name
@@ -321,7 +309,7 @@ typedef enum nss_status (*nss_getcanonname_r)
static char *
getcanonname (service_user *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;
if (cfct != NULL)
{
@@ -751,7 +739,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
while (!no_more)
{
no_data = 0;
- nss_gethostbyname4_r fct4 = NULL;
+ nss_gethostbyname4_r *fct4 = NULL;
/* gethostbyname4_r sends out parallel A and AAAA queries and
is thus only suitable for PF_UNSPEC. */
@@ -827,7 +815,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
}
else
{
- nss_gethostbyname3_r fct = NULL;
+ nss_gethostbyname3_r *fct = NULL;
if (req->ai_flags & AI_CANONNAME)
/* No need to use this function if we do not look for
the canonical name. The function does not exist in
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
2020-02-12 14:34 ` [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers Florian Weimer
2020-02-12 14:34 ` [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h> Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:11 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 4/7] nss_compat: " Florian Weimer
` (5 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
---
hesiod/nss_hesiod/hesiod-grp.c | 2 ++
hesiod/nss_hesiod/hesiod-proto.c | 2 ++
hesiod/nss_hesiod/hesiod-pwd.c | 2 ++
hesiod/nss_hesiod/hesiod-service.c | 2 ++
4 files changed, 8 insertions(+)
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
index c6d02247b7..158d4f02d8 100644
--- a/hesiod/nss_hesiod/hesiod-grp.c
+++ b/hesiod/nss_hesiod/hesiod-grp.c
@@ -26,6 +26,8 @@
#include <string.h>
#include <sys/param.h>
+NSS_DECLARE_MODULE_FUNCTIONS (hesiod)
+
/* Get the declaration of the parser function. */
#define ENTNAME grent
#define STRUCTURE group
diff --git a/hesiod/nss_hesiod/hesiod-proto.c b/hesiod/nss_hesiod/hesiod-proto.c
index d317fb71df..03f4fa2131 100644
--- a/hesiod/nss_hesiod/hesiod-proto.c
+++ b/hesiod/nss_hesiod/hesiod-proto.c
@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
+NSS_DECLARE_MODULE_FUNCTIONS (hesiod)
+
/* Declare a parser for Hesiod protocol entries. Although the format
of the entries is identical to those in /etc/protocols, here is no
predefined parser for us to use. */
diff --git a/hesiod/nss_hesiod/hesiod-pwd.c b/hesiod/nss_hesiod/hesiod-pwd.c
index 335b594f31..36ca3d1a19 100644
--- a/hesiod/nss_hesiod/hesiod-pwd.c
+++ b/hesiod/nss_hesiod/hesiod-pwd.c
@@ -24,6 +24,8 @@
#include <stdlib.h>
#include <string.h>
+NSS_DECLARE_MODULE_FUNCTIONS (hesiod)
+
/* Get the declaration of the parser function. */
#define ENTNAME pwent
#define STRUCTURE passwd
diff --git a/hesiod/nss_hesiod/hesiod-service.c b/hesiod/nss_hesiod/hesiod-service.c
index 94fa5112c9..ce93fd3d8f 100644
--- a/hesiod/nss_hesiod/hesiod-service.c
+++ b/hesiod/nss_hesiod/hesiod-service.c
@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
+NSS_DECLARE_MODULE_FUNCTIONS (hesiod)
+
/* Hesiod uses a format for service entries that differs from the
traditional format. We therefore declare our own parser. */
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 4/7] nss_compat: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (2 preceding siblings ...)
2020-02-12 14:34 ` [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:14 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 5/7] nss_db: " Florian Weimer
` (4 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
---
nss/nss_compat/compat-grp.c | 2 ++
nss/nss_compat/compat-initgroups.c | 2 ++
nss/nss_compat/compat-pwd.c | 2 ++
nss/nss_compat/compat-spwd.c | 2 ++
4 files changed, 8 insertions(+)
diff --git a/nss/nss_compat/compat-grp.c b/nss/nss_compat/compat-grp.c
index 561511c91a..14aadc6f01 100644
--- a/nss/nss_compat/compat-grp.c
+++ b/nss/nss_compat/compat-grp.c
@@ -27,6 +27,8 @@
#include <libc-lock.h>
#include <kernel-features.h>
+NSS_DECLARE_MODULE_FUNCTIONS (compat)
+
static service_user *ni;
static enum nss_status (*setgrent_impl) (int stayopen);
static enum nss_status (*getgrnam_r_impl) (const char *name,
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
index d2a280d9c3..67a4c100f6 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -30,6 +30,8 @@
#include <kernel-features.h>
#include <scratch_buffer.h>
+NSS_DECLARE_MODULE_FUNCTIONS (compat)
+
static service_user *ni;
static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t,
long int *, long int *,
diff --git a/nss/nss_compat/compat-pwd.c b/nss/nss_compat/compat-pwd.c
index b964e6f644..dfb454f777 100644
--- a/nss/nss_compat/compat-pwd.c
+++ b/nss/nss_compat/compat-pwd.c
@@ -31,6 +31,8 @@
#include "netgroup.h"
#include "nisdomain.h"
+NSS_DECLARE_MODULE_FUNCTIONS (compat)
+
static service_user *ni;
static enum nss_status (*setpwent_impl) (int stayopen);
static enum nss_status (*getpwnam_r_impl) (const char *name,
diff --git a/nss/nss_compat/compat-spwd.c b/nss/nss_compat/compat-spwd.c
index 15f5b95bb0..0a1fde1ea4 100644
--- a/nss/nss_compat/compat-spwd.c
+++ b/nss/nss_compat/compat-spwd.c
@@ -31,6 +31,8 @@
#include "netgroup.h"
#include "nisdomain.h"
+NSS_DECLARE_MODULE_FUNCTIONS (compat)
+
static service_user *ni;
static enum nss_status (*setspent_impl) (int stayopen);
static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp,
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 5/7] nss_db: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (3 preceding siblings ...)
2020-02-12 14:34 ` [PATCH 4/7] nss_compat: " Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:18 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 6/7] nss_files: " Florian Weimer
` (3 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
---
nss/nss_db/db-init.c | 2 ++
nss/nss_db/db-initgroups.c | 1 -
nss/nss_db/nss_db.h | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/nss/nss_db/db-init.c b/nss/nss_db/db-init.c
index 1ba5b70dfd..6f48b821f3 100644
--- a/nss/nss_db/db-init.c
+++ b/nss/nss_db/db-init.c
@@ -22,6 +22,8 @@
#include <nscd/nscd.h>
#include <string.h>
+#include "nss_db.h"
+
#define PWD_FILENAME (_PATH_VARDB "passwd.db")
define_traced_file (pwd, PWD_FILENAME);
diff --git a/nss/nss_db/db-initgroups.c b/nss/nss_db/db-initgroups.c
index 0ea81c90bb..a8c39d68d9 100644
--- a/nss/nss_db/db-initgroups.c
+++ b/nss/nss_db/db-initgroups.c
@@ -32,7 +32,6 @@
/* The hashing function we use. */
#include "../intl/hash-string.h"
-
enum nss_status
_nss_db_initgroups_dyn (const char *user, gid_t group, long int *start,
long int *size, gid_t **groupsp, long int limit,
diff --git a/nss/nss_db/nss_db.h b/nss/nss_db/nss_db.h
index 24942f5ec9..e354909c58 100644
--- a/nss/nss_db/nss_db.h
+++ b/nss/nss_db/nss_db.h
@@ -23,6 +23,7 @@
#include <stdint.h>
#include <libc-lock.h>
+NSS_DECLARE_MODULE_FUNCTIONS (db)
/* String table index type. */
typedef uint32_t stridx_t;
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 6/7] nss_files: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (4 preceding siblings ...)
2020-02-12 14:34 ` [PATCH 5/7] nss_db: " Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:26 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 7/7] nss_dns: " Florian Weimer
` (2 subsequent siblings)
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
---
nss/nss_files/files-alias.c | 2 ++
nss/nss_files/files-ethers.c | 3 +++
nss/nss_files/files-grp.c | 3 +++
nss/nss_files/files-hosts.c | 2 ++
nss/nss_files/files-init.c | 3 +++
nss/nss_files/files-initgroups.c | 3 +++
nss/nss_files/files-key.c | 2 ++
nss/nss_files/files-netgrp.c | 2 ++
nss/nss_files/files-network.c | 3 +++
nss/nss_files/files-proto.c | 2 ++
nss/nss_files/files-pwd.c | 3 +++
nss/nss_files/files-rpc.c | 2 ++
nss/nss_files/files-service.c | 2 ++
nss/nss_files/files-sgrp.c | 3 +++
nss/nss_files/files-spwd.c | 3 +++
15 files changed, 38 insertions(+)
diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c
index 7062181e5b..6aff7b4c10 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -30,6 +30,8 @@
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (files)
+
/* Locks the static variables in this file. */
__libc_lock_define_initialized (static, lock)
\f
diff --git a/nss/nss_files/files-ethers.c b/nss/nss_files/files-ethers.c
index dc618e4027..72c803a35c 100644
--- a/nss/nss_files/files-ethers.c
+++ b/nss/nss_files/files-ethers.c
@@ -18,6 +18,9 @@
#include <string.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
struct etherent_data {};
diff --git a/nss/nss_files/files-grp.c b/nss/nss_files/files-grp.c
index 7db3e42888..8746e033ee 100644
--- a/nss/nss_files/files-grp.c
+++ b/nss/nss_files/files-grp.c
@@ -17,6 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <grp.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define STRUCTURE group
#define ENTNAME grent
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index 92c5d9728d..9f0ed6f085 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -24,7 +24,9 @@
#include <resolv/resolv-internal.h>
#include <scratch_buffer.h>
#include <alloc_buffer.h>
+#include <nss.h>
+NSS_DECLARE_MODULE_FUNCTIONS (files)
/* Get implementation for some internal functions. */
#include "../resolv/res_hconf.h"
diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c
index 0929d09b6a..b36220e480 100644
--- a/nss/nss_files/files-init.c
+++ b/nss/nss_files/files-init.c
@@ -20,6 +20,9 @@
#include <string.h>
#include <nscd/nscd.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define PWD_FILENAME "/etc/passwd"
define_traced_file (pwd, PWD_FILENAME);
diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
index 2dd0882d29..577d6ddf1e 100644
--- a/nss/nss_files/files-initgroups.c
+++ b/nss/nss_files/files-initgroups.c
@@ -25,6 +25,9 @@
#include <stdbool.h>
#include <stdlib.h>
#include <scratch_buffer.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
enum nss_status
_nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
diff --git a/nss/nss_files/files-key.c b/nss/nss_files/files-key.c
index 9ae5a01c1f..cf0a7d9ad9 100644
--- a/nss/nss_files/files-key.c
+++ b/nss/nss_files/files-key.c
@@ -24,6 +24,8 @@
#include <rpc/des_crypt.h>
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (files)
+
#define DATAFILE "/etc/publickey"
diff --git a/nss/nss_files/files-netgrp.c b/nss/nss_files/files-netgrp.c
index 407ee06d71..2c580af01d 100644
--- a/nss/nss_files/files-netgrp.c
+++ b/nss/nss_files/files-netgrp.c
@@ -27,6 +27,8 @@
#include "nsswitch.h"
#include "netgroup.h"
+NSS_DECLARE_MODULE_FUNCTIONS (files)
+
#define DATAFILE "/etc/netgroup"
libnss_files_hidden_proto (_nss_files_endnetgrent)
diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c
index 6530d51c3b..cc71e3ab2e 100644
--- a/nss/nss_files/files-network.c
+++ b/nss/nss_files/files-network.c
@@ -20,6 +20,9 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <stdint.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define ENTNAME netent
#define DATABASE "networks"
diff --git a/nss/nss_files/files-proto.c b/nss/nss_files/files-proto.c
index a30ac52e7b..c30bedc0aa 100644
--- a/nss/nss_files/files-proto.c
+++ b/nss/nss_files/files-proto.c
@@ -17,7 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <netdb.h>
+#include <nss.h>
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define ENTNAME protoent
#define DATABASE "protocols"
diff --git a/nss/nss_files/files-pwd.c b/nss/nss_files/files-pwd.c
index 91c728e86c..51aa9a0cd3 100644
--- a/nss/nss_files/files-pwd.c
+++ b/nss/nss_files/files-pwd.c
@@ -17,6 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <pwd.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define STRUCTURE passwd
#define ENTNAME pwent
diff --git a/nss/nss_files/files-rpc.c b/nss/nss_files/files-rpc.c
index a2587bbaa8..ea4bcb1423 100644
--- a/nss/nss_files/files-rpc.c
+++ b/nss/nss_files/files-rpc.c
@@ -17,7 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <rpc/netdb.h>
+#include <nss.h>
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define ENTNAME rpcent
#define DATABASE "rpc"
diff --git a/nss/nss_files/files-service.c b/nss/nss_files/files-service.c
index e2f461677c..bfc2590699 100644
--- a/nss/nss_files/files-service.c
+++ b/nss/nss_files/files-service.c
@@ -18,7 +18,9 @@
#include <netinet/in.h>
#include <netdb.h>
+#include <nss.h>
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define ENTNAME servent
#define DATABASE "services"
diff --git a/nss/nss_files/files-sgrp.c b/nss/nss_files/files-sgrp.c
index 00d206bcbc..303c8fa690 100644
--- a/nss/nss_files/files-sgrp.c
+++ b/nss/nss_files/files-sgrp.c
@@ -17,6 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <gshadow.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define STRUCTURE sgrp
#define ENTNAME sgent
diff --git a/nss/nss_files/files-spwd.c b/nss/nss_files/files-spwd.c
index 74874ad136..13680451c0 100644
--- a/nss/nss_files/files-spwd.c
+++ b/nss/nss_files/files-spwd.c
@@ -17,6 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <shadow.h>
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (files)
#define STRUCTURE spwd
#define ENTNAME spent
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 7/7] nss_dns: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (5 preceding siblings ...)
2020-02-12 14:34 ` [PATCH 6/7] nss_files: " Florian Weimer
@ 2020-02-12 14:34 ` Florian Weimer
2020-02-13 1:19 ` DJ Delorie
2020-02-12 14:39 ` [PATCH 8/7] nss_nisplus: " Florian Weimer
2020-02-13 9:01 ` [PATCH 9/7] nss_nis: " Florian Weimer
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:34 UTC (permalink / raw)
To: libc-alpha
---
resolv/nss_dns/dns-canon.c | 2 ++
resolv/nss_dns/dns-host.c | 2 ++
resolv/nss_dns/dns-network.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/resolv/nss_dns/dns-canon.c b/resolv/nss_dns/dns-canon.c
index 0849c04dbe..5bcd16958e 100644
--- a/resolv/nss_dns/dns-canon.c
+++ b/resolv/nss_dns/dns-canon.c
@@ -26,6 +26,8 @@
#include <resolv/resolv_context.h>
#include <resolv/resolv-internal.h>
+NSS_DECLARE_MODULE_FUNCTIONS (dns)
+
#if PACKETSZ > 65536
# define MAXPACKET PACKETSZ
#else
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index fe90328175..91c0a3b0e4 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -90,6 +90,8 @@
#include <resolv/mapv4v6addr.h>
#include <resolv/mapv4v6hostent.h>
+NSS_DECLARE_MODULE_FUNCTIONS (dns)
+
#define RESOLVSORT
#if PACKETSZ > 65536
diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c
index 906a3a6b06..250e7e7187 100644
--- a/resolv/nss_dns/dns-network.c
+++ b/resolv/nss_dns/dns-network.c
@@ -70,6 +70,8 @@
#include <resolv/resolv-internal.h>
#include <resolv/resolv_context.h>
+NSS_DECLARE_MODULE_FUNCTIONS (dns)
+
/* Maximum number of aliases we allow. */
#define MAX_NR_ALIASES 48
--
2.24.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 8/7] nss_nisplus: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (6 preceding siblings ...)
2020-02-12 14:34 ` [PATCH 7/7] nss_dns: " Florian Weimer
@ 2020-02-12 14:39 ` Florian Weimer
2020-02-13 1:31 ` DJ Delorie
2020-02-13 9:01 ` [PATCH 9/7] nss_nis: " Florian Weimer
8 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-12 14:39 UTC (permalink / raw)
To: libc-alpha
-----
nis/nss-nisplus.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/nis/nss-nisplus.h b/nis/nss-nisplus.h
index ca6ef67654..92c67880b9 100644
--- a/nis/nss-nisplus.h
+++ b/nis/nss-nisplus.h
@@ -23,6 +23,7 @@
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (nisplus)
/* Convert NIS+ error number to NSS error number. */
extern const enum nss_status __niserr2nss_tab[] attribute_hidden;
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers
2020-02-12 14:34 ` [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers Florian Weimer
@ 2020-02-12 22:36 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-12 22:36 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> A future commit will use these names for types of functions
> in NSS service modules.
> ---
> nss/nss_compat/compat-grp.c | 54 +++++++++++------------
> nss/nss_compat/compat-initgroups.c | 71 +++++++++++++++---------------
> nss/nss_compat/compat-pwd.c | 56 +++++++++++------------
> nss/nss_compat/compat-spwd.c | 44 +++++++++---------
> 4 files changed, 112 insertions(+), 113 deletions(-)
This one just renames symbols, no functional change. LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h>
2020-02-12 14:34 ` [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h> Florian Weimer
@ 2020-02-13 1:10 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:10 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> This macro allows to add type safety to the implementation of NSS
> service modules.
> ---
> nscd/aicache.c | 23 +---
> nss/nss.h | 203 +++++++++++++++++++++++++++++++++++-
> sysdeps/posix/getaddrinfo.c | 18 +---
> 3 files changed, 209 insertions(+), 35 deletions(-)
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 ` [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS Florian Weimer
@ 2020-02-13 1:11 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:11 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> hesiod/nss_hesiod/hesiod-grp.c | 2 ++
> hesiod/nss_hesiod/hesiod-proto.c | 2 ++
> hesiod/nss_hesiod/hesiod-pwd.c | 2 ++
> hesiod/nss_hesiod/hesiod-service.c | 2 ++
> 4 files changed, 8 insertions(+)
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 4/7] nss_compat: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 ` [PATCH 4/7] nss_compat: " Florian Weimer
@ 2020-02-13 1:14 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:14 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> nss/nss_compat/compat-grp.c | 2 ++
> nss/nss_compat/compat-initgroups.c | 2 ++
> nss/nss_compat/compat-pwd.c | 2 ++
> nss/nss_compat/compat-spwd.c | 2 ++
> 4 files changed, 8 insertions(+)
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 5/7] nss_db: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 ` [PATCH 5/7] nss_db: " Florian Weimer
@ 2020-02-13 1:18 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:18 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> nss/nss_db/db-init.c | 2 ++
> nss/nss_db/db-initgroups.c | 1 -
> nss/nss_db/nss_db.h | 1 +
> 3 files changed, 3 insertions(+), 1 deletion(-)
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com
Unneeded whitespace change though:
diff --git a/nss/nss_db/db-initgroups.c b/nss/nss_db/db-initgroups.c
index 0ea81c90bb..a8c39d68d9 100644
--- a/nss/nss_db/db-initgroups.c
+++ b/nss/nss_db/db-initgroups.c
@@ -32,7 +32,6 @@
/* The hashing function we use. */
#include "../intl/hash-string.h"
-
enum nss_status
_nss_db_initgroups_dyn (const char *user, gid_t group, long int *start,
long int *size, gid_t **groupsp, long int limit,
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 7/7] nss_dns: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 ` [PATCH 7/7] nss_dns: " Florian Weimer
@ 2020-02-13 1:19 ` DJ Delorie
0 siblings, 0 replies; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:19 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> resolv/nss_dns/dns-canon.c | 2 ++
> resolv/nss_dns/dns-host.c | 2 ++
> resolv/nss_dns/dns-network.c | 2 ++
> 3 files changed, 6 insertions(+)
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 6/7] nss_files: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 ` [PATCH 6/7] nss_files: " Florian Weimer
@ 2020-02-13 1:26 ` DJ Delorie
2020-02-13 8:12 ` Florian Weimer
0 siblings, 1 reply; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:26 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> nss/nss_files/files-alias.c | 2 ++
> nss/nss_files/files-ethers.c | 3 +++
> nss/nss_files/files-grp.c | 3 +++
> nss/nss_files/files-hosts.c | 2 ++
> nss/nss_files/files-init.c | 3 +++
> nss/nss_files/files-initgroups.c | 3 +++
> nss/nss_files/files-key.c | 2 ++
> nss/nss_files/files-netgrp.c | 2 ++
> nss/nss_files/files-network.c | 3 +++
> nss/nss_files/files-proto.c | 2 ++
> nss/nss_files/files-pwd.c | 3 +++
> nss/nss_files/files-rpc.c | 2 ++
> nss/nss_files/files-service.c | 2 ++
> nss/nss_files/files-sgrp.c | 3 +++
> nss/nss_files/files-spwd.c | 3 +++
> 15 files changed, 38 insertions(+)
LGTM. Seems to be some inconsistency about whether to use <nss.h> or
"nsswitch.h" - I wonder if always using "nsswitch.h" *just* for
consistency would be worth the cost?
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/7] nss_nisplus: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:39 ` [PATCH 8/7] nss_nisplus: " Florian Weimer
@ 2020-02-13 1:31 ` DJ Delorie
2020-02-13 8:11 ` Florian Weimer
0 siblings, 1 reply; 29+ messages in thread
From: DJ Delorie @ 2020-02-13 1:31 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> nis/nss-nisplus.h | 1 +
> 1 file changed, 1 insertion(+)
LGTM. Will nis-nss be on the list too?
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 8/7] nss_nisplus: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 1:31 ` DJ Delorie
@ 2020-02-13 8:11 ` Florian Weimer
0 siblings, 0 replies; 29+ messages in thread
From: Florian Weimer @ 2020-02-13 8:11 UTC (permalink / raw)
To: DJ Delorie; +Cc: libc-alpha
* DJ Delorie:
> Florian Weimer <fweimer@redhat.com> writes:
>> nis/nss-nisplus.h | 1 +
>> 1 file changed, 1 insertion(+)
>
> LGTM. Will nis-nss be on the list too?
>
> Reviewed-by: DJ Delorie <dj@redhat.com>
Thanks for the reviews. Looks like I have to send 9/7, too. 8-/
Florian
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 6/7] nss_files: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 1:26 ` DJ Delorie
@ 2020-02-13 8:12 ` Florian Weimer
0 siblings, 0 replies; 29+ messages in thread
From: Florian Weimer @ 2020-02-13 8:12 UTC (permalink / raw)
To: DJ Delorie; +Cc: libc-alpha
* DJ Delorie:
> Florian Weimer <fweimer@redhat.com> writes:
>> nss/nss_files/files-alias.c | 2 ++
>> nss/nss_files/files-ethers.c | 3 +++
>> nss/nss_files/files-grp.c | 3 +++
>> nss/nss_files/files-hosts.c | 2 ++
>> nss/nss_files/files-init.c | 3 +++
>> nss/nss_files/files-initgroups.c | 3 +++
>> nss/nss_files/files-key.c | 2 ++
>> nss/nss_files/files-netgrp.c | 2 ++
>> nss/nss_files/files-network.c | 3 +++
>> nss/nss_files/files-proto.c | 2 ++
>> nss/nss_files/files-pwd.c | 3 +++
>> nss/nss_files/files-rpc.c | 2 ++
>> nss/nss_files/files-service.c | 2 ++
>> nss/nss_files/files-sgrp.c | 3 +++
>> nss/nss_files/files-spwd.c | 3 +++
>> 15 files changed, 38 insertions(+)
>
> LGTM. Seems to be some inconsistency about whether to use <nss.h> or
> "nsswitch.h" - I wonder if always using "nsswitch.h" *just* for
> consistency would be worth the cost?
>
> Reviewed-by: DJ Delorie <dj@redhat.com>
Maybe we should add nss_files.h if there any common declarations?
Thanks,
Florian
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
` (7 preceding siblings ...)
2020-02-12 14:39 ` [PATCH 8/7] nss_nisplus: " Florian Weimer
@ 2020-02-13 9:01 ` Florian Weimer
2020-02-13 9:16 ` Andreas Schwab
2020-02-13 9:21 ` Andreas Schwab
8 siblings, 2 replies; 29+ messages in thread
From: Florian Weimer @ 2020-02-13 9:01 UTC (permalink / raw)
To: libc-alpha
This commit removes the minor optimization based on strong aliases
because it loses type safety.
-----
nis/nss-nis.h | 1 +
nis/nss_nis/nis-hosts.c | 13 ++++++++-----
nis/nss_nis/nis-network.c | 15 ++++++++++-----
nis/nss_nis/nis-spwd.c | 13 +++++++++----
4 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -22,6 +22,7 @@
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (nis)
/* Convert YP error number to NSS error number. */
extern const enum nss_status __yperr2nss_tab[] attribute_hidden;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..1ee5444cfc 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -90,9 +90,16 @@ static bool_t new_start = 1;
static char *oldkey = NULL;
static int oldkeylen = 0;
+hidden_proto (_nss_nis_endhostent)
enum nss_status
_nss_nis_sethostent (int stayopen)
+{
+ return _nss_nis_endhostent ();
+}
+
+enum nss_status
+_nss_nis_endhostent (void)
{
__libc_lock_lock (lock);
@@ -108,11 +115,7 @@ _nss_nis_sethostent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
- even though the prototypes don't match. The argument of sethostent
- is used so this makes no difference. */
-strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
-
+hidden_def (_nss_nis_endhostent)
/* The calling function always need to get a lock first. */
static enum nss_status
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..511de00bd3 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -45,10 +45,18 @@ static bool_t new_start = 1;
static char *oldkey;
static int oldkeylen;
+hidden_proto (_nss_nis_endnetent)
+
enum nss_status
_nss_nis_setnetent (int stayopen)
{
- __libc_lock_lock (lock);
+ return _nss_nis_endnetent ();
+}
+
+enum nss_status
+_nss_nis_endnetent (void)
+{
+__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
@@ -62,10 +70,7 @@ _nss_nis_setnetent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endnetent an alias of _nss_nis_setnetent. We do this
- even though the prototypes don't match. The argument of setnetent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setnetent, _nss_nis_endnetent)
+hidden_def (_nss_nis_endnetent)
static enum nss_status
internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..660447b544 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -46,8 +46,16 @@ static bool ent_adjunct_used;
static char *oldkey;
static int oldkeylen;
+hidden_proto (_nss_nis_endspent)
+
enum nss_status
_nss_nis_setspent (int stayopen)
+{
+ return _nss_nis_endspent ();
+}
+
+enum nss_status
+_nss_nis_endspent (void)
{
__libc_lock_lock (lock);
@@ -61,10 +69,7 @@ _nss_nis_setspent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endspent an alias of _nss_nis_setspent. We do this
- even though the prototypes don't match. The argument of setspent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setspent, _nss_nis_endspent)
+hidden_def (_nss_nis_endspent)
static enum nss_status
internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 9:01 ` [PATCH 9/7] nss_nis: " Florian Weimer
@ 2020-02-13 9:16 ` Andreas Schwab
2020-02-13 9:21 ` Andreas Schwab
1 sibling, 0 replies; 29+ messages in thread
From: Andreas Schwab @ 2020-02-13 9:16 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Feb 13 2020, Florian Weimer wrote:
> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
> index 2d08076382..1ee5444cfc 100644
> --- a/nis/nss_nis/nis-hosts.c
> +++ b/nis/nss_nis/nis-hosts.c
> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
> static char *oldkey = NULL;
> static int oldkeylen = 0;
>
> +hidden_proto (_nss_nis_endhostent)
>
> enum nss_status
> _nss_nis_sethostent (int stayopen)
> +{
> + return _nss_nis_endhostent ();
> +}
> +
> +enum nss_status
> +_nss_nis_endhostent (void)
> {
> __libc_lock_lock (lock);
>
> @@ -108,11 +115,7 @@ _nss_nis_sethostent (int stayopen)
>
> return NSS_STATUS_SUCCESS;
> }
> -/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
> - even though the prototypes don't match. The argument of sethostent
> - is used so this makes no difference. */
> -strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
> -
> +hidden_def (_nss_nis_endhostent)
Please also remove the #define/#undef above.
> diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
> index dcafd26148..511de00bd3 100644
> --- a/nis/nss_nis/nis-network.c
> +++ b/nis/nss_nis/nis-network.c
> @@ -45,10 +45,18 @@ static bool_t new_start = 1;
> static char *oldkey;
> static int oldkeylen;
>
> +hidden_proto (_nss_nis_endnetent)
> +
> enum nss_status
> _nss_nis_setnetent (int stayopen)
> {
> - __libc_lock_lock (lock);
> + return _nss_nis_endnetent ();
> +}
> +
> +enum nss_status
> +_nss_nis_endnetent (void)
> +{
> +__libc_lock_lock (lock);
>
> new_start = 1;
> if (oldkey != NULL)
> @@ -62,10 +70,7 @@ _nss_nis_setnetent (int stayopen)
>
> return NSS_STATUS_SUCCESS;
> }
> -/* Make _nss_nis_endnetent an alias of _nss_nis_setnetent. We do this
> - even though the prototypes don't match. The argument of setnetent
> - is not used so this makes no difference. */
> -strong_alias (_nss_nis_setnetent, _nss_nis_endnetent)
> +hidden_def (_nss_nis_endnetent)
Likewise.
> diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
> index 6cd46b4022..660447b544 100644
> --- a/nis/nss_nis/nis-spwd.c
> +++ b/nis/nss_nis/nis-spwd.c
> @@ -46,8 +46,16 @@ static bool ent_adjunct_used;
> static char *oldkey;
> static int oldkeylen;
>
> +hidden_proto (_nss_nis_endspent)
> +
> enum nss_status
> _nss_nis_setspent (int stayopen)
> +{
> + return _nss_nis_endspent ();
> +}
> +
> +enum nss_status
> +_nss_nis_endspent (void)
> {
> __libc_lock_lock (lock);
>
> @@ -61,10 +69,7 @@ _nss_nis_setspent (int stayopen)
>
> return NSS_STATUS_SUCCESS;
> }
> -/* Make _nss_nis_endspent an alias of _nss_nis_setspent. We do this
> - even though the prototypes don't match. The argument of setspent
> - is not used so this makes no difference. */
> -strong_alias (_nss_nis_setspent, _nss_nis_endspent)
> +hidden_def (_nss_nis_endspent)
Likewise.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 9:01 ` [PATCH 9/7] nss_nis: " Florian Weimer
2020-02-13 9:16 ` Andreas Schwab
@ 2020-02-13 9:21 ` Andreas Schwab
2020-02-13 9:31 ` Florian Weimer
1 sibling, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2020-02-13 9:21 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Feb 13 2020, Florian Weimer wrote:
> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
> index 2d08076382..1ee5444cfc 100644
> --- a/nis/nss_nis/nis-hosts.c
> +++ b/nis/nss_nis/nis-hosts.c
> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
> static char *oldkey = NULL;
> static int oldkeylen = 0;
>
> +hidden_proto (_nss_nis_endhostent)
The hidden_proto should be in the header.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 9:21 ` Andreas Schwab
@ 2020-02-13 9:31 ` Florian Weimer
2020-02-13 9:38 ` Andreas Schwab
0 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-13 9:31 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
* Andreas Schwab:
> On Feb 13 2020, Florian Weimer wrote:
>
>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>> index 2d08076382..1ee5444cfc 100644
>> --- a/nis/nss_nis/nis-hosts.c
>> +++ b/nis/nss_nis/nis-hosts.c
>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>> static char *oldkey = NULL;
>> static int oldkeylen = 0;
>>
>> +hidden_proto (_nss_nis_endhostent)
>
> The hidden_proto should be in the header.
Which header? nss_nis.h?
We don't have libnss_nis_hidden_proto yet. Should I define that, too?
Thanks,
Florian
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 9:31 ` Florian Weimer
@ 2020-02-13 9:38 ` Andreas Schwab
2020-02-25 14:50 ` Florian Weimer
0 siblings, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2020-02-13 9:38 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Feb 13 2020, Florian Weimer wrote:
> * Andreas Schwab:
>
>> On Feb 13 2020, Florian Weimer wrote:
>>
>>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>>> index 2d08076382..1ee5444cfc 100644
>>> --- a/nis/nss_nis/nis-hosts.c
>>> +++ b/nis/nss_nis/nis-hosts.c
>>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>>> static char *oldkey = NULL;
>>> static int oldkeylen = 0;
>>>
>>> +hidden_proto (_nss_nis_endhostent)
>>
>> The hidden_proto should be in the header.
>
> Which header? nss_nis.h?
netdb.h, after the prototype.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-13 9:38 ` Andreas Schwab
@ 2020-02-25 14:50 ` Florian Weimer
2020-02-25 15:09 ` Andreas Schwab
0 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-25 14:50 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
* Andreas Schwab:
> On Feb 13 2020, Florian Weimer wrote:
>
>> * Andreas Schwab:
>>
>>> On Feb 13 2020, Florian Weimer wrote:
>>>
>>>> diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
>>>> index 2d08076382..1ee5444cfc 100644
>>>> --- a/nis/nss_nis/nis-hosts.c
>>>> +++ b/nis/nss_nis/nis-hosts.c
>>>> @@ -90,9 +90,16 @@ static bool_t new_start = 1;
>>>> static char *oldkey = NULL;
>>>> static int oldkeylen = 0;
>>>>
>>>> +hidden_proto (_nss_nis_endhostent)
>>>
>>> The hidden_proto should be in the header.
>>
>> Which header? nss_nis.h?
>
> netdb.h, after the prototype.
Do you mean like this?
Changing DECLARE_NSS_PROTOTYPES would require updating all NSS modules
to use hidden_def because with a hidden_proto, the function definition
would only define the internal alias, and the exported function would be
gone.
Thanks,
Florian
8<------------------------------------------------------------------8<
This commit removes the minor optimization based on strong aliases
because it loses type safety.
-----
include/netdb.h | 7 ++++++-
nis/nss-nis.h | 1 +
nis/nss_nis/nis-hosts.c | 17 +++++++----------
nis/nss_nis/nis-network.c | 17 ++++++++---------
nis/nss_nis/nis-spwd.c | 16 ++++++++--------
5 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/include/netdb.h b/include/netdb.h
index e230b1f4fc..a2bd5eef44 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -279,7 +279,8 @@ extern enum nss_status _nss_ ## service ## _getnetbyname_r \
extern enum nss_status _nss_ ## service ## _getnetbyaddr_r \
(uint32_t addr, int type, struct netent *net, \
char *buffer, size_t buflen, int *errnop, \
- int *herrnop);
+ int *herrnop); \
+extern enum nss_status _nss_ ## service ## _endspent (void);
DECLARE_NSS_PROTOTYPES (compat)
DECLARE_NSS_PROTOTYPES (dns)
@@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
DECLARE_NSS_PROTOTYPES (nis)
DECLARE_NSS_PROTOTYPES (nisplus)
+hidden_proto (_nss_nis_endhostent)
+hidden_proto (_nss_nis_endnetent)
+hidden_proto (_nss_nis_endspent)
+
#undef DECLARE_NSS_PROTOTYPES
#endif
diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -22,6 +22,7 @@
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (nis)
/* Convert YP error number to NSS error number. */
extern const enum nss_status __yperr2nss_tab[] attribute_hidden;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..7c28580659 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -19,11 +19,7 @@
#include <assert.h>
#include <nss.h>
#include <ctype.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endgrent. */
-#define _nss_nis_endhostent _nss_nis_endhostent_XXX
#include <netdb.h>
-#undef _nss_nis_endhostent
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -90,9 +86,14 @@ static bool_t new_start = 1;
static char *oldkey = NULL;
static int oldkeylen = 0;
-
enum nss_status
_nss_nis_sethostent (int stayopen)
+{
+ return _nss_nis_endhostent ();
+}
+
+enum nss_status
+_nss_nis_endhostent (void)
{
__libc_lock_lock (lock);
@@ -108,11 +109,7 @@ _nss_nis_sethostent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
- even though the prototypes don't match. The argument of sethostent
- is used so this makes no difference. */
-strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
-
+hidden_def (_nss_nis_endhostent)
/* The calling function always need to get a lock first. */
static enum nss_status
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..23975cb93f 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -17,11 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <nss.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endgrent. */
-#define _nss_nis_endnetent _nss_nis_endnetent_XXX
#include <netdb.h>
-#undef _nss_nis_endnetent
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
@@ -48,7 +44,13 @@ static int oldkeylen;
enum nss_status
_nss_nis_setnetent (int stayopen)
{
- __libc_lock_lock (lock);
+ return _nss_nis_endnetent ();
+}
+
+enum nss_status
+_nss_nis_endnetent (void)
+{
+__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
@@ -62,10 +64,7 @@ _nss_nis_setnetent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endnetent an alias of _nss_nis_setnetent. We do this
- even though the prototypes don't match. The argument of setnetent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setnetent, _nss_nis_endnetent)
+hidden_def (_nss_nis_endnetent)
static enum nss_status
internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..be882431d7 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -20,14 +20,11 @@
#include <ctype.h>
#include <errno.h>
#include <string.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endspent. */
-#define _nss_nis_endspent _nss_nis_endspent_XXX
#include <shadow.h>
-#undef _nss_nis_endspent
#include <libc-lock.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+#include <netdb.h>
#include "nss-nis.h"
#include <libnsl.h>
@@ -48,6 +45,12 @@ static int oldkeylen;
enum nss_status
_nss_nis_setspent (int stayopen)
+{
+ return _nss_nis_endspent ();
+}
+
+enum nss_status
+_nss_nis_endspent (void)
{
__libc_lock_lock (lock);
@@ -61,10 +64,7 @@ _nss_nis_setspent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endspent an alias of _nss_nis_setspent. We do this
- even though the prototypes don't match. The argument of setspent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setspent, _nss_nis_endspent)
+hidden_def (_nss_nis_endspent)
static enum nss_status
internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-25 14:50 ` Florian Weimer
@ 2020-02-25 15:09 ` Andreas Schwab
2020-02-25 16:10 ` Florian Weimer
0 siblings, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2020-02-25 15:09 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Feb 25 2020, Florian Weimer wrote:
> @@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
> DECLARE_NSS_PROTOTYPES (nis)
> DECLARE_NSS_PROTOTYPES (nisplus)
>
> +hidden_proto (_nss_nis_endhostent)
> +hidden_proto (_nss_nis_endnetent)
> +hidden_proto (_nss_nis_endspent)
> +
The hidden_proto should only exist if IS_IN(libnss_nis).
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-25 15:09 ` Andreas Schwab
@ 2020-02-25 16:10 ` Florian Weimer
2020-02-25 16:41 ` Andreas Schwab
0 siblings, 1 reply; 29+ messages in thread
From: Florian Weimer @ 2020-02-25 16:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
* Andreas Schwab:
> On Feb 25 2020, Florian Weimer wrote:
>
>> @@ -288,6 +289,10 @@ DECLARE_NSS_PROTOTYPES (hesiod)
>> DECLARE_NSS_PROTOTYPES (nis)
>> DECLARE_NSS_PROTOTYPES (nisplus)
>>
>> +hidden_proto (_nss_nis_endhostent)
>> +hidden_proto (_nss_nis_endnetent)
>> +hidden_proto (_nss_nis_endspent)
>> +
>
> The hidden_proto should only exist if IS_IN(libnss_nis).
Okay, then let's add the infrastructure for this. What about the patch
below?
Thanks,
Florian
8<------------------------------------------------------------------8<
This commit removes the minor optimization based on strong aliases
because it loses type safety.
-----
include/libc-symbols.h | 23 +++++++++++++++++++++++
include/netdb.h | 8 +++++++-
nis/nss-nis.h | 1 +
nis/nss_nis/nis-hosts.c | 17 +++++++----------
nis/nss_nis/nis-network.c | 17 ++++++++---------
nis/nss_nis/nis-spwd.c | 16 ++++++++--------
6 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 33e2d34c53..b0b75a087e 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -835,6 +835,29 @@ for linking")
# define libnsl_hidden_data_ver(local, name)
#endif
+#if IS_IN (libnss_nis)
+# define libnss_nis_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
+# define libnss_nis_hidden_tls_proto(name, attrs...) \
+ hidden_tls_proto (name, ##attrs)
+# define libnss_nis_hidden_def(name) hidden_def (name)
+# define libnss_nis_hidden_weak(name) hidden_weak (name)
+# define libnss_nis_hidden_ver(local, name) hidden_ver (local, name)
+# define libnss_nis_hidden_data_def(name) hidden_data_def (name)
+# define libnss_nis_hidden_tls_def(name) hidden_tls_def (name)
+# define libnss_nis_hidden_data_weak(name) hidden_data_weak (name)
+# define libnss_nis_hidden_data_ver(local, name) hidden_data_ver (local, name)
+#else
+# define libnss_nis_hidden_proto(name, attrs...)
+# define libnss_nis_hidden_tls_proto(name, attrs...)
+# define libnss_nis_hidden_def(name)
+# define libnss_nis_hidden_weak(name)
+# define libnss_nis_hidden_ver(local, name)
+# define libnss_nis_hidden_data_def(name)
+# define libnss_nis_hidden_tls_def(name)
+# define libnss_nis_hidden_data_weak(name)
+# define libnss_nis_hidden_data_ver(local, name)
+#endif
+
#if IS_IN (libnss_nisplus)
# define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnss_nisplus_hidden_tls_proto(name, attrs...) \
diff --git a/include/netdb.h b/include/netdb.h
index e230b1f4fc..3c78da60c5 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -279,7 +279,8 @@ extern enum nss_status _nss_ ## service ## _getnetbyname_r \
extern enum nss_status _nss_ ## service ## _getnetbyaddr_r \
(uint32_t addr, int type, struct netent *net, \
char *buffer, size_t buflen, int *errnop, \
- int *herrnop);
+ int *herrnop); \
+extern enum nss_status _nss_ ## service ## _endspent (void);
DECLARE_NSS_PROTOTYPES (compat)
DECLARE_NSS_PROTOTYPES (dns)
@@ -289,6 +290,11 @@ DECLARE_NSS_PROTOTYPES (nis)
DECLARE_NSS_PROTOTYPES (nisplus)
#undef DECLARE_NSS_PROTOTYPES
+
+libnss_nis_hidden_proto (_nss_nis_endhostent)
+libnss_nis_hidden_proto (_nss_nis_endnetent)
+libnss_nis_hidden_proto (_nss_nis_endspent)
+
#endif
#endif /* !_NETDB_H */
diff --git a/nis/nss-nis.h b/nis/nss-nis.h
index dc091d1a20..7c009d7e87 100644
--- a/nis/nss-nis.h
+++ b/nis/nss-nis.h
@@ -22,6 +22,7 @@
#include "nsswitch.h"
+NSS_DECLARE_MODULE_FUNCTIONS (nis)
/* Convert YP error number to NSS error number. */
extern const enum nss_status __yperr2nss_tab[] attribute_hidden;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 2d08076382..eb074783f7 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -19,11 +19,7 @@
#include <assert.h>
#include <nss.h>
#include <ctype.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endgrent. */
-#define _nss_nis_endhostent _nss_nis_endhostent_XXX
#include <netdb.h>
-#undef _nss_nis_endhostent
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -90,9 +86,14 @@ static bool_t new_start = 1;
static char *oldkey = NULL;
static int oldkeylen = 0;
-
enum nss_status
_nss_nis_sethostent (int stayopen)
+{
+ return _nss_nis_endhostent ();
+}
+
+enum nss_status
+_nss_nis_endhostent (void)
{
__libc_lock_lock (lock);
@@ -108,11 +109,7 @@ _nss_nis_sethostent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
- even though the prototypes don't match. The argument of sethostent
- is used so this makes no difference. */
-strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
-
+libnss_nis_hidden_def (_nss_nis_endhostent)
/* The calling function always need to get a lock first. */
static enum nss_status
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index dcafd26148..8d87c69d8e 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -17,11 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <nss.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endgrent. */
-#define _nss_nis_endnetent _nss_nis_endnetent_XXX
#include <netdb.h>
-#undef _nss_nis_endnetent
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
@@ -48,7 +44,13 @@ static int oldkeylen;
enum nss_status
_nss_nis_setnetent (int stayopen)
{
- __libc_lock_lock (lock);
+ return _nss_nis_endnetent ();
+}
+
+enum nss_status
+_nss_nis_endnetent (void)
+{
+__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
@@ -62,10 +64,7 @@ _nss_nis_setnetent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endnetent an alias of _nss_nis_setnetent. We do this
- even though the prototypes don't match. The argument of setnetent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setnetent, _nss_nis_endnetent)
+libnss_nis_hidden_def (_nss_nis_endnetent)
static enum nss_status
internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 6cd46b4022..9790dd4104 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -20,14 +20,11 @@
#include <ctype.h>
#include <errno.h>
#include <string.h>
-/* The following is an ugly trick to avoid a prototype declaration for
- _nss_nis_endspent. */
-#define _nss_nis_endspent _nss_nis_endspent_XXX
#include <shadow.h>
-#undef _nss_nis_endspent
#include <libc-lock.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+#include <netdb.h>
#include "nss-nis.h"
#include <libnsl.h>
@@ -48,6 +45,12 @@ static int oldkeylen;
enum nss_status
_nss_nis_setspent (int stayopen)
+{
+ return _nss_nis_endspent ();
+}
+
+enum nss_status
+_nss_nis_endspent (void)
{
__libc_lock_lock (lock);
@@ -61,10 +64,7 @@ _nss_nis_setspent (int stayopen)
return NSS_STATUS_SUCCESS;
}
-/* Make _nss_nis_endspent an alias of _nss_nis_setspent. We do this
- even though the prototypes don't match. The argument of setspent
- is not used so this makes no difference. */
-strong_alias (_nss_nis_setspent, _nss_nis_endspent)
+libnss_nis_hidden_def (_nss_nis_endspent)
static enum nss_status
internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-25 16:10 ` Florian Weimer
@ 2020-02-25 16:41 ` Andreas Schwab
2020-02-25 16:44 ` Florian Weimer
0 siblings, 1 reply; 29+ messages in thread
From: Andreas Schwab @ 2020-02-25 16:41 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Feb 25 2020, Florian Weimer wrote:
> This commit removes the minor optimization based on strong aliases
> because it loses type safety.
Ok.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 9/7] nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
2020-02-25 16:41 ` Andreas Schwab
@ 2020-02-25 16:44 ` Florian Weimer
0 siblings, 0 replies; 29+ messages in thread
From: Florian Weimer @ 2020-02-25 16:44 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
* Andreas Schwab:
> On Feb 25 2020, Florian Weimer wrote:
>
>> This commit removes the minor optimization based on strong aliases
>> because it loses type safety.
>
> Ok.
Thanks, pushed.
Florian
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2020-02-25 16:44 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12 14:34 [PATCH 0/7] More type safety for NSS modules Florian Weimer
2020-02-12 14:34 ` [PATCH 1/7] nss_compat: Do not use nss_* names for function pointers Florian Weimer
2020-02-12 22:36 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 2/7] nss: Add function types and NSS_DECLARE_MODULE_FUNCTIONS macro to <nss.h> Florian Weimer
2020-02-13 1:10 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 3/7] nss_hesiod: Use NSS_DECLARE_MODULE_FUNCTIONS Florian Weimer
2020-02-13 1:11 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 4/7] nss_compat: " Florian Weimer
2020-02-13 1:14 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 5/7] nss_db: " Florian Weimer
2020-02-13 1:18 ` DJ Delorie
2020-02-12 14:34 ` [PATCH 6/7] nss_files: " Florian Weimer
2020-02-13 1:26 ` DJ Delorie
2020-02-13 8:12 ` Florian Weimer
2020-02-12 14:34 ` [PATCH 7/7] nss_dns: " Florian Weimer
2020-02-13 1:19 ` DJ Delorie
2020-02-12 14:39 ` [PATCH 8/7] nss_nisplus: " Florian Weimer
2020-02-13 1:31 ` DJ Delorie
2020-02-13 8:11 ` Florian Weimer
2020-02-13 9:01 ` [PATCH 9/7] nss_nis: " Florian Weimer
2020-02-13 9:16 ` Andreas Schwab
2020-02-13 9:21 ` Andreas Schwab
2020-02-13 9:31 ` Florian Weimer
2020-02-13 9:38 ` Andreas Schwab
2020-02-25 14:50 ` Florian Weimer
2020-02-25 15:09 ` Andreas Schwab
2020-02-25 16:10 ` Florian Weimer
2020-02-25 16:41 ` Andreas Schwab
2020-02-25 16:44 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).