[omd-commits] OMD Git: omd: omd: add new command "omd su <site>"

git version control git at mathias-kettner.de
Mon Jun 20 11:14:18 CEST 2011


Module:   omd
Branch:   master
Commit:   c6efb0d5b2e7f77973192870d90f884b6d789c89
URL:      http://omdistro.org/projects/omd/repository/revisions/c6efb0d5b2e7f77973192870d90f884b6d789c89

Author:   Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Mon Jun 20 11:00:31 2011 +0200
Commiter: Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Mon Jun 20 11:00:31 2011 +0200

omd: add new command "omd su <site>"

---

 packages/omd/omd |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/packages/omd/omd b/packages/omd/omd
index 4e10b18..6b1379a 100644
--- a/packages/omd/omd
+++ b/packages/omd/omd
@@ -2327,6 +2327,11 @@ def main_config(args, options={}):
         else:
             config_usage()
 
+def main_su(args, options={}):
+    try:
+        os.execl("/bin/su", "su", "-", "%s" % g_sitename)
+    except OSError:
+        bail_out("Cannot open a shell for user %s" % g_sitename)
 
 commands = [
 #  command   only_root  needs_site must_exist confirm args, function,
@@ -2457,6 +2462,11 @@ commands = [
     "Shows differences compared to the original version files",
     ""),
 
+  ( "su",     True, 1, 1, False, "", main_su,
+    [ ],
+    "Run a shell as a site-user",
+    ""),
+
 ]
 
 def handle_global_option(opt, orig):
@@ -2601,7 +2611,7 @@ if g_sitename != None and site_must_exist and not site_exists(g_sitename):
 # Commands operating on an existing site *must* run omd in
 # the same version as the site has! Sole exception: update.
 # That command must be run in the target version
-if g_sitename and site_must_exist and command != "update":
+if g_sitename and site_must_exist and command not in ["update", "su"]:
     v = site_version(g_sitename)
     if OMD_VERSION != v:
         exec_other_omd(v)



More information about the omd-commits mailing list