]> granicus.if.org Git - icinga2/commitdiff
Make sure that user/group exists when starting Icinga 2
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 25 Nov 2014 17:42:13 +0000 (18:42 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 25 Nov 2014 17:44:25 +0000 (18:44 +0100)
fixes #7173
fixes #7613

etc/initsystem/icinga2-prepare-dirs
etc/initsystem/icinga2.init.d.cmake

index 74daa1b8cd5eef8d7ff1dfe63a648277e1f9cb79..245f065f91a259b8944f458a0fd7926e411012c0 100644 (file)
@@ -12,8 +12,20 @@ else
        exit 1
 fi
 
+
 ICINGA2_USER=`$DAEMON variable get --current RunAsUser`
+if [ $? != 0 ]; then
+        echo "Could not fetch RunAsUser variable. Error '$ICINGA2_USER'. Exiting."
+        exit 6
+fi
+
 ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup`
+if [ $? != 0 ]; then
+        echo "Could not fetch RunAsGroup variable. Error '$ICINGA2_GROUP'. Exiting."
+        exit 6
+fi
+
+getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || echo "Command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6
 
 mkdir -p $(dirname -- $ICINGA2_PID_FILE)
 chown $ICINGA2_USER:$ICINGA2_GROUP $(dirname -- $ICINGA2_PID_FILE)
index d9e8ae63f375ae41a527d25d9b3a277ed157d3f0..4ec65e486190a05880004a657745bfb8f8d9488a 100644 (file)
@@ -26,14 +26,25 @@ fi
 
 test -x $DAEMON || exit 5
 
+if [ ! -e $ICINGA2_CONFIG_FILE ]; then
+       echo "Config file '$ICINGA2_CONFIG_FILE' does not exist."
+       exit 6
+fi
+
 ICINGA2_USER=`$DAEMON variable get --current RunAsUser`
-ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup`
+if [ $? != 0 ]; then
+        echo "Could not fetch RunAsUser variable. Error '$ICINGA2_USER'. Exiting."
+        exit 6
+fi
 
-if [ ! -e $ICINGA2_CONFIG_FILE ]; then
-        echo "Config file '$ICINGA2_CONFIG_FILE' does not exist."
+ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup`
+if [ $? != 0 ]; then
+        echo "Could not fetch RunAsGroup variable. Error '$ICINGA2_GROUP'. Exiting."
         exit 6
 fi
 
+getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || echo "Command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6
+
 # Get function from functions library
 if [ -f /etc/rc.d/init.d/functions ]; then
         . /etc/rc.d/init.d/functions