From: Gunnar Beutner <gunnar.beutner@netways.de>
Date: Mon, 20 Oct 2014 19:41:04 +0000 (+0200)
Subject: Remove {DAEMON,ICINGA2}_USER and {DAEMON,ICINGA2}_GROUP variables
X-Git-Tag: v2.2.0~319
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e17eadf8f87b0d7d12cb3011737ff6a0889a134;p=icinga2

Remove {DAEMON,ICINGA2}_USER and {DAEMON,ICINGA2}_GROUP variables

refs #7370
---

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10461a032..e13d08856 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,6 @@ include(GNUInstallDirs)
 
 set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
 set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
-set(ICINGA2_COMMAND_USER "icinga" CACHE STRING "Icinga 2 command user")
 set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
 set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
 set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
diff --git a/INSTALL.md b/INSTALL.md
index 871005da2..a3019fe39 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -135,7 +135,6 @@ variables are supported:
 
 - `ICINGA2_USER`: The user Icinga 2 should run as; defaults to `icinga`
 - `ICINGA2_GROUP`: The group Icinga 2 should run as; defaults to `icinga`
-- `ICINGA2_COMMAND_USER`: The command user Icinga 2 should use; defaults to `icinga`
 - `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
 - `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
 - `ICINGA2_UNITY_BUILD`: Whether to perform a unity build
diff --git a/debian/icinga2-common.icinga2.default b/debian/icinga2-common.icinga2.default
index 6df5df10a..3b709684e 100644
--- a/debian/icinga2-common.icinga2.default
+++ b/debian/icinga2-common.icinga2.default
@@ -1,7 +1,5 @@
 # default settings for icinga2's initscript
 
 #DAEMON_CONFIG="/etc/icinga2/icinga2.conf"
-#DAEMON_USER=nagios
-#DAEMON_GROUP=nagios
 #DAEMON_CMDGROUP=www-data
 #DAEMON_ARGS="-e /var/log/icinga2/icinga2.err"
diff --git a/debian/icinga2-common.icinga2.init b/debian/icinga2-common.icinga2.init
index e04ff4597..8d0ef3f76 100644
--- a/debian/icinga2-common.icinga2.init
+++ b/debian/icinga2-common.icinga2.init
@@ -17,8 +17,6 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
 DESC="icinga2 monitoring daemon"
 NAME=icinga2
 DAEMON=/usr/sbin/icinga2
-DAEMON_USER=nagios
-DAEMON_GROUP=nagios
 DAEMON_CMDGROUP=www-data
 DAEMON_ARGS="-e /var/log/icinga2/icinga2.err"
 STARTUP_LOG="/var/log/icinga2/startup.log"
@@ -28,6 +26,9 @@ SCRIPTNAME=/etc/init.d/$NAME
 # Exit if the package is not installed
 [ -x "$DAEMON" ] || exit 0
 
+DAEMON_USER=`$DAEMON variable get --current RunAsUser`
+DAEMON_GROUP=`$DAEMON variable get --current RunAsGroup`
+
 # Read configuration variable file if it is present
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
diff --git a/debian/rules b/debian/rules
index acb0b8406..b5f99c136 100755
--- a/debian/rules
+++ b/debian/rules
@@ -25,7 +25,6 @@ override_dh_auto_configure:
 		-DICINGA2_RUNDIR=/run \
 		-DICINGA2_USER=nagios \
 		-DICINGA2_GROUP=nagios \
-		-DICINGA2_COMMAND_USER=nagios \
 		-DICINGA2_COMMAND_GROUP=www-data \
 		-DICINGA2_PLUGINDIR=/usr/lib/nagios/plugins \
 		-DICINGA2_UNITY_BUILD=TRUE
diff --git a/etc/initsystem/icinga2-prepare-dirs b/etc/initsystem/icinga2-prepare-dirs
index c9b12491b..74daa1b8c 100644
--- a/etc/initsystem/icinga2-prepare-dirs
+++ b/etc/initsystem/icinga2-prepare-dirs
@@ -12,6 +12,9 @@ else
 	exit 1
 fi
 
+ICINGA2_USER=`$DAEMON variable get --current RunAsUser`
+ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup`
+
 mkdir -p $(dirname -- $ICINGA2_PID_FILE)
 chown $ICINGA2_USER:$ICINGA2_GROUP $(dirname -- $ICINGA2_PID_FILE)
 if [ -f $ICINGA2_PID_FILE ]; then
diff --git a/etc/initsystem/icinga2.init.d.cmake b/etc/initsystem/icinga2.init.d.cmake
index f13496fc0..d9e8ae63f 100644
--- a/etc/initsystem/icinga2.init.d.cmake
+++ b/etc/initsystem/icinga2.init.d.cmake
@@ -26,6 +26,9 @@ fi
 
 test -x $DAEMON || exit 5
 
+ICINGA2_USER=`$DAEMON variable get --current RunAsUser`
+ICINGA2_GROUP=`$DAEMON variable get --current RunAsGroup`
+
 if [ ! -e $ICINGA2_CONFIG_FILE ]; then
         echo "Config file '$ICINGA2_CONFIG_FILE' does not exist."
         exit 6
diff --git a/etc/initsystem/icinga2.sysconfig.cmake b/etc/initsystem/icinga2.sysconfig.cmake
index 8b65b8017..646347d19 100644
--- a/etc/initsystem/icinga2.sysconfig.cmake
+++ b/etc/initsystem/icinga2.sysconfig.cmake
@@ -8,5 +8,4 @@ ICINGA2_STARTUP_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/startup.log
 ICINGA2_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log
 ICINGA2_USER=@ICINGA2_USER@
 ICINGA2_GROUP=@ICINGA2_GROUP@
-ICINGA2_COMMAND_USER=@ICINGA2_COMMAND_USER@
 ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@
diff --git a/icinga2.spec b/icinga2.spec
index c42a42cb6..56d172447 100644
--- a/icinga2.spec
+++ b/icinga2.spec
@@ -186,7 +186,6 @@ CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
          -DICINGA2_RUNDIR=%{_rundir} \
          -DICINGA2_USER=%{icinga_user} \
          -DICINGA2_GROUP=%{icinga_group} \
-         -DICINGA2_COMMAND_USER=%{icinga_user} \
          -DICINGA2_COMMAND_GROUP=%{icingacmd_group} \
          -DICINGA2_UNITY_BUILD=TRUE"
 %if "%{_vendor}" == "redhat"