[PATCH v2 22/23] nscd: Remove most of the rebuilds of existing libc functions

Carlos O'Donell carlos@redhat.com
Tue Mar 24 21:58:54 GMT 2026


On 3/20/26 4:43 PM, Florian Weimer wrote:
> With __nscd_disable_database, the databases are already disabled.
> 
> Keep the struct hostent functions because the *2_r and *3_r variants
> are not exported from libc.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>   nscd/Makefile        |  6 ------
>   nscd/getgrgid_r.c    | 34 ----------------------------------
>   nscd/getgrnam_r.c    | 33 ---------------------------------
>   nscd/getpwnam_r.c    | 30 ------------------------------
>   nscd/getpwuid_r.c    | 30 ------------------------------
>   nscd/getsrvbynm_r.c  | 29 -----------------------------
>   nscd/getsrvbypt_r.c  | 29 -----------------------------
>   nscd/grpcache.c      |  4 ++--
>   nscd/pwdcache.c      |  4 ++--
>   nscd/servicescache.c |  4 ++--
>   10 files changed, 6 insertions(+), 197 deletions(-)
>   delete mode 100644 nscd/getgrgid_r.c
>   delete mode 100644 nscd/getgrnam_r.c
>   delete mode 100644 nscd/getpwnam_r.c
>   delete mode 100644 nscd/getpwuid_r.c
>   delete mode 100644 nscd/getsrvbynm_r.c
>   delete mode 100644 nscd/getsrvbypt_r.c
> 
> diff --git a/nscd/Makefile b/nscd/Makefile
> index 2578b00e27..58a2d01e00 100644
> --- a/nscd/Makefile
> +++ b/nscd/Makefile
> @@ -46,14 +46,8 @@ nscd-modules := \
>     cachedumper \
>     connections \
>     dbg_log \
> -  getgrgid_r \
> -  getgrnam_r \
>     gethstbyad_r \
>     gethstbynm3_r \
> -  getpwnam_r \
> -  getpwuid_r \
> -  getsrvbynm_r \
> -  getsrvbypt_r \
>     grpcache \
>     hstcache \
>     initgrcache \
> diff --git a/nscd/getgrgid_r.c b/nscd/getgrgid_r.c
> deleted file mode 100644
> index 3fa0717d88..0000000000
> --- a/nscd/getgrgid_r.c
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <grp.h>
> -
> -#include <grp-merge.h>
> -
> -#define LOOKUP_TYPE	struct group
> -#define FUNCTION_NAME	getgrgid
> -#define DATABASE_NAME	group
> -#define ADD_PARAMS	gid_t gid
> -#define ADD_VARIABLES	gid
> -#define BUFLEN		NSS_BUFLEN_GROUP
> -
> -#define DEEPCOPY_FN	__copy_grp
> -#define MERGE_FN	__merge_grp
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include <nss/getXXbyYY_r.c>
> diff --git a/nscd/getgrnam_r.c b/nscd/getgrnam_r.c
> deleted file mode 100644
> index 7be4374408..0000000000
> --- a/nscd/getgrnam_r.c
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <grp.h>
> -
> -#include <grp-merge.h>
> -
> -#define LOOKUP_TYPE	struct group
> -#define FUNCTION_NAME	getgrnam
> -#define DATABASE_NAME	group
> -#define ADD_PARAMS	const char *name
> -#define ADD_VARIABLES	name
> -
> -#define DEEPCOPY_FN	__copy_grp
> -#define MERGE_FN	__merge_grp
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include <nss/getXXbyYY_r.c>
> diff --git a/nscd/getpwnam_r.c b/nscd/getpwnam_r.c
> deleted file mode 100644
> index e63b7fb0c1..0000000000
> --- a/nscd/getpwnam_r.c
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <pwd.h>
> -
> -
> -#define LOOKUP_TYPE	struct passwd
> -#define FUNCTION_NAME	getpwnam
> -#define DATABASE_NAME	passwd
> -#define ADD_PARAMS	const char *name
> -#define ADD_VARIABLES	name
> -#define BUFLEN		NSS_BUFLEN_PASSWD
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include <nss/getXXbyYY_r.c>
> diff --git a/nscd/getpwuid_r.c b/nscd/getpwuid_r.c
> deleted file mode 100644
> index 3ea5f806f8..0000000000
> --- a/nscd/getpwuid_r.c
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <pwd.h>
> -
> -
> -#define LOOKUP_TYPE	struct passwd
> -#define FUNCTION_NAME	getpwuid
> -#define DATABASE_NAME	passwd
> -#define ADD_PARAMS	uid_t uid
> -#define ADD_VARIABLES	uid
> -#define BUFLEN		NSS_BUFLEN_PASSWD
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include <nss/getXXbyYY_r.c>
> diff --git a/nscd/getsrvbynm_r.c b/nscd/getsrvbynm_r.c
> deleted file mode 100644
> index 4ac934815c..0000000000
> --- a/nscd/getsrvbynm_r.c
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <netdb.h>
> -
> -
> -#define LOOKUP_TYPE		struct servent
> -#define FUNCTION_NAME		getservbyname
> -#define DATABASE_NAME		services
> -#define ADD_PARAMS		const char *name, const char *proto
> -#define ADD_VARIABLES		name, proto
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include "../nss/getXXbyYY_r.c"
> diff --git a/nscd/getsrvbypt_r.c b/nscd/getsrvbypt_r.c
> deleted file mode 100644
> index 9ca0fec407..0000000000
> --- a/nscd/getsrvbypt_r.c
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Copyright (C) 1996-2026 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   This program is free software; you can redistribute it and/or modify
> -   it under the terms of the GNU General Public License as published
> -   by the Free Software Foundation; version 2 of the License, or
> -   (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -   GNU General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
> -
> -#include <netdb.h>
> -
> -
> -#define LOOKUP_TYPE		struct servent
> -#define FUNCTION_NAME		getservbyport
> -#define DATABASE_NAME		services
> -#define ADD_PARAMS		int port, const char *proto
> -#define ADD_VARIABLES		port, proto
> -
> -/* We are nscd, so we don't want to be talking to ourselves.  */
> -#undef	USE_NSCD
> -
> -#include "../nss/getXXbyYY_r.c"
> diff --git a/nscd/grpcache.c b/nscd/grpcache.c
> index a05f6fb6e6..1e060724f6 100644
> --- a/nscd/grpcache.c
> +++ b/nscd/grpcache.c
> @@ -401,9 +401,9 @@ lookup (int type, union keytype key, struct group *resultbufp, char *buffer,
>   	size_t buflen, struct group **grp)
>   {
>     if (type == GETGRBYNAME)
> -    return __getgrnam_r (key.v, resultbufp, buffer, buflen, grp);
> +    return getgrnam_r (key.v, resultbufp, buffer, buflen, grp);
>     else
> -    return __getgrgid_r (key.g, resultbufp, buffer, buflen, grp);
> +    return getgrgid_r (key.g, resultbufp, buffer, buflen, grp);
>   }
>   
>   
> diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
> index 715775be2f..66f9ff09a2 100644
> --- a/nscd/pwdcache.c
> +++ b/nscd/pwdcache.c
> @@ -379,9 +379,9 @@ lookup (int type, union keytype key, struct passwd *resultbufp, char *buffer,
>   	size_t buflen, struct passwd **pwd)
>   {
>     if (type == GETPWBYNAME)
> -    return __getpwnam_r (key.v, resultbufp, buffer, buflen, pwd);
> +    return getpwnam_r (key.v, resultbufp, buffer, buflen, pwd);
>     else
> -    return __getpwuid_r (key.u, resultbufp, buffer, buflen, pwd);
> +    return getpwuid_r (key.u, resultbufp, buffer, buflen, pwd);
>   }
>   
>   
> diff --git a/nscd/servicescache.c b/nscd/servicescache.c
> index aa8a80d483..46cf1a9e3b 100644
> --- a/nscd/servicescache.c
> +++ b/nscd/servicescache.c
> @@ -329,10 +329,10 @@ lookup (int type, char *key, struct servent *resultbufp, char *buffer,
>       }
>   
>     if (type == GETSERVBYNAME)
> -    return __getservbyname_r (key, proto, resultbufp, buffer, buflen, serv);
> +    return getservbyname_r (key, proto, resultbufp, buffer, buflen, serv);
>   
>     assert (type == GETSERVBYPORT);
> -  return __getservbyport_r (atol (key), proto, resultbufp, buffer, buflen,
> +  return getservbyport_r (atol (key), proto, resultbufp, buffer, buflen,
>   			    serv);
>   }
>   


-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list