From 3c29e49d774619bb18b2c8919f4f52f12ab7d5ea Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 12 Jun 2012 14:38:00 +0200
Subject: [PATCH] Fix daemon-util with non-root user models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit 4b42c3d6 broke non-root user mode since, while trying to do a
cleanup a move all local variable definitions to the start of the
function; however, the plain_name var is only defined later, so this
actually doesn't work.

Note that enabling set -u doesn't _directly_ work, since we rely on
some variables which are usually undefined (EXTRA_*_ARGS, etc.). It
can be fixed, but in a later patch.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 daemons/daemon-util.in | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
index 5bf2c3fa0..b754e7f60 100644
--- a/daemons/daemon-util.in
+++ b/daemons/daemon-util.in
@@ -203,6 +203,9 @@ start() {
   fi
 
   local name="$1"; shift
+  # Convert daemon name to uppercase after removing "ganeti-" prefix
+  local plain_name=${name#ganeti-}
+  local ucname=$(tr a-z A-Z <<<$plain_name)
   local pidfile=$(_daemon_pidfile $name)
   local usergroup=$(_daemon_usergroup $plain_name)
   local daemonexec=$(_daemon_executable $name)
@@ -213,10 +216,6 @@ start() {
     return 1
   fi
 
-  # Convert daemon name to uppercase after removing "ganeti-" prefix
-  local plain_name=${name#ganeti-}
-  local ucname=$(tr a-z A-Z <<<$plain_name)
-
   # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
   eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""
 
-- 
GitLab