aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjun Shankar <arjun@redhat.com>2023-10-02 14:55:15 +0200
committerArjun Shankar <arjun@redhat.com>2023-10-24 12:30:59 +0200
commitb121fdc552f392cd86b21f159dd3e3b998de91a3 (patch)
treeeee235f1a10c6ce5d1b4d5a760c4a00d1d86e24d
parent83d13972f23546758b600ba940e0d53248dd0339 (diff)
downloadglibc-b121fdc552f392cd86b21f159dd3e3b998de91a3.zip
glibc-b121fdc552f392cd86b21f159dd3e3b998de91a3.tar.gz
glibc-b121fdc552f392cd86b21f159dd3e3b998de91a3.tar.bz2
Remove 'grp' and merge into 'nss' and 'posix'
The majority of grp routines are entry points for nss functionality. This commit removes the 'grp' subdirectory and moves all nss-relevant functionality and all tests to 'nss', and the 'setgroups' stub into 'posix' (alongside the 'getgroups' stub). References to grp/ are accordingly changed. In addition, compat-initgroups.c, a fallback implementation of initgroups is renamed to initgroups-fallback.c so that the build system does not confuse it for nss_compat/compat-initgroups.c. Build time improves very slightly; e.g. down from an average of 45.5s to 44.5s on an 8-thread mobile x86_64 CPU. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r--Makeconfig2
-rw-r--r--grp/Makefile70
-rw-r--r--grp/Versions34
-rw-r--r--include/grp-merge.h2
-rw-r--r--include/grp.h2
-rw-r--r--nscd/initgrcache.c2
-rw-r--r--nss/Makefile43
-rw-r--r--nss/Versions30
-rw-r--r--nss/fgetgrent.c (renamed from grp/fgetgrent.c)0
-rw-r--r--nss/fgetgrent_r.c (renamed from grp/fgetgrent_r.c)0
-rw-r--r--nss/getgrent.c (renamed from grp/getgrent.c)0
-rw-r--r--nss/getgrent_r.c (renamed from grp/getgrent_r.c)0
-rw-r--r--nss/getgrgid.c (renamed from grp/getgrgid.c)0
-rw-r--r--nss/getgrgid_r.c (renamed from grp/getgrgid_r.c)0
-rw-r--r--nss/getgrnam.c (renamed from grp/getgrnam.c)0
-rw-r--r--nss/getgrnam_r.c (renamed from grp/getgrnam_r.c)0
-rw-r--r--nss/grp-merge.c (renamed from grp/grp-merge.c)0
-rw-r--r--nss/grp-merge.h (renamed from grp/grp-merge.h)0
-rw-r--r--nss/grp.h (renamed from grp/grp.h)0
-rw-r--r--nss/initgroups-fallback.c (renamed from grp/compat-initgroups.c)0
-rw-r--r--nss/initgroups.c (renamed from grp/initgroups.c)2
-rw-r--r--nss/putgrent.c (renamed from grp/putgrent.c)0
-rw-r--r--nss/testgrp.c (renamed from grp/testgrp.c)0
-rw-r--r--nss/tst-initgroups1.c (renamed from grp/tst-initgroups1.c)0
-rw-r--r--nss/tst-initgroups1.root/etc/group (renamed from grp/tst-initgroups1.root/etc/group)0
-rw-r--r--nss/tst-initgroups1.root/etc/nsswitch.conf (renamed from grp/tst-initgroups1.root/etc/nsswitch.conf)0
-rw-r--r--nss/tst-initgroups1.root/etc/passwd (renamed from grp/tst-initgroups1.root/etc/passwd)0
-rw-r--r--nss/tst-initgroups2.c (renamed from grp/tst-initgroups2.c)0
-rw-r--r--nss/tst-initgroups2.root/etc/group (renamed from grp/tst-initgroups2.root/etc/group)0
-rw-r--r--nss/tst-initgroups2.root/etc/nsswitch.conf (renamed from grp/tst-initgroups2.root/etc/nsswitch.conf)0
-rw-r--r--nss/tst-initgroups2.root/etc/passwd (renamed from grp/tst-initgroups2.root/etc/passwd)0
-rw-r--r--nss/tst-putgrent.c (renamed from grp/tst-putgrent.c)0
-rw-r--r--nss/tst_fgetgrent.c (renamed from grp/tst_fgetgrent.c)0
-rw-r--r--nss/tst_fgetgrent.sh (renamed from grp/tst_fgetgrent.sh)10
-rw-r--r--posix/Makefile1
-rw-r--r--posix/Versions2
-rw-r--r--posix/setgroups.c (renamed from grp/setgroups.c)0
-rwxr-xr-xscripts/update-copyrights2
38 files changed, 85 insertions, 117 deletions
diff --git a/Makeconfig b/Makeconfig
index c48fcc5..9ff6a90 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1352,7 +1352,7 @@ endif
# dependencies and generate sorted-subdirs dynamically.
all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
stdlib stdio-common libio malloc string wcsmbs time dirent \
- grp pwd posix io termios resource misc socket sysvipc gmon \
+ pwd posix io termios resource misc socket sysvipc gmon \
gnulib iconv iconvdata wctype manual shadow gshadow po argp \
localedata timezone rt conform debug mathvec support \
dlfcn elf
diff --git a/grp/Makefile b/grp/Makefile
deleted file mode 100644
index 38006fb..0000000
--- a/grp/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 1991-2023 Free Software Foundation, Inc.
-# This file is part of the GNU C Library.
-
-# The GNU C Library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-
-# The GNU C Library 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
-# Lesser General Public License for more details.
-
-# You should have received a copy of the GNU Lesser General Public
-# License along with the GNU C Library; if not, see
-# <https://www.gnu.org/licenses/>.
-
-#
-# Sub-makefile for grp portion of the library.
-#
-subdir := grp
-
-include ../Makeconfig
-
-headers := grp.h
-
-routines := fgetgrent initgroups setgroups \
- getgrent getgrgid getgrnam putgrent \
- getgrent_r getgrgid_r getgrnam_r fgetgrent_r \
- grp-merge
-
-tests := testgrp tst-putgrent
-
-tests-container = \
- tst-initgroups1 \
- tst-initgroups2
-
-ifeq (yes,$(build-shared))
-test-srcs := tst_fgetgrent
-ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)tst_fgetgrent.out
-endif
-endif
-
-
-include ../Rules
-
-ifeq ($(have-thread-library),yes)
-
-CFLAGS-getgrgid_r.c += -fexceptions
-CFLAGS-getgrnam_r.c += -fexceptions
-CFLAGS-getgrent_r.c += -fexceptions
-CFLAGS-getgrent.c += -fexceptions
-CFLAGS-fgetgrent.c += -fexceptions
-CFLAGS-fgetgrent_r.c += -fexceptions $(libio-mtsafe)
-CFLAGS-putgrent.c += -fexceptions $(libio-mtsafe)
-CFLAGS-initgroups.c += -fexceptions
-CFLAGS-getgrgid.c += -fexceptions
-
-endif
-
-ifeq ($(run-built-tests),yes)
-# tst_fgetgrent currently only works with shared libraries
-ifeq (yes,$(build-shared))
-$(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
- $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
- $(evaluate-test)
-
-endif
-endif
diff --git a/grp/Versions b/grp/Versions
deleted file mode 100644
index 096caa4..0000000
--- a/grp/Versions
+++ /dev/null
@@ -1,34 +0,0 @@
-libc {
- GLIBC_2.0 {
- # e*
- endgrent;
-
- # f*
- fgetgrent; fgetgrent_r;
-
- # g*
- getgrent; getgrent_r; getgrgid; getgrgid_r; getgrnam; getgrnam_r;
- getgroups;
-
- # i*
- initgroups;
-
- # s*
- setgrent; setgroups;
- }
- GLIBC_2.1 {
- # p*
- putgrent;
- }
- GLIBC_2.1.2 {
- # g*
- getgrent_r; getgrgid_r; getgrnam_r;
- }
- GLIBC_2.2.4 {
- # g*
- getgrouplist;
- }
- GLIBC_PRIVATE {
- __merge_grp; __copy_grp;
- }
-}
diff --git a/include/grp-merge.h b/include/grp-merge.h
index 331ac20..fc9a25d 100644
--- a/include/grp-merge.h
+++ b/include/grp-merge.h
@@ -1,5 +1,5 @@
#ifndef _GRP_MERGE_H
-#include <grp/grp-merge.h>
+#include <nss/grp-merge.h>
libc_hidden_proto (__copy_grp)
libc_hidden_proto (__merge_grp)
diff --git a/include/grp.h b/include/grp.h
index 2cd2475..96b98a3 100644
--- a/include/grp.h
+++ b/include/grp.h
@@ -1,5 +1,5 @@
#ifndef _GRP_H
-#include <grp/grp.h>
+#include <nss/grp.h>
#ifndef _ISOMAC
libc_hidden_proto (setgroups)
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index be44951..8d8e1c2 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -45,7 +45,7 @@ static const initgr_response_header notfound =
};
-#include "../grp/compat-initgroups.c"
+#include "../nss/initgroups-fallback.c"
static time_t
diff --git a/nss/Makefile b/nss/Makefile
index 32764b7..baf7d9d 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -23,6 +23,7 @@ subdir := nss
include ../Makeconfig
headers := \
+ grp.h \
nss.h \
# headers
@@ -50,6 +51,34 @@ routines = \
valid_list_field \
# routines
+# grp routines:
+routines += \
+ fgetgrent \
+ fgetgrent_r \
+ getgrent \
+ getgrent_r \
+ getgrgid \
+ getgrgid_r \
+ getgrnam \
+ getgrnam_r \
+ grp-merge \
+ initgroups \
+ putgrent \
+ # routines
+
+ifeq ($(have-thread-library),yes)
+CFLAGS-fgetgrent.c += -fexceptions
+CFLAGS-fgetgrent_r.c += -fexceptions $(libio-mtsafe)
+CFLAGS-getgrent.c += -fexceptions
+CFLAGS-getgrent_r.c += -fexceptions
+CFLAGS-getgrgid.c += -fexceptions
+CFLAGS-getgrgid_r.c += -fexceptions
+CFLAGS-getgrnam.c += -fexceptions
+CFLAGS-getgrnam_r.c += -fexceptions
+CFLAGS-initgroups.c += -fexceptions
+CFLAGS-putgrent.c += -fexceptions $(libio-mtsafe)
+endif
+
# These are the databases that go through nss dispatch.
# Caution: if you add a database here, you must add its real name
# in databases.def, too.
@@ -88,6 +117,7 @@ tests := \
bug17079 \
test-digits-dots \
test-netdb \
+ testgrp \
tst-nss-getpwent \
tst-nss-hash \
tst-nss-test1 \
@@ -95,11 +125,14 @@ tests := \
tst-nss-test4 \
tst-nss-test5 \
tst-nss-test_errno \
+ tst-putgrent \
# tests
xtests = bug-erange
tests-container := \
+ tst-initgroups1 \
+ tst-initgroups2 \
tst-nss-compat1 \
tst-nss-db-endgrent \
tst-nss-db-endpwent \
@@ -112,13 +145,21 @@ tests-container := \
tst-reload2 \
# tests-container
-# Tests which need libdl
ifeq (yes,$(build-shared))
+# Tests which need libdl
tests += tst-nss-files-hosts-erange
tests += tst-nss-files-hosts-multi
tests += tst-nss-files-hosts-getent
tests += tst-nss-files-alias-leak
tests += tst-nss-files-alias-truncated
+# tst_fgetgrent currently only works with shared libraries
+test-srcs := tst_fgetgrent
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst_fgetgrent.out
+$(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
+ $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
+ $(evaluate-test)
+endif
endif
# If we have a thread library then we can test cancellation against
diff --git a/nss/Versions b/nss/Versions
index e551524..5401829 100644
--- a/nss/Versions
+++ b/nss/Versions
@@ -5,10 +5,38 @@ libc {
# Functions exported as no-op compat symbols.
__nss_passwd_lookup; __nss_group_lookup; __nss_hosts_lookup; __nss_next;
__nss_database_lookup;
+
+ # e*
+ endgrent;
+
+ # f*
+ fgetgrent; fgetgrent_r;
+
+ # g*
+ getgrent; getgrent_r; getgrgid; getgrgid_r; getgrnam; getgrnam_r;
+ getgroups;
+
+ # i*
+ initgroups;
+
+ # s*
+ setgrent;
+ }
+ GLIBC_2.1 {
+ # p*
+ putgrent;
+ }
+ GLIBC_2.1.2 {
+ # g*
+ getgrent_r; getgrgid_r; getgrnam_r;
}
GLIBC_2.2.2 {
__nss_hostname_digits_dots;
}
+ GLIBC_2.2.4 {
+ # g*
+ getgrouplist;
+ }
GLIBC_2.27 {
}
GLIBC_PRIVATE {
@@ -107,6 +135,8 @@ libc {
_nss_files_initgroups_dyn;
_nss_files_init;
+
+ __merge_grp; __copy_grp;
}
}
diff --git a/grp/fgetgrent.c b/nss/fgetgrent.c
index 2e7c7fe..2e7c7fe 100644
--- a/grp/fgetgrent.c
+++ b/nss/fgetgrent.c
diff --git a/grp/fgetgrent_r.c b/nss/fgetgrent_r.c
index 5ce7023..5ce7023 100644
--- a/grp/fgetgrent_r.c
+++ b/nss/fgetgrent_r.c
diff --git a/grp/getgrent.c b/nss/getgrent.c
index 6e09987..6e09987 100644
--- a/grp/getgrent.c
+++ b/nss/getgrent.c
diff --git a/grp/getgrent_r.c b/nss/getgrent_r.c
index ea3d0e8..ea3d0e8 100644
--- a/grp/getgrent_r.c
+++ b/nss/getgrent_r.c
diff --git a/grp/getgrgid.c b/nss/getgrgid.c
index db50f8f..db50f8f 100644
--- a/grp/getgrgid.c
+++ b/nss/getgrgid.c
diff --git a/grp/getgrgid_r.c b/nss/getgrgid_r.c
index dab5f85..dab5f85 100644
--- a/grp/getgrgid_r.c
+++ b/nss/getgrgid_r.c
diff --git a/grp/getgrnam.c b/nss/getgrnam.c
index 98d637b..98d637b 100644
--- a/grp/getgrnam.c
+++ b/nss/getgrnam.c
diff --git a/grp/getgrnam_r.c b/nss/getgrnam_r.c
index ed5649c..ed5649c 100644
--- a/grp/getgrnam_r.c
+++ b/nss/getgrnam_r.c
diff --git a/grp/grp-merge.c b/nss/grp-merge.c
index 991abf0..991abf0 100644
--- a/grp/grp-merge.c
+++ b/nss/grp-merge.c
diff --git a/grp/grp-merge.h b/nss/grp-merge.h
index 9e1f75c..9e1f75c 100644
--- a/grp/grp-merge.h
+++ b/nss/grp-merge.h
diff --git a/grp/grp.h b/nss/grp.h
index c889647..c889647 100644
--- a/grp/grp.h
+++ b/nss/grp.h
diff --git a/grp/compat-initgroups.c b/nss/initgroups-fallback.c
index 9df9407..9df9407 100644
--- a/grp/compat-initgroups.c
+++ b/nss/initgroups-fallback.c
diff --git a/grp/initgroups.c b/nss/initgroups.c
index 2ebd623..e803cec 100644
--- a/grp/initgroups.c
+++ b/nss/initgroups.c
@@ -39,7 +39,7 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
static bool use_initgroups_entry;
-#include "compat-initgroups.c"
+#include "initgroups-fallback.c"
static int
diff --git a/grp/putgrent.c b/nss/putgrent.c
index 93caea5..93caea5 100644
--- a/grp/putgrent.c
+++ b/nss/putgrent.c
diff --git a/grp/testgrp.c b/nss/testgrp.c
index 892cfaa..892cfaa 100644
--- a/grp/testgrp.c
+++ b/nss/testgrp.c
diff --git a/grp/tst-initgroups1.c b/nss/tst-initgroups1.c
index 3f12388..3f12388 100644
--- a/grp/tst-initgroups1.c
+++ b/nss/tst-initgroups1.c
diff --git a/grp/tst-initgroups1.root/etc/group b/nss/tst-initgroups1.root/etc/group
index 0dac1cc..0dac1cc 100644
--- a/grp/tst-initgroups1.root/etc/group
+++ b/nss/tst-initgroups1.root/etc/group
diff --git a/grp/tst-initgroups1.root/etc/nsswitch.conf b/nss/tst-initgroups1.root/etc/nsswitch.conf
index 8d0a1ae..8d0a1ae 100644
--- a/grp/tst-initgroups1.root/etc/nsswitch.conf
+++ b/nss/tst-initgroups1.root/etc/nsswitch.conf
diff --git a/grp/tst-initgroups1.root/etc/passwd b/nss/tst-initgroups1.root/etc/passwd
index 5e3a2a5..5e3a2a5 100644
--- a/grp/tst-initgroups1.root/etc/passwd
+++ b/nss/tst-initgroups1.root/etc/passwd
diff --git a/grp/tst-initgroups2.c b/nss/tst-initgroups2.c
index 4e8b8c5..4e8b8c5 100644
--- a/grp/tst-initgroups2.c
+++ b/nss/tst-initgroups2.c
diff --git a/grp/tst-initgroups2.root/etc/group b/nss/tst-initgroups2.root/etc/group
index 0dac1cc..0dac1cc 100644
--- a/grp/tst-initgroups2.root/etc/group
+++ b/nss/tst-initgroups2.root/etc/group
diff --git a/grp/tst-initgroups2.root/etc/nsswitch.conf b/nss/tst-initgroups2.root/etc/nsswitch.conf
index c61f362..c61f362 100644
--- a/grp/tst-initgroups2.root/etc/nsswitch.conf
+++ b/nss/tst-initgroups2.root/etc/nsswitch.conf
diff --git a/grp/tst-initgroups2.root/etc/passwd b/nss/tst-initgroups2.root/etc/passwd
index 5e3a2a5..5e3a2a5 100644
--- a/grp/tst-initgroups2.root/etc/passwd
+++ b/nss/tst-initgroups2.root/etc/passwd
diff --git a/grp/tst-putgrent.c b/nss/tst-putgrent.c
index 79c1486..79c1486 100644
--- a/grp/tst-putgrent.c
+++ b/nss/tst-putgrent.c
diff --git a/grp/tst_fgetgrent.c b/nss/tst_fgetgrent.c
index be41191..be41191 100644
--- a/grp/tst_fgetgrent.c
+++ b/nss/tst_fgetgrent.c
diff --git a/grp/tst_fgetgrent.sh b/nss/tst_fgetgrent.sh
index 1775a6b..fb6b0c4 100644
--- a/grp/tst_fgetgrent.sh
+++ b/nss/tst_fgetgrent.sh
@@ -21,20 +21,20 @@ set -e
common_objpfx=$1; shift
test_program_prefix=$1; shift
-testout=${common_objpfx}/grp/tst_fgetgrent.out
+testout=${common_objpfx}/nss/tst_fgetgrent.out
result=0
${test_program_prefix} \
-${common_objpfx}grp/tst_fgetgrent 0 > ${testout} || result=1
+${common_objpfx}nss/tst_fgetgrent 0 > ${testout} || result=1
${test_program_prefix} \
-${common_objpfx}grp/tst_fgetgrent 1 >> ${testout} || result=1
+${common_objpfx}nss/tst_fgetgrent 1 >> ${testout} || result=1
${test_program_prefix} \
-${common_objpfx}grp/tst_fgetgrent 2 >> ${testout} || result=1
+${common_objpfx}nss/tst_fgetgrent 2 >> ${testout} || result=1
${test_program_prefix} \
-${common_objpfx}grp/tst_fgetgrent 3 >> ${testout} || result=1
+${common_objpfx}nss/tst_fgetgrent 3 >> ${testout} || result=1
exit $result
diff --git a/posix/Makefile b/posix/Makefile
index c36b9d9..be7d319 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -137,6 +137,7 @@ routines := \
sched_sets \
sched_yield \
setgid \
+ setgroups \
setpgid \
setpgrp \
setresgid \
diff --git a/posix/Versions b/posix/Versions
index 3753810..2eedbc3 100644
--- a/posix/Versions
+++ b/posix/Versions
@@ -53,7 +53,7 @@ libc {
sched_get_priority_max; sched_get_priority_min; sched_getparam;
sched_getscheduler; sched_rr_get_interval; sched_setparam;
sched_setscheduler; sched_yield; setegid; seteuid; setgid;
- setpgid; setpgrp; setsid; setuid; sleep; sysconf;
+ setgroups; setpgid; setpgrp; setsid; setuid; sleep; sysconf;
# t*
times;
diff --git a/grp/setgroups.c b/posix/setgroups.c
index d988866..d988866 100644
--- a/grp/setgroups.c
+++ b/posix/setgroups.c
diff --git a/scripts/update-copyrights b/scripts/update-copyrights
index f6ef6fa..a582fa1 100755
--- a/scripts/update-copyrights
+++ b/scripts/update-copyrights
@@ -65,7 +65,7 @@ for f in $files; do
"$update_script" "$f"
fi
;;
- grp/initgroups.c | misc/bits/stab.def | posix/regex.h \
+ nss/initgroups.c | misc/bits/stab.def | posix/regex.h \
| sysdeps/wordsize-32/divdi3.c)
# Pre-1991 gaps in copyright years, so cannot use a single range.
UPDATE_COPYRIGHT_USE_INTERVALS=1 "$update_script" "$f"