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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
From 9f8610184c6984ca271ccd4915c23b328491eae2 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <sthibault@debian.org>
Date: Tue, 24 Jun 2025 23:54:46 +0200
Origin: upstream, https://github.com/cromerc/opensysusers/pull/9
Forwarded: https://github.com/cromerc/opensysusers/pull/9
Bug: https://github.com/cromerc/opensysusers/issues/8
Bug-Debian: https://bugs.debian.org/1105010
Reviewed-by: Andrea Pappacoda <tachi@debian.org>
Subject: [PATCH] Support uid:gid
Note: uid:- does not make sense and is thus rejected
Fixes #8
---
sysusers | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/sysusers b/sysusers
index 8773e33..922e59d 100755
--- a/sysusers
+++ b/sysusers
@@ -22,12 +22,16 @@ add_group() {
}
add_user() {
- # add_user <name> <id> <gecos> <home>
+ # add_user <name> <uid> <gid> <gecos> <home>
if ! id "$1" >/dev/null 2>&1; then
if [ "$2" = '-' ]; then
- useradd --prefix "$root" -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
+ if [ "$3" = '-' ]; then
+ useradd --prefix "$root" -rc "$4" -g "$1" -d "$5" -s '/sbin/nologin' "$1"
+ else
+ useradd --prefix "$root" -rc "$4" -g "$3" -d "$5" -s '/sbin/nologin' "$1"
+ fi
else
- useradd --prefix "$root" -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1"
+ useradd --prefix "$root" -rc "$4" -u "$2" -g "$3" -d "$5" -s '/sbin/nologin' "$1"
fi
passwd --prefix "$root" -l "$1" >/dev/null 2>&1
fi
@@ -91,13 +95,22 @@ parse_string() {
fi
case "${type}" in
- [gu])
- case "${id}" in 65535|4294967295) warninvalid; return; esac
+ u)
+ uid=${id%%:*}
+ gid=${id##*:}
+ case "${uid}" in 65535|4294967295) warninvalid; return; esac
+ case "${gid}" in 65535|4294967295) warninvalid; return; esac
+ if [ "${uid}" != '-' ] && [ "${gid}" = '-' ]; then warninvalid; return; fi
[ "${home:--}" = '-' ] && home='/'
- add_group "${name}" "${id}"
- if [ "${type}" = u ]; then
- add_user "${name}" "${id}" "${gecos}" "${home}"
+ if [ "${uid}" = "${id}" ]; then
+ # No specific gid, create group for this user
+ add_group "${name}" "${id}"
fi
+ add_user "${name}" "${uid}" "${gid}" "${gecos}" "${home}"
+ ;;
+ g)
+ case "${id}" in 65535|4294967295) warninvalid; return; esac
+ add_group "${name}" "${id}"
;;
m)
add_group "${id}" '-'
|