Fix edge cases when specifying the user to run as.

* check the username fits the format expected by adduser;
 * don't allow root;
 * if the user exists, don't try to create it; usually, this is
   harmless, but it fails if the user exists with a UID outside the
   normal range for system users.

Fixes .
This commit is contained in:
Oliver Jowett 2015-02-19 22:41:39 +00:00
parent f391bf4b22
commit ab8c4db85b
5 changed files with 34 additions and 6 deletions

View file

@ -97,7 +97,10 @@ case "$1" in
db_get $NAME/auto-start
if [ "$RET" = "true" ]; then
db_get $NAME/run-as-user
adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RET"
if ! getent passwd "$RET" >/dev/null
then
adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RET"
fi
fi
# -10 changed the lighttpd config file, but didn't arrange to restart it.