[icinga-checkins] icinga.org: icinga-core/cmaser/fixes: more permissions checks on the plugin command

git at icinga.org git at icinga.org
Sun Jul 4 11:27:04 CEST 2010


Module: icinga-core
Branch: cmaser/fixes
Commit: 88a3dd5aa2e7e5d3490dd43ba1533bb3415fea0c
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=88a3dd5aa2e7e5d3490dd43ba1533bb3415fea0c

Author: Christoph Maser <cmr at financial.com>
Date:   Sun Jul  4 10:15:53 2010 +0200

more permissions checks on the plugin command

---

 base/checks.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/base/checks.c b/base/checks.c
index 5b80862..af0d360 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -837,12 +837,18 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 	                         chldargs[1] = '\0';
 	                     }
 	 
+                             if (access(chldargs[0], R_OK)) {
+                                  logit(NSLOG_RUNTIME_WARNING,TRUE,"plugin %s does not exists or is not readable\n",chldargs[0]);
+                                  _exit(STATE_UNKNOWN);
+                             } 
+
+                             if (access(chldargs[0], X_OK) != 0  ) {
+                                 logit(NSLOG_RUNTIME_WARNING,TRUE,"wrong execution permissions on plugin %s\n",chldargs[0]);
+                                 _exit(STATE_UNKNOWN);
+                             }  
+
 	                     log_debug_info(DEBUGL_CHECKS,0,"running process %s via execv\n",processed_command);
-                             if (access(chldargs[0], R_OK|X_OK) == 0) {
-	                         execv(chldargs[0],chldargs);
-                             } else {
-                               logit(NSLOG_RUNTIME_WARNING,TRUE,"wrong permissions on plugin %s\n",chldargs[0]);
-                             }
+	                     execv(chldargs[0],chldargs);
                      	    _exit(EXIT_FAILURE);
 			}
 





More information about the icinga-checkins mailing list