[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:22:15 UTC 2012


The following commit has been merged in the debian/master branch:
commit cf505337f3dfdf59c465bdfe2a7045d19c58871e
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Feb 22 15:24:23 2012 +0100

    Fix : (reported by: nadiw) protect the escalmation point if anti-slash before in commands args.

diff --git a/shinken/commandcall.py b/shinken/commandcall.py
index 29e16c4..f459a06 100644
--- a/shinken/commandcall.py
+++ b/shinken/commandcall.py
@@ -62,9 +62,11 @@ class CommandCall(DummyCommandCall):
         self.id = self.__class__.id
         self.__class__.id += 1
         self.call = call
-        tab = call.split('!')
-        self.command = tab[0]
-        self.args = tab[1:]
+        # Now split by ! and get command and args
+        self.get_command_and_args()
+        #tab = call.split('!')
+        #self.command = tab[0]
+        #self.args = tab[1:]
         self.command = commands.find_by_name(self.command.strip())
         if self.command is not None:
             self.valid = True
@@ -83,6 +85,17 @@ class CommandCall(DummyCommandCall):
             if self.valid and reactionner_tag is 'None':
                 self.reactionner_tag = self.command.reactionner_tag #from command if not set
 
+    # We want to get the command and the args with ! splitting.
+    # but don't forget to protect against the \! to do not split them
+    def get_command_and_args(self):
+        # first protect
+        p_call = self.call.replace('\!', '___PROTECT_ESCLAMATION___')
+        tab = p_call.split('!')
+        self.command = tab[0]
+        # Reverse the protection
+        self.args = [s.replace('___PROTECT_ESCLAMATION___', '!') for s in tab[1:]]
+        
+        
 
 
     def is_valid(self):
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_protect_esclamation_point.cfg
similarity index 87%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_protect_esclamation_point.cfg
index 1566c73..688ffa9 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_protect_esclamation_point.cfg
@@ -8,14 +8,14 @@ auto_rescheduling_interval=30
 auto_rescheduling_window=180
 cached_host_check_horizon=15
 cached_service_check_horizon=15
-cfg_file=1r_1h_1s/hosts.cfg
-cfg_file=1r_1h_1s/services.cfg
-cfg_file=1r_1h_1s/contacts.cfg
-cfg_file=1r_1h_1s/commands.cfg
-cfg_file=1r_1h_1s/timeperiods.cfg
-cfg_file=1r_1h_1s/hostgroups.cfg
-cfg_file=1r_1h_1s/servicegroups.cfg
-cfg_file=1r_1h_1s/shinken-specific.cfg
+cfg_file=protect_esclamation_point/hosts.cfg
+cfg_file=protect_esclamation_point/services.cfg
+cfg_file=protect_esclamation_point/contacts.cfg
+cfg_file=protect_esclamation_point/commands.cfg
+cfg_file=protect_esclamation_point/timeperiods.cfg
+cfg_file=protect_esclamation_point/hostgroups.cfg
+cfg_file=protect_esclamation_point/servicegroups.cfg
+cfg_file=protect_esclamation_point/shinken-specific.cfg
 check_external_commands=1
 check_for_orphaned_hosts=1
 check_for_orphaned_services=1
diff --git a/test/etc/1r_1h_1s/commands.cfg b/test/etc/protect_esclamation_point/commands.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/commands.cfg
copy to test/etc/protect_esclamation_point/commands.cfg
diff --git a/test/etc/1r_1h_1s/contacts.cfg b/test/etc/protect_esclamation_point/contacts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/contacts.cfg
copy to test/etc/protect_esclamation_point/contacts.cfg
diff --git a/test/etc/1r_1h_1s/hostgroups.cfg b/test/etc/protect_esclamation_point/hostgroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hostgroups.cfg
copy to test/etc/protect_esclamation_point/hostgroups.cfg
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/protect_esclamation_point/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/protect_esclamation_point/hosts.cfg
diff --git a/test/etc/1r_1h_1s/servicegroups.cfg b/test/etc/protect_esclamation_point/servicegroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/servicegroups.cfg
copy to test/etc/protect_esclamation_point/servicegroups.cfg
diff --git a/test/etc/bad_sat_realm_conf/services.cfg b/test/etc/protect_esclamation_point/services.cfg
similarity index 96%
copy from test/etc/bad_sat_realm_conf/services.cfg
copy to test/etc/protect_esclamation_point/services.cfg
index e16682e..5c6635a 100644
--- a/test/etc/bad_sat_realm_conf/services.cfg
+++ b/test/etc/protect_esclamation_point/services.cfg
@@ -26,7 +26,7 @@ define service{
 
 define service{
   active_checks_enabled          1
-  check_command                  check_service!ok
+  check_command                  check_service!blabla!ti\!ti!toto
   check_interval                 1
   host_name                      test_host_0
   icon_image                     ../../docs/images/tip.gif?host=$HOSTNAME$&srv=$SERVICEDESC$
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/protect_esclamation_point/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/protect_esclamation_point/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/protect_esclamation_point/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/protect_esclamation_point/timeperiods.cfg
diff --git a/test/jenkins/longtests.txt b/test/jenkins/longtests.txt
index 6edada7..e709e9f 100644
--- a/test/jenkins/longtests.txt
+++ b/test/jenkins/longtests.txt
@@ -95,6 +95,7 @@ test_define_with_space.py
 test_objects_and_notifways.py
 test_star_in_hostgroups.py
 test_freshness.py
+test_protect_esclamation_point.py
 test_parse_perfdata.py
 
 # takes long
diff --git a/test/jenkins/shorttests.txt b/test/jenkins/shorttests.txt
index 91cbfe0..43efc60 100644
--- a/test/jenkins/shorttests.txt
+++ b/test/jenkins/shorttests.txt
@@ -102,4 +102,5 @@ test_define_with_space.py
 test_objects_and_notifways.py
 test_star_in_hostgroups.py
 test_freshness.py
+test_protect_esclamation_point.py
 test_parse_perfdata.py
diff --git a/test/quick_tests.sh b/test/quick_tests.sh
index 5544471..3ccddb4 100755
--- a/test/quick_tests.sh
+++ b/test/quick_tests.sh
@@ -140,6 +140,7 @@ launch_and_assert test_define_with_space.py
 launch_and_assert test_objects_and_notifways.py
 launch_and_assert test_freshness.py
 launch_and_assert test_star_in_hostgroups.py
+launch_and_assert test_protect_esclamation_point.py
 
 launch_and_assert test_maintenance_period.py
 #Live status is a bit longer than the previous, so we put it at the end.
diff --git a/test/test_dot_virg_in_command.py b/test/test_protect_esclamation_point.py
similarity index 88%
copy from test/test_dot_virg_in_command.py
copy to test/test_protect_esclamation_point.py
index c931fc3..d9c4f32 100755
--- a/test/test_dot_virg_in_command.py
+++ b/test/test_protect_esclamation_point.py
@@ -26,11 +26,11 @@
 from shinken_test import *
 
 
-class TestConfig(ShinkenTest):
+class TestProtectEscalmationPoint(ShinkenTest):
     #Uncomment this is you want to use a specific configuration
     #for your test
     def setUp(self):
-        self.setup_with_file('etc/nagios_dot_virg_in_command.cfg')
+        self.setup_with_file('etc/nagios_protect_esclamation_point.cfg')
 
     
     #Change ME :)
@@ -50,9 +50,9 @@ class TestConfig(ShinkenTest):
         svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
         svc.checks_in_progress = []
         svc.act_depend_of = [] # no hostchecks on critical checkresults
-        print svc.event_handler.args
-        self.assert_('sudo -s pkill toto ; cd /my/path && ./toto' in svc.event_handler.args)
 
+        print svc.check_command.args
+        self.assert_(u'ti!ti' in svc.check_command.args)
 
 if __name__ == '__main__':
     unittest.main()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list