]> granicus.if.org Git - ejabberd/commitdiff
ejabberdctl: Create home directory as root
authorHolger Weiss <holger@zedat.fu-berlin.de>
Thu, 24 Jul 2014 15:16:47 +0000 (17:16 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Thu, 24 Jul 2014 15:16:47 +0000 (17:16 +0200)
If the $INSTALLUSER is not root, he will usually not have the necessary
permissions to create his home directory.

ejabberdctl.template

index b9f372514fb12f868b1e331ef03aeef89274b877..a4d4680e259ab8ee15a6e0efb6ab9a1968db3b88 100755 (executable)
@@ -23,6 +23,14 @@ if [ "$INSTALLUSER" != "" ] ; then
     for GID in `id -G`; do
         if [ $GID -eq 0 ] ; then
             INSTALLUSER_HOME=$(getent passwd "$INSTALLUSER" | cut -d: -f6)
+            if [ -z "$INSTALLUSER_HOME" ] ; then
+                echo "Cannot determine home directory of $INSTALLUSER" >&2
+                exit 1
+            fi
+            if [ ! -d "$INSTALLUSER_HOME" ] ; then
+                mkdir -p "$INSTALLUSER_HOME"
+                chown "$INSTALLUSER" "$INSTALLUSER_HOME"
+            fi
             EXEC_CMD="env HOME=$INSTALLUSER_HOME su $INSTALLUSER -p -c"
         fi
     done
@@ -143,10 +151,6 @@ fi
 [ -z "$date" ] || EJABBERD_OPTS="${EJABBERD_OPTS} log_rotate_date '$date'"
 [ -z "$EJABBERD_OPTS" ] || EJABBERD_OPTS="-ejabberd ${EJABBERD_OPTS}"
 
-# create the ejabberd home dir with the proper user if doesn't exist
-# then change to that directory readable by INSTALLUSER to
-# prevent "File operation error: eacces." messages
-[ -d $HOME ] || $EXEC_CMD "mkdir -p $HOME"
 [ -d $SPOOL_DIR ] || $EXEC_CMD "mkdir -p $SPOOL_DIR"
 # then set SPOOL_DIR as ejabberd home directory by changing
 # to that directory readable by INSTALLUSER to prevent