File: fix-root-option.patch

package info (click to toggle)
opensysusers 0.7.3-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 476 kB
  • sloc: xml: 578; sh: 239; makefile: 194
file content (53 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Description: Fix --root option
 This patch fixes the behaviour of the --root option, by actually prepending
 all paths with the given prefix.
Author: Andrea Pappacoda <andrea@pappacoda.it>
Bug: https://github.com/cromerc/opensysusers/issues/4
Bug-Debian: https://bugs.debian.org/1055517
Forwarded: https://github.com/cromerc/opensysusers/issues/4#issuecomment-2351643543
Last-Update: 2024-09-15

--- opensysusers-0.7.3.orig/sysusers
+++ opensysusers-0.7.3/sysusers
@@ -15,9 +15,9 @@ warninvalid() {
 add_group() {
 	# add_group <name> <id>
 	if [ "$2" = '-' ]; then
-		grep -q "^$1:" /etc/group || groupadd -r "$1"
-	elif ! grep -q "^$1:\|^[^:]*:[^:]*:$2:[^:]*$" /etc/group; then
-		groupadd -g "$2" "$1"
+		grep -q "^$1:" "$root/etc/group" || groupadd --prefix "$root" -r "$1"
+	elif ! grep -q "^$1:\|^[^:]*:[^:]*:$2:[^:]*$" "$root/etc/group"; then
+		groupadd --prefix "$root" -g "$2" "$1"
 	fi
 }
 
@@ -25,11 +25,11 @@ add_user() {
 	# add_user <name> <id> <gecos> <home>
 	if ! id "$1" >/dev/null 2>&1; then
 		if [ "$2" = '-' ]; then
-			useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
+			useradd --prefix "$root" -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
 		else
-			useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
+			useradd --prefix "$root" -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
 		fi
-		passwd -l "$1" >/dev/null 2>&1
+		passwd --prefix "$root" -l "$1" >/dev/null 2>&1
 	fi
 }
 
@@ -102,10 +102,10 @@ parse_string() {
 		m)
 			add_group "${id}" '-'
 			if id "${name}" >/dev/null 2>&1; then
-				usermod -a -G "${id}" "${name}"
+				usermod --prefix "$root" -a -G "${id}" "${name}"
 			else
-				useradd -r -g "${id}" -s '/sbin/nologin' "${name}"
-				passwd -l "${name}" >/dev/null 2>&1
+				useradd --prefix "$root" -r -g "${id}" -s '/sbin/nologin' "${name}"
+				passwd --prefix "$root" -l "${name}" >/dev/null 2>&1
 			fi
 		;;
 		r)