From aa7b59acb860751297223036fbddbc6277882a45 Mon Sep 17 00:00:00 2001
From: Andrea Spadaccini <spadaccio@google.com>
Date: Tue, 1 Nov 2011 18:45:27 +0000
Subject: [PATCH] Move hooks PATH environment variable to constants

Move the contents of the PATH environment variable for hooks to
constants, and use its value in the code and in the hooks documentation.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
(cherry picked from commit fe5ca2bbc103d25d159bc23b00c3acdfb024c0d2)
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 doc/hooks.rst    | 2 +-
 lib/constants.py | 1 +
 lib/mcpu.py      | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/hooks.rst b/doc/hooks.rst
index d9f09f2b4..3cf8bc70b 100644
--- a/doc/hooks.rst
+++ b/doc/hooks.rst
@@ -98,7 +98,7 @@ The scripts will be run as follows:
 
 - stdout and stderr are directed to files
 
-- PATH is reset to ``/sbin:/bin:/usr/sbin:/usr/bin``
+- PATH is reset to :pyeval:`constants.HOOKS_PATH`
 
 - the environment is cleared, and only ganeti-specific variables will
   be left
diff --git a/lib/constants.py b/lib/constants.py
index 4fa186e9f..90b992269 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -328,6 +328,7 @@ HOOKS_PHASE_POST = "post"
 HOOKS_NAME_CFGUPDATE = "config-update"
 HOOKS_NAME_WATCHER = "watcher"
 HOOKS_VERSION = 2
+HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
 
 # hooks subject type (what object type does the LU deal with)
 HTYPE_CLUSTER = "CLUSTER"
diff --git a/lib/mcpu.py b/lib/mcpu.py
index 89046c60c..ba07b83ac 100644
--- a/lib/mcpu.py
+++ b/lib/mcpu.py
@@ -519,7 +519,7 @@ class HooksMaster(object):
     cfg = self.lu.cfg
 
     env = {
-      "PATH": "/sbin:/bin:/usr/sbin:/usr/bin",
+      "PATH": constants.HOOKS_PATH,
       "GANETI_HOOKS_VERSION": constants.HOOKS_VERSION,
       "GANETI_OP_CODE": self.op.OP_ID,
       "GANETI_DATA_DIR": constants.DATA_DIR,
-- 
GitLab