Blame SOURCES/shadow-4.9-getsubids.patch

9746fa
diff -up shadow-4.9/man/getsubids.1.xml.getsubids shadow-4.9/man/getsubids.1.xml
9746fa
--- shadow-4.9/man/getsubids.1.xml.getsubids	2021-11-18 16:27:33.951053120 +0100
9746fa
+++ shadow-4.9/man/getsubids.1.xml	2021-11-18 16:27:33.951053120 +0100
9746fa
@@ -0,0 +1,141 @@
9746fa
+
9746fa
+
9746fa
+   Copyright (c) 2021 Iker Pedrosa
9746fa
+   All rights reserved.
9746fa
+
9746fa
+   Redistribution and use in source and binary forms, with or without
9746fa
+   modification, are permitted provided that the following conditions
9746fa
+   are met:
9746fa
+   1. Redistributions of source code must retain the above copyright
9746fa
+      notice, this list of conditions and the following disclaimer.
9746fa
+   2. Redistributions in binary form must reproduce the above copyright
9746fa
+      notice, this list of conditions and the following disclaimer in the
9746fa
+      documentation and/or other materials provided with the distribution.
9746fa
+   3. The name of the copyright holders or contributors may not be used to
9746fa
+      endorse or promote products derived from this software without
9746fa
+      specific prior written permission.
9746fa
+
9746fa
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9746fa
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
9746fa
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
9746fa
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
9746fa
+   HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9746fa
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9746fa
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
9746fa
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
9746fa
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9746fa
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
9746fa
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9746fa
+-->
9746fa
+
9746fa
+  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
9746fa
+
9746fa
+]>
9746fa
+
9746fa
+<refentry id='getsubids.1'>
9746fa
+  <refentryinfo>
9746fa
+    <author>
9746fa
+      <firstname>Iker</firstname>
9746fa
+      <surname>Pedrosa</surname>
9746fa
+      <contrib>Creation, 2021</contrib>
9746fa
+    </author>
9746fa
+  </refentryinfo>
9746fa
+  <refmeta>
9746fa
+    <refentrytitle>getsubids</refentrytitle>
9746fa
+    <manvolnum>1</manvolnum>
9746fa
+    <refmiscinfo class="sectdesc">User Commands</refmiscinfo>
9746fa
+    <refmiscinfo class="source">shadow-utils</refmiscinfo>
9746fa
+    <refmiscinfo class="version">&SHADOW_UTILS_VERSION;</refmiscinfo>
9746fa
+  </refmeta>
9746fa
+  <refnamediv id='name'>
9746fa
+    <refname>getsubids</refname>
9746fa
+    <refpurpose>get the subordinate id ranges for a user</refpurpose>
9746fa
+  </refnamediv>
9746fa
+
9746fa
+  <refsynopsisdiv id='synopsis'>
9746fa
+    <cmdsynopsis>
9746fa
+      <command>getsubids</command>
9746fa
+      <arg choice='opt'>
9746fa
+        <replaceable>options</replaceable>
9746fa
+      </arg>
9746fa
+      <arg choice='plain'>
9746fa
+        <replaceable>USER</replaceable>
9746fa
+      </arg>
9746fa
+    </cmdsynopsis>
9746fa
+  </refsynopsisdiv>
9746fa
+
9746fa
+  <refsect1 id='description'>
9746fa
+    <title>DESCRIPTION</title>
9746fa
+    <para>
9746fa
+      The <command>getsubids</command> command lists the subordinate user ID
9746fa
+      ranges for a given user. The subordinate group IDs can be listed using
9746fa
+      the <option>-g</option> option.
9746fa
+    </para>
9746fa
+  </refsect1>
9746fa
+
9746fa
+  <refsect1 id='options'>
9746fa
+    <title>OPTIONS</title>
9746fa
+    <para>
9746fa
+      The options which apply to the <command>getsubids</command> command are:
9746fa
+    </para>
9746fa
+    <variablelist remap='IP'>
9746fa
+      <varlistentry>
9746fa
+        <term>
9746fa
+          <option>-g</option>
9746fa
+        </term>
9746fa
+        <listitem>
9746fa
+          <para>
9746fa
+            List the subordinate group ID ranges.
9746fa
+          </para>
9746fa
+        </listitem>
9746fa
+      </varlistentry>
9746fa
+    </variablelist>
9746fa
+  </refsect1>
9746fa
+
9746fa
+  <refsect1 id='example'>
9746fa
+    <title>EXAMPLE</title>
9746fa
+    <para>
9746fa
+      For example, to obtain the subordinate UIDs of the testuser:
9746fa
+    </para>
9746fa
+    <para>
9746fa
+<programlisting>
9746fa
+$ getsubids testuser
9746fa
+0: testuser 100000 65536
9746fa
+</programlisting>
9746fa
+    </para>
9746fa
+    <para>
9746fa
+      This command output provides (in order from left to right) the list
9746fa
+      index, username, UID range start, and number of UIDs in range.
9746fa
+    </para>
9746fa
+  </refsect1>
9746fa
+
9746fa
+  <refsect1 id='see_also'>
9746fa
+    <title>SEE ALSO</title>
9746fa
+    <para>
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>login.defs</refentrytitle><manvolnum>5</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>newgidmap</refentrytitle><manvolnum>1</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>newuidmap</refentrytitle><manvolnum>1</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>subgid</refentrytitle><manvolnum>5</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>subuid</refentrytitle><manvolnum>5</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>useradd</refentrytitle><manvolnum>8</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>userdel</refentrytitle><manvolnum>8</manvolnum>
9746fa
+      </citerefentry>.
9746fa
+      <citerefentry>
9746fa
+        <refentrytitle>usermod</refentrytitle><manvolnum>8</manvolnum>
9746fa
+      </citerefentry>,
9746fa
+    </para>
9746fa
+  </refsect1>
9746fa
+</refentry>
9746fa
diff -up shadow-4.9/man/Makefile.am.getsubids shadow-4.9/man/Makefile.am
9746fa
--- shadow-4.9/man/Makefile.am.getsubids	2021-07-22 23:55:35.000000000 +0200
9746fa
+++ shadow-4.9/man/Makefile.am	2021-11-18 16:27:33.951053120 +0100
9746fa
@@ -62,6 +62,7 @@ man_MANS += $(man_nopam)
9746fa
 endif
9746fa
 
9746fa
 man_subids = \
9746fa
+	man1/getsubids.1 \
9746fa
 	man1/newgidmap.1 \
9746fa
 	man1/newuidmap.1 \
9746fa
 	man5/subgid.5 \
9746fa
@@ -80,6 +81,7 @@ man_XMANS = \
9746fa
 	expiry.1.xml \
9746fa
 	faillog.5.xml \
9746fa
 	faillog.8.xml \
9746fa
+	getsubids.1.xml \
9746fa
 	gpasswd.1.xml \
9746fa
 	groupadd.8.xml \
9746fa
 	groupdel.8.xml \
9746fa
diff -up shadow-4.9/src/getsubids.c.getsubids shadow-4.9/src/getsubids.c
9746fa
--- shadow-4.9/src/getsubids.c.getsubids	2021-11-18 16:27:33.951053120 +0100
9746fa
+++ shadow-4.9/src/getsubids.c	2021-11-18 16:27:33.951053120 +0100
9746fa
@@ -0,0 +1,46 @@
9746fa
+#include <stdio.h>
9746fa
+#include <string.h>
9746fa
+#include <stdlib.h>
9746fa
+#include "subid.h"
9746fa
+#include "prototypes.h"
9746fa
+
9746fa
+const char *Prog;
9746fa
+FILE *shadow_logfd = NULL;
9746fa
+
9746fa
+void usage(void)
9746fa
+{
9746fa
+	fprintf(stderr, "Usage: %s [-g] user\n", Prog);
9746fa
+	fprintf(stderr, "    list subuid ranges for user\n");
9746fa
+	fprintf(stderr, "    pass -g to list subgid ranges\n");
9746fa
+	exit(EXIT_FAILURE);
9746fa
+}
9746fa
+
9746fa
+int main(int argc, char *argv[])
9746fa
+{
9746fa
+	int i, count=0;
9746fa
+	struct subid_range *ranges;
9746fa
+	const char *owner;
9746fa
+
9746fa
+	Prog = Basename (argv[0]);
9746fa
+	shadow_logfd = stderr;
9746fa
+	if (argc < 2)
9746fa
+		usage();
9746fa
+	owner = argv[1];
9746fa
+	if (argc == 3 && strcmp(argv[1], "-g") == 0) {
9746fa
+		owner = argv[2];
9746fa
+		count = get_subgid_ranges(owner, &ranges;;
9746fa
+	} else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
9746fa
+		usage();
9746fa
+	} else {
9746fa
+		count = get_subuid_ranges(owner, &ranges;;
9746fa
+	}
9746fa
+	if (!ranges) {
9746fa
+		fprintf(stderr, "Error fetching ranges\n");
9746fa
+		exit(1);
9746fa
+	}
9746fa
+	for (i = 0; i < count; i++) {
9746fa
+		printf("%d: %s %lu %lu\n", i, owner,
9746fa
+			ranges[i].start, ranges[i].count);
9746fa
+	}
9746fa
+	return 0;
9746fa
+}
9746fa
diff -up shadow-4.9/src/list_subid_ranges.c.getsubids shadow-4.9/src/list_subid_ranges.c
9746fa
diff -up shadow-4.9/src/Makefile.am.getsubids shadow-4.9/src/Makefile.am
9746fa
--- shadow-4.9/src/Makefile.am.getsubids	2021-11-18 16:27:33.943053061 +0100
9746fa
+++ shadow-4.9/src/Makefile.am	2021-11-18 16:28:03.647272392 +0100
9746fa
@@ -157,8 +157,8 @@ if FCAPS
9746fa
 	setcap cap_setgid+ep $(DESTDIR)$(ubindir)/newgidmap
9746fa
 endif
9746fa
 
9746fa
-noinst_PROGRAMS += list_subid_ranges  \
9746fa
-					get_subid_owners \
9746fa
+bin_PROGRAMS    +=  getsubids
9746fa
+noinst_PROGRAMS +=  get_subid_owners \
9746fa
 					new_subid_range \
9746fa
 					free_subid_range \
9746fa
 					check_subid_range
9746fa
@@ -174,13 +174,13 @@ MISCLIBS = \
9746fa
 	$(LIBCRYPT) \
9746fa
 	$(LIBTCB)
9746fa
 
9746fa
-list_subid_ranges_LDADD = \
9746fa
+getsubids_LDADD = \
9746fa
 	$(top_builddir)/lib/libshadow.la \
9746fa
 	$(top_builddir)/libmisc/libmisc.la \
9746fa
 	$(top_builddir)/libsubid/libsubid.la \
9746fa
 	$(MISCLIBS) -ldl
9746fa
 
9746fa
-list_subid_ranges_CPPFLAGS = \
9746fa
+getsubids_CPPFLAGS = \
9746fa
 	-I$(top_srcdir)/lib \
9746fa
 	-I$(top_srcdir)/libmisc \
9746fa
 	-I$(top_srcdir)/libsubid