From 83301531c0aa22ffc155096826d8f5250c6a880a Mon Sep 17 00:00:00 2001 From: Martin Osvald Date: Nov 24 2022 12:35:27 +0000 Subject: Support user:group notation by sysusers.generate-pre.sh script #Type Name ID GECOS Home directory Shell u user_name uid:gid "User Description" /home/dir /path/to/shell According to: https://www.freedesktop.org/software/systemd/man/sysusers.d.html --- diff --git a/sysusers.generate-pre.sh b/sysusers.generate-pre.sh index 862cb77..a077bb7 100755 --- a/sysusers.generate-pre.sh +++ b/sysusers.generate-pre.sh @@ -70,9 +70,12 @@ parse() { eval "arr=( $line )" case "${arr[0]}" in ('u') - group "${arr[1]}" "${arr[2]}" - user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}" - # TODO: user:group support + if [[ "${arr[2]}" == *":"* ]]; then + user "${arr[1]}" "${arr[2]%:*}" "${arr[3]}" "${arr[2]#*:}" "${arr[4]}" "${arr[5]}" + else + group "${arr[1]}" "${arr[2]}" + user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}" + fi ;; ('g') group "${arr[1]}" "${arr[2]}"