xbps-triggers: system-accounts: introduce <account>_pgroup to set primary group.
While here also change default home directory to /dev/null if unset.
This commit is contained in:
parent
26837c2859
commit
7339b81b43
|
@ -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:
|
||||
|
||||
- `<account>_homedir` the home directory for the user. If unset defaults to `/`.
|
||||
- `<account>_homedir` the home directory for the user. If unset defaults to `/dev/null`.
|
||||
- `<account>_shell` the shell for the new user. If unset defaults to `/sbin/nologin`.
|
||||
- `<account>_descr` the description for the new user. If unset defaults to `<user> unprivileged user`.
|
||||
- `<account>_descr` the description for the new user. If unset defaults to `<account> unprivileged user`.
|
||||
- `<account>_groups` additional groups to be added to for the new user.
|
||||
- `<account>_pgroup` to set the primary group, by default primary group is set to `<account>`.
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Template file for 'xbps-triggers'
|
||||
pkgname=xbps-triggers
|
||||
version=0.91
|
||||
version=0.92
|
||||
revision=1
|
||||
noarch=yes
|
||||
bootstrap=yes
|
||||
|
|
Loading…
Reference in New Issue