[sysadmin-bin] Add the brand new run-nagios-command, this will help us bypassing authorized_keys restriction and pa



commit 20e48d0b6689cb99a00f71ee4595f7b5b65205ea
Author: Andrea Veri <av gnome org>
Date:   Thu Feb 28 11:32:39 2013 +0100

    Add the brand new run-nagios-command, this will help us bypassing authorized_keys restriction and pass 
the args sent by Nagios directly to the relevant script.

 run-nagios-command |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/run-nagios-command b/run-nagios-command
new file mode 100755
index 0000000..b0a4f12
--- /dev/null
+++ b/run-nagios-command
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+
+import os
+import shlex
+
+# In case .bashrc was executed, umask might have been changed from
+# the default, which could result in files being created private
+# not world-readable
+os.umask(0002)
+
+def run_nagios_command(args):
+   cmd = ['/etc/nagios/eventhandlers/restart-httpd']
+   cmd.extend(args[1:])
+   os.execv(cmd[0], cmd)
+
+if __name__ == "__main__":
+    if 'SSH_ORIGINAL_COMMAND' in os.environ:
+        run_nagios_command(shlex.split(os.environ['SSH_ORIGINAL_COMMAND']))
+    else:
+        import sys
+        print >>sys.stderr, 'SSH authentication succeeded. Interactive login is not allowed.'
+        sys.exit(1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]