sysusers/generate: bridge 'm' entries to usermod
This tweaks the sysusers.d handling logic so that 'm' entries are now translated to a series of groupadd + useradd + usermod call. The last usermod call is the notable change, effectively affecting the list of secondary groups now.
This commit is contained in:
parent
7665e1796f
commit
f27d461663
|
@ -38,6 +38,7 @@ EOF
|
||||||
group() {
|
group() {
|
||||||
group="$1"
|
group="$1"
|
||||||
gid="$2"
|
gid="$2"
|
||||||
|
|
||||||
if [ "$gid" = '-' ]; then
|
if [ "$gid" = '-' ]; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
getent group '$group' >/dev/null || groupadd -r '$group' || :
|
getent group '$group' >/dev/null || groupadd -r '$group' || :
|
||||||
|
@ -49,6 +50,17 @@ group() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usermod() {
|
||||||
|
user="$1"
|
||||||
|
group="$2"
|
||||||
|
|
||||||
|
cat <<-EOF
|
||||||
|
if getent group '$group' >/dev/null; then
|
||||||
|
usermod -a -G '$group' '$user' || :
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
parse() {
|
parse() {
|
||||||
while read -r line || [ -n "$line" ] ; do
|
while read -r line || [ -n "$line" ] ; do
|
||||||
{ [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue
|
{ [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue
|
||||||
|
@ -66,7 +78,8 @@ parse() {
|
||||||
;;
|
;;
|
||||||
('m')
|
('m')
|
||||||
group "${arr[2]}" "-"
|
group "${arr[2]}" "-"
|
||||||
user "${arr[1]}" "-" "" "${arr[2]}"
|
user "${arr[1]}" "-" "" "${arr[1]}" "" ""
|
||||||
|
usermod "${arr[1]}" "${arr[2]}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue