[pkg-bacula-commits] [bacula] 01/07: delegate daemons uid/gid changing to init system

Carsten Leonhardt leo at moszumanska.debian.org
Wed Jul 20 10:57:38 UTC 2016


This is an automated email from the git hooks/post-receive script.

leo pushed a commit to tag development/wheezy-2012-11-25
in repository bacula.

commit 0252554daa6bb79eb90d5c58ce6b555b6b0a843d
Author: Alexander Golovko <alexandro at ankalagon.ru>
Date:   Thu Nov 8 00:51:49 2012 +0400

    delegate daemons uid/gid changing to init system
    
    Change uid/gid by start-stop-daemon for correct backtrace work.
    Thanks to Matija Nalis (bug #556207)
    
    Backported commits:
      cf9eb640182f4adfd83d05954dc35a20b60170c1 (partially)
      38b37627e9112fd9309815d54b037219e63fea9e
---
 debian/additions/common-functions.dpkg             | 14 ++++++--------
 debian/bacula-director-common.bacula-director.init |  8 +++++---
 debian/bacula-fd.init                              |  8 +++++---
 debian/bacula-sd.init                              |  8 +++++---
 debian/changelog                                   |  3 +++
 5 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/debian/additions/common-functions.dpkg b/debian/additions/common-functions.dpkg
index 065566f..73181e7 100644
--- a/debian/additions/common-functions.dpkg
+++ b/debian/additions/common-functions.dpkg
@@ -63,13 +63,11 @@ setup_etc_default() {
     case "$1" in
         bacula-fd)
             SERVICE="bacula-fd"
-            ARGS=""
-            DEFAULT_ARGS=""
+            DAEMONUSER="root"
             ;;
         bacula-sd)
             SERVICE="bacula-sd"
-            ARGS="-u bacula -g tape"
-            DEFAULT_ARGS="-u bacula -g tape"
+            DAEMONUSER="bacula:tape"
             ;;
         bacula-director-pgsql|bacula-director-mysql|bacula-director-sqlite3)
             SERVICE="bacula-dir"
@@ -86,6 +84,7 @@ setup_etc_default() {
 
 
     ENABLED="yes"
+    ARGS=""
     CONFIG="/etc/bacula/$SERVICE.conf"
     DEFAULTS="/etc/default/$SERVICE"
     UCFR_ARGS="${UCFR_ARGS:-}"
@@ -99,8 +98,6 @@ setup_etc_default() {
         else
             if [ -f "$DEFAULTS" ]; then
                 ENABLED=$(. $DEFAULTS; echo $ENABLED)
-                ARGS=$(. $DEFAULTS; echo $ARGS)
-                CONFIG=$(. $DEFAULTS; echo $CONFIG)
             fi
         fi
     fi
@@ -120,12 +117,13 @@ setup_etc_default() {
 # ENABLED="no"
 ENABLED="$ENABLED"
 
+# Daemon user (in format user or user:group)
+DAEMONUSER="$DAEMONUSER"
+
 # Additional start arguments can be provided here
-# ARGS="$DEFAULT_ARGS"
 ARGS="$ARGS"
 
 # Default config file can be changed here
-# CONFIG="/etc/bacula/$SERVICE.conf"
 CONFIG="$CONFIG"
 _EOF
 
diff --git a/debian/bacula-director-common.bacula-director.init b/debian/bacula-director-common.bacula-director.init
index 158ffe6..747dff1 100644
--- a/debian/bacula-director-common.bacula-director.init
+++ b/debian/bacula-director-common.bacula-director.init
@@ -47,6 +47,8 @@ if [ -r /etc/default/$NAME ]; then
 fi
 
 CONFIG="${CONFIG:-/etc/bacula/$NAME.conf}"
+DAEMONUSER="${DAEMONUSER:-bacula:bacula}"
+ARGS="${ARGS:-}"
 
 create_var_run_dir
 
@@ -64,15 +66,15 @@ kill_pid()
 # do_start()
 do_start()
 {
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+	start-stop-daemon -c "$DAEMONUSER" --start --quiet --pidfile $PIDFILE \
 	--oknodo --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 # do_stop()
 do_stop()
 {
-	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
-		--retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
+	start-stop-daemon -c "$DAEMONUSER" --stop --quiet --pidfile $PIDFILE \
+	--oknodo --retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 
diff --git a/debian/bacula-fd.init b/debian/bacula-fd.init
index 4ccc7d5..eebfd9c 100644
--- a/debian/bacula-fd.init
+++ b/debian/bacula-fd.init
@@ -43,6 +43,8 @@ if [ -r /etc/default/$NAME ]; then
 fi
 
 CONFIG="${CONFIG:-/etc/bacula/$NAME.conf}"
+DAEMONUSER="${DAEMONUSER:-root}"
+ARGS="${ARGS:-}"
 
 create_var_run_dir
 
@@ -51,14 +53,14 @@ PIDFILE=/var/run/bacula/$NAME.$PORT.pid
 
 do_start()
 {
-        start-stop-daemon --start --quiet --pidfile $PIDFILE \
+        start-stop-daemon -c "$DAEMONUSER" --start --quiet --pidfile $PIDFILE \
         --oknodo --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 do_stop()
 {
-        start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
-        --retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
+        start-stop-daemon -c "$DAEMONUSER" --stop --quiet --pidfile $PIDFILE \
+        --oknodo --retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 case "$1" in
diff --git a/debian/bacula-sd.init b/debian/bacula-sd.init
index 6fae0ab..5584fac 100644
--- a/debian/bacula-sd.init
+++ b/debian/bacula-sd.init
@@ -41,6 +41,8 @@ if [ -r /etc/default/$NAME ]; then
 fi
 
 CONFIG="${CONFIG:-/etc/bacula/$NAME.conf}"
+DAEMONUSER="${DAEMONUSER:-bacula:tape}"
+ARGS="${ARGS:-}"
 
 create_var_run_dir
 
@@ -48,14 +50,14 @@ PIDFILE=/var/run/bacula/$NAME.$PORT.pid
 
 do_start()
 {
-        start-stop-daemon --start --quiet --pidfile $PIDFILE \
+        start-stop-daemon -c "$DAEMONUSER" --start --quiet --pidfile $PIDFILE \
         --oknodo --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 do_stop()
 {
-        start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
-        --retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
+        start-stop-daemon -c "$DAEMONUSER" --stop --quiet --pidfile $PIDFILE \
+        --oknodo --retry TERM/30/KILL/5 --exec $DAEMON -- -c $CONFIG $ARGS
 }
 
 case "$1" in
diff --git a/debian/changelog b/debian/changelog
index 223e556..2e80ec1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,9 @@ bacula (5.2.6+dfsg-2+deb7u1) testing; urgency=high
   * debian/*.init:
     + fix waiting for real daemon stopping (Closes: #684744). 
     - remove unused code from bacula-director init script.
+  * debian/additions/common-functions.dpkg, debian/*.init:
+    + delegate daemons uid/gid changing to start-stop-daemon, thanks to 
+      Matija Nalis (Closes: #556207).
 
   [ Bart Swedrowski ]
   * debian/bacula-console.postinst,debian/bacula-console-qt.postinst,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git



More information about the pkg-bacula-commits mailing list