[Nagios-devel] [PATCH 2/3] Patch to new_mini_epn to allow any
Posted: Thu Aug 05, 2010 10:34 am
From: Ethan Galstad
---
Changelog | 1 +
THANKS | 1 +
contrib/new_mini_epn.c | 21 ++++++++++++++++-----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/Changelog b/Changelog
index b4283da..54cd941 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Nagios 3.x Change Log
3.2.2 - ??/??/2010
------------------
ENHANCEMENTS
+* Patch to new_mini_epn to allow any command line length without breaking on extra trailing or leading whitespace (Ray Bengen)
* Patch to speed up loading of state retention data (Matthieu Kermagoret)
* Custom notifications are now suppressed during scheduled downtime (Sven Nierlein)
diff --git a/THANKS b/THANKS
index bacf809..b10e20a 100644
--- a/THANKS
+++ b/THANKS
@@ -28,6 +28,7 @@ since 1999. If I missed your name, let me know.
* Simon Beale
* Ben Bell
* Marlo Bell
+* Ray Bengen
* Derrick Bennett
* Chris Bensend
* Kevin Benton
diff --git a/contrib/new_mini_epn.c b/contrib/new_mini_epn.c
index 4320111..38b24e2 100644
--- a/contrib/new_mini_epn.c
+++ b/contrib/new_mini_epn.c
@@ -217,8 +217,6 @@ void deinit_embedded_perl(void){
int main(int argc, char **argv, char **env) {
- char command_line[128];
-
init_embedded_perl();
/* Calls Perl to load and construct a new
* Term::ReadLine object.
@@ -231,13 +229,26 @@ int main(int argc, char **argv, char **env) {
* get_command_line calls Perl to get a scalar from stdin
*/
- strncpy(command_line, get_command_line(), 128) ;
-
/* Perl Term::ReadLine::readline() method chomps the "\n"
* from the end of the input.
*/
- run_plugin(command_line) ;
+ char *cmd,*end;
+ /* Allow any length command line */
+ cmd = (get_command_line ()) ;
+
+ // Trim leading whitespace
+ while (isspace (*cmd)) cmd++;
+
+ // Trim trailing whitespace
+ end = cmd + strlen (cmd) - 1;
+ while (end > cmd && isspace (*end)) end--;
+
+ // Write new null terminator
+ *(end+1) = 0;
+
+ run_plugin (cmd) ;
}
deinit_embedded_perl();
}
+
--
1.7.1
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
---
Changelog | 1 +
THANKS | 1 +
contrib/new_mini_epn.c | 21 ++++++++++++++++-----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/Changelog b/Changelog
index b4283da..54cd941 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Nagios 3.x Change Log
3.2.2 - ??/??/2010
------------------
ENHANCEMENTS
+* Patch to new_mini_epn to allow any command line length without breaking on extra trailing or leading whitespace (Ray Bengen)
* Patch to speed up loading of state retention data (Matthieu Kermagoret)
* Custom notifications are now suppressed during scheduled downtime (Sven Nierlein)
diff --git a/THANKS b/THANKS
index bacf809..b10e20a 100644
--- a/THANKS
+++ b/THANKS
@@ -28,6 +28,7 @@ since 1999. If I missed your name, let me know.
* Simon Beale
* Ben Bell
* Marlo Bell
+* Ray Bengen
* Derrick Bennett
* Chris Bensend
* Kevin Benton
diff --git a/contrib/new_mini_epn.c b/contrib/new_mini_epn.c
index 4320111..38b24e2 100644
--- a/contrib/new_mini_epn.c
+++ b/contrib/new_mini_epn.c
@@ -217,8 +217,6 @@ void deinit_embedded_perl(void){
int main(int argc, char **argv, char **env) {
- char command_line[128];
-
init_embedded_perl();
/* Calls Perl to load and construct a new
* Term::ReadLine object.
@@ -231,13 +229,26 @@ int main(int argc, char **argv, char **env) {
* get_command_line calls Perl to get a scalar from stdin
*/
- strncpy(command_line, get_command_line(), 128) ;
-
/* Perl Term::ReadLine::readline() method chomps the "\n"
* from the end of the input.
*/
- run_plugin(command_line) ;
+ char *cmd,*end;
+ /* Allow any length command line */
+ cmd = (get_command_line ()) ;
+
+ // Trim leading whitespace
+ while (isspace (*cmd)) cmd++;
+
+ // Trim trailing whitespace
+ end = cmd + strlen (cmd) - 1;
+ while (end > cmd && isspace (*end)) end--;
+
+ // Write new null terminator
+ *(end+1) = 0;
+
+ run_plugin (cmd) ;
}
deinit_embedded_perl();
}
+
--
1.7.1
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]