From 7339b81b4372b333161befb0dd42feaf3585302d Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 23 Feb 2015 22:09:20 +0100 Subject: [PATCH] xbps-triggers: system-accounts: introduce _pgroup to set primary group. While here also change default home directory to /dev/null if unset. --- Manual.md | 5 +++-- .../post-install/04-create-xbps-metadata-scripts.sh | 6 +++++- srcpkgs/xbps-triggers/files/system-accounts | 9 +++++---- srcpkgs/xbps-triggers/template | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) mode change 100755 => 100644 srcpkgs/xbps-triggers/files/system-accounts diff --git a/Manual.md b/Manual.md index a80e486a74e..231ff895f1b 100644 --- a/Manual.md +++ b/Manual.md @@ -793,10 +793,11 @@ separated by blanks, i.e `system_accounts="foo blah:22"`. Optionally the **uid** can be specified by delimiting it with a color, i.e `system_accounts="foo:48"`. Additional variables for the **system accounts** can be specified to change its behavior: - - `_homedir` the home directory for the user. If unset defaults to `/`. + - `_homedir` the home directory for the user. If unset defaults to `/dev/null`. - `_shell` the shell for the new user. If unset defaults to `/sbin/nologin`. - - `_descr` the description for the new user. If unset defaults to ` unprivileged user`. + - `_descr` the description for the new user. If unset defaults to ` unprivileged user`. - `_groups` additional groups to be added to for the new user. + - `_pgroup` to set the primary group, by default primary group is set to ``. The **system user** is created by using a dynamically allocated **uid/gid** in your system and it's created as a `system account`, unless the **uid** is set. A new group will be created for the diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh index edb4b83bfb3..a7e15d06db5 100644 --- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh +++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh @@ -90,6 +90,7 @@ _EOF eval shell="\$${_uname}_shell" eval descr="\$${_uname}_descr" eval groups="\$${_uname}_groups" + eval pgroup="\$${_uname}_pgroup" if [ -n "$homedir" ]; then echo "export ${_uname}_homedir=\"$homedir\"" >> $tmpf fi @@ -102,7 +103,10 @@ _EOF if [ -n "$groups" ]; then echo "export ${_uname}_groups=\"${groups}\"" >> $tmpf fi - unset homedir shell descr groups + if [ -n "$pgroup" ]; then + echo "export ${_uname}_pgroup=\"${pgroup}\"" >> $tmpf + fi + unset homedir shell descr groups pgroup done fi # diff --git a/srcpkgs/xbps-triggers/files/system-accounts b/srcpkgs/xbps-triggers/files/system-accounts old mode 100755 new mode 100644 index e41ce37fe80..f9cf00a57e4 --- a/srcpkgs/xbps-triggers/files/system-accounts +++ b/srcpkgs/xbps-triggers/files/system-accounts @@ -89,7 +89,8 @@ run) eval shell="\$${_uname}_shell" eval descr="\$${_uname}_descr" eval groups="\$${_uname}_groups" - [ -z "$homedir" ] && homedir="/" + eval pgroup="\$${_uname}_pgroup" + [ -z "$homedir" ] && homedir="/dev/null" [ -z "$shell" ] && shell="/sbin/nologin" [ -z "$descr" ] && descr="${_uname} unprivileged user" [ -n "$groups" ] && user_groups="-G $groups" @@ -105,11 +106,11 @@ run) continue fi - group_add ${acct} + group_add ${pgroup:-${acct}} if ! getent passwd ${_uname} >/dev/null; then - useradd -c "$descr" -d "$homedir" -s "$shell" \ - ${user_groups} ${use_id:=-g ${_uname}} -r ${_uname} && \ + useradd -c "$descr" -d "$homedir" -s "$shell" ${user_groups} \ + ${pgroup:+-N} ${use_id:=-g ${pgroup:-${_uname}}} -r ${_uname} && \ passwd -l ${_uname} >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "Created ${_uname} (${_uid}) system user." diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index 846cb637e22..5cb2aee0ee1 100644 --- a/srcpkgs/xbps-triggers/template +++ b/srcpkgs/xbps-triggers/template @@ -1,6 +1,6 @@ # Template file for 'xbps-triggers' pkgname=xbps-triggers -version=0.91 +version=0.92 revision=1 noarch=yes bootstrap=yes