diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-04-01 09:31:27 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-04-01 09:31:27 (GMT) |
commit | d001e08133763427fded92847f3366d53811abca (patch) | |
tree | e855c4367d1ad202400bd7544cd10af42ea95b68 | |
parent | 8a7b252eeb78a2209ebc5cb28739772c9bdaade0 (diff) | |
download | monitoring-plugins-d001e08133763427fded92847f3366d53811abca.tar.gz |
np_extra_opts now retain pointers from argv so that plugins can still overwrite sensitive options
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1971 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | lib/extra_opts.c | 4 | ||||
-rw-r--r-- | lib/extra_opts.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/extra_opts.c b/lib/extra_opts.c index d46d124..8c17fa4 100644 --- a/lib/extra_opts.c +++ b/lib/extra_opts.c | |||
@@ -122,7 +122,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){ | |||
122 | if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n")); | 122 | if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n")); |
123 | 123 | ||
124 | /* starting with program name */ | 124 | /* starting with program name */ |
125 | argv_new[0]=strdup(argv[0]); | 125 | argv_new[0]=argv[0]; |
126 | argc_new=1; | 126 | argc_new=1; |
127 | /* then parsed ini opts (frying them up in the same run) */ | 127 | /* then parsed ini opts (frying them up in the same run) */ |
128 | while(extra_args){ | 128 | while(extra_args){ |
@@ -132,7 +132,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){ | |||
132 | free(ea1); | 132 | free(ea1); |
133 | } | 133 | } |
134 | /* finally the rest of the argv array */ | 134 | /* finally the rest of the argv array */ |
135 | for (i=1; i<*argc; i++) argv_new[argc_new++]=strdup(argv[i]); | 135 | for (i=1; i<*argc; i++) argv_new[argc_new++]=argv[i]; |
136 | *argc=argc_new; | 136 | *argc=argc_new; |
137 | /* and terminate. */ | 137 | /* and terminate. */ |
138 | argv_new[argc_new]=NULL; | 138 | argv_new[argc_new]=NULL; |
diff --git a/lib/extra_opts.h b/lib/extra_opts.h index 8ce0903..0cb47fb 100644 --- a/lib/extra_opts.h +++ b/lib/extra_opts.h | |||
@@ -11,8 +11,8 @@ | |||
11 | * ini-procesed arguments always come first (in the ord of --extra-opts | 11 | * ini-procesed arguments always come first (in the ord of --extra-opts |
12 | * arguments). If no --extra-opts arguments are provided or returned nothing | 12 | * arguments). If no --extra-opts arguments are provided or returned nothing |
13 | * it returns **argv otherwise the new array is returned. --extra-opts are | 13 | * it returns **argv otherwise the new array is returned. --extra-opts are |
14 | * always removed from **argv and the new array and all its elements can be | 14 | * always removed from **argv. The original pointers from **argv are kept in |
15 | * freed with free(); | 15 | * the new array to preserve ability to overwrite arguments in processlist. |
16 | */ | 16 | */ |
17 | char **np_extra_opts(int *argc, char **argv, const char *plugin_name); | 17 | char **np_extra_opts(int *argc, char **argv, const char *plugin_name); |
18 | 18 | ||