sysusers.generate-pre.sh: properly escape quotes in description strings
... (rhbz#2104141) In the first version, I wanted to use POSIX quotes with $''. But that required 'printf %q', which brings in a dependency on coreutils. Following mcr0mmand's suggestion, ${foo@Q} is used instead, which should work equivalently, and does not require anything new. Tested with 'sysusers.generate-pre.sh /usr/lib/sysusers.d/*conf'. The output is the same before and after, apart from the dovecot user with a quote. rhel-only Resolves: #2217149
This commit is contained in:
parent
00374b7b6e
commit
66144f688d
@ -20,15 +20,15 @@ user() {
|
||||
if [ "$uid" = '-' ] || [ "$uid" = '' ]; then
|
||||
cat <<-EOF
|
||||
getent passwd '$user' >/dev/null || \\
|
||||
useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user' || :
|
||||
useradd -r -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || :
|
||||
EOF
|
||||
else
|
||||
cat <<-EOF
|
||||
if ! getent passwd '$user' >/dev/null; then
|
||||
if ! getent passwd '$uid' >/dev/null; then
|
||||
useradd -r -u '$uid' -g '$group' -d '$home' -s '$shell' -c '$desc' '$user' || :
|
||||
if ! getent passwd ${user@Q} >/dev/null; then
|
||||
if ! getent passwd ${uid@Q} >/dev/null; then
|
||||
useradd -r -u ${uid@Q} -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || :
|
||||
else
|
||||
useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user' || :
|
||||
useradd -r -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || :
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -42,11 +42,11 @@ group() {
|
||||
|
||||
if [ "$gid" = '-' ]; then
|
||||
cat <<-EOF
|
||||
getent group '$group' >/dev/null || groupadd -r '$group' || :
|
||||
getent group ${group@Q} >/dev/null || groupadd -r ${group@Q} || :
|
||||
EOF
|
||||
else
|
||||
cat <<-EOF
|
||||
getent group '$group' >/dev/null || groupadd -f -g '$gid' -r '$group' || :
|
||||
getent group ${group@Q} >/dev/null || groupadd -f -g ${gid@Q} -r ${group@Q} || :
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
@ -56,8 +56,8 @@ usermod() {
|
||||
group="$2"
|
||||
|
||||
cat <<-EOF
|
||||
if getent group '$group' >/dev/null; then
|
||||
usermod -a -G '$group' '$user' || :
|
||||
if getent group ${group@Q} >/dev/null; then
|
||||
usermod -a -G ${group@Q} '$user' || :
|
||||
fi
|
||||
EOF
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user