Merge pull request #715 from tom-ee/improve__user-type
* explicitly check for `absent` to handle state-typos gracefully * add messaging * redirect stdout+stderr of `userdel` If no mail-spoolfile exists for the user the error reporting was visible in the cdist-run. * add new messages to man.rst * quote "remote user", ensuring `user` is handled as one parameter * fix [SC1117] (explicitly excaping `\n`)
This commit is contained in:
commit
09bd321c5c
2 changed files with 13 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2013 Daniel Heule (hda at sfs.biz)
|
||||
# 2018 Thomas Eckert (tom at it-eckert.de)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -130,13 +131,17 @@ if [ "$state" = "present" ]; then
|
|||
echo useradd "$@" "$name"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
elif [ "$state" = "absent" ]; then
|
||||
if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||
#user exists, but state != present, so delete it
|
||||
if [ -f "$__object/parameter/remove-home" ]; then
|
||||
echo userdel -r "${name}"
|
||||
printf "userdel -r '%s' >/dev/null 2>&1\\n" "${name}"
|
||||
echo "userdel -r" >> "$__messages_out"
|
||||
else
|
||||
echo userdel "${name}"
|
||||
printf "userdel '%s' >/dev/null 2>&1\\n" "${name}"
|
||||
echo "userdel" >> "$__messages_out"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Invalid state $state" >&2
|
||||
fi
|
||||
|
|
|
@ -60,6 +60,11 @@ mod
|
|||
add
|
||||
New user added
|
||||
|
||||
userdel -r
|
||||
If user was deleted with homedir
|
||||
|
||||
userdel
|
||||
If user was deleted (keeping homedir)
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
|
Loading…
Reference in a new issue