From 3b6ccf642c6bb2b7db087f09ee563ae9318af734 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Wed, 10 Nov 2021 09:54:59 +0100 Subject: [PATCH] getsubids: system binary for user's sub*ids Rename list_subid_ranges to getsubids to provide a system binary to check the sub*ids of a user. The intention is to provide this binary with any distribution that includes the subid feature, so that system administrators can check the subid ranges of a given user. Finally, add a man page to explain the behaviour of getsubids. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1980780 Signed-off-by: Iker Pedrosa --- man/Makefile.am | 2 + man/getsubids.1.xml | 141 ++++++++++++++++++ src/.gitignore | 2 +- src/Makefile.am | 8 +- src/{list_subid_ranges.c => getsubids.c} | 3 +- .../libsubid/01_list_ranges/list_ranges.test | 4 +- 6 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 man/getsubids.1.xml rename src/{list_subid_ranges.c => getsubids.c} (95%) diff --git a/man/Makefile.am b/man/Makefile.am index f0f5c44b..e9cab28a 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -62,6 +62,7 @@ man_MANS += $(man_nopam) endif man_subids = \ + man1/getsubids.1 \ man1/newgidmap.1 \ man1/newuidmap.1 \ man5/subgid.5 \ @@ -80,6 +81,7 @@ man_XMANS = \ expiry.1.xml \ faillog.5.xml \ faillog.8.xml \ + getsubids.1.xml \ gpasswd.1.xml \ groupadd.8.xml \ groupdel.8.xml \ diff --git a/man/getsubids.1.xml b/man/getsubids.1.xml new file mode 100644 index 00000000..200ed35f --- /dev/null +++ b/man/getsubids.1.xml @@ -0,0 +1,141 @@ + + + +]> + + + + + Iker + Pedrosa + Creation, 2021 + + + + getsubids + 1 + User Commands + shadow-utils + &SHADOW_UTILS_VERSION; + + + getsubids + get the subordinate id ranges for a user + + + + + getsubids + + options + + + USER + + + + + + DESCRIPTION + + The getsubids command lists the subordinate user ID + ranges for a given user. The subordinate group IDs can be listed using + the option. + + + + + OPTIONS + + The options which apply to the getsubids command are: + + + + + + + + + List the subordinate group ID ranges. + + + + + + + + EXAMPLE + + For example, to obtain the subordinate UIDs of the testuser: + + + +$ getsubids testuser +0: testuser 100000 65536 + + + + This command output provides (in order from left to right) the list + index, username, UID range start, and number of UIDs in range. + + + + + SEE ALSO + + + login.defs5 + , + + newgidmap1 + , + + newuidmap1 + , + + subgid5 + , + + subuid5 + , + + useradd8 + , + + userdel8 + . + + usermod8 + , + + + diff --git a/src/.gitignore b/src/.gitignore index 24d832bc..5fffda77 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -34,7 +34,7 @@ /usermod /vipw /get_subid_owners -/list_subid_ranges +/getsubids /new_subid_range /free_subid_range /check_subid_range diff --git a/src/Makefile.am b/src/Makefile.am index 6cc873be..a1a2e4e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -158,8 +158,8 @@ if FCAPS setcap cap_setgid+ep $(DESTDIR)$(ubindir)/newgidmap endif -noinst_PROGRAMS += list_subid_ranges \ - get_subid_owners \ +bin_PROGRAMS += getsubids +noinst_PROGRAMS += get_subid_owners \ new_subid_range \ free_subid_range \ check_subid_range @@ -175,13 +175,13 @@ MISCLIBS = \ $(LIBCRYPT) \ $(LIBTCB) -list_subid_ranges_LDADD = \ +getsubids_LDADD = \ $(top_builddir)/lib/libshadow.la \ $(top_builddir)/libmisc/libmisc.la \ $(top_builddir)/libsubid/libsubid.la \ $(MISCLIBS) -ldl -list_subid_ranges_CPPFLAGS = \ +getsubids_CPPFLAGS = \ -I$(top_srcdir)/lib \ -I$(top_srcdir)/libmisc \ -I$(top_srcdir) \ diff --git a/src/list_subid_ranges.c b/src/getsubids.c similarity index 95% rename from src/list_subid_ranges.c rename to src/getsubids.c index f649a002..109b22bc 100644 --- a/src/list_subid_ranges.c +++ b/src/getsubids.c @@ -1,6 +1,7 @@ #include +#include +#include #include "subid.h" -#include "stdlib.h" #include "prototypes.h" const char *Prog; diff --git a/tests/libsubid/01_list_ranges/list_ranges.test b/tests/libsubid/01_list_ranges/list_ranges.test index b131303b..37af1256 100755 --- a/tests/libsubid/01_list_ranges/list_ranges.test +++ b/tests/libsubid/01_list_ranges/list_ranges.test @@ -17,8 +17,8 @@ trap 'log_status "$0" "FAILURE"; restore_config' 0 change_config echo -n "list foo's ranges..." -${build_path}/src/list_subid_ranges foo > /tmp/subuidlistout -${build_path}/src/list_subid_ranges -g foo > /tmp/subgidlistout +${build_path}/src/getsubids foo > /tmp/subuidlistout +${build_path}/src/getsubids -g foo > /tmp/subgidlistout echo "OK" echo -n "Check the subuid ranges..."