[icinga-checkins] icinga.org: icinga2/support/2.2: Make sure that user/ group exists when starting Icinga 2

git at icinga.org git at icinga.org
Tue Nov 25 18:45:01 CET 2014


Module: icinga2
Branch: support/2.2
Commit: 1fcf5d0460d5ecc3fedf0ce8904b870a1eebf6d4
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=1fcf5d0460d5ecc3fedf0ce8904b870a1eebf6d4

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Nov 25 18:42:13 2014 +0100

Make sure that user/group exists when starting Icinga 2

fixes #7173
fixes #7613

---

 etc/initsystem/icinga2-prepare-dirs |   12 ++++++++++++
 etc/initsystem/icinga2.init.d.cmake |   17 ++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/etc/initsystem/icinga2-prepare-dirs b/etc/initsystem/icinga2-prepare-dirs
index 74daa1b..245f065 100644
--- a/etc/initsystem/icinga2-prepare-dirs
+++ b/etc/initsystem/icinga2-prepare-dirs
@@ -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)
diff --git a/etc/initsystem/icinga2.init.d.cmake b/etc/initsystem/icinga2.init.d.cmake
index d9e8ae6..4ec65e4 100644
--- a/etc/initsystem/icinga2.init.d.cmake
+++ b/etc/initsystem/icinga2.init.d.cmake
@@ -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



More information about the icinga-checkins mailing list