diff options
author | Holger Weiss <hweiss@users.sourceforge.net> | 2007-09-26 10:57:44 (GMT) |
---|---|---|
committer | Holger Weiss <hweiss@users.sourceforge.net> | 2007-09-26 10:57:44 (GMT) |
commit | faf593d23a7c4c09143373053106f61da3265384 (patch) | |
tree | 5059abbc2e8794ec1879a02c3a4a4c157735ad40 /plugins/check_radius.c | |
parent | 0b66867288b1eb9b9c7a2ffa5cf5e3fd473dc1e7 (diff) | |
download | monitoring-plugins-faf593d23a7c4c09143373053106f61da3265384.tar.gz |
Drop the weird and undocumented behaviour of using positional argument
parsing instead of getopt(3) if 8 command line arguments were given (as
suggested by Matthias) and check whether all required arguments have
been specified in order to spit out proper error messages and to avoid a
possible segfault (as suggested by Thomas).
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1800 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_radius.c')
-rw-r--r-- | plugins/check_radius.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 32af91f..dcb85ac 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
@@ -225,30 +225,6 @@ process_arguments (int argc, char **argv) | |||
225 | {0, 0, 0, 0} | 225 | {0, 0, 0, 0} |
226 | }; | 226 | }; |
227 | 227 | ||
228 | if (argc < 2) | ||
229 | return ERROR; | ||
230 | |||
231 | if (argc == 9) { | ||
232 | config_file = argv[1]; | ||
233 | username = argv[2]; | ||
234 | password = argv[3]; | ||
235 | if (is_intpos (argv[4])) | ||
236 | timeout_interval = atoi (argv[4]); | ||
237 | else | ||
238 | usage2 (_("Timeout interval must be a positive integer"), optarg); | ||
239 | if (is_intpos (argv[5])) | ||
240 | retries = atoi (argv[5]); | ||
241 | else | ||
242 | usage4 (_("Number of retries must be a positive integer")); | ||
243 | server = argv[6]; | ||
244 | if (is_intpos (argv[7])) | ||
245 | port = atoi (argv[7]); | ||
246 | else | ||
247 | usage4 (_("Port must be a positive integer")); | ||
248 | expect = argv[8]; | ||
249 | return OK; | ||
250 | } | ||
251 | |||
252 | while (1) { | 228 | while (1) { |
253 | c = getopt_long (argc, argv, "+hVvH:P:F:u:p:n:t:r:e:", longopts, | 229 | c = getopt_long (argc, argv, "+hVvH:P:F:u:p:n:t:r:e:", longopts, |
254 | &option); | 230 | &option); |
@@ -309,6 +285,16 @@ process_arguments (int argc, char **argv) | |||
309 | break; | 285 | break; |
310 | } | 286 | } |
311 | } | 287 | } |
288 | |||
289 | if (server == NULL) | ||
290 | usage4 (_("Host not specified")); | ||
291 | if (username == NULL) | ||
292 | usage4 (_("User not specified")); | ||
293 | if (password == NULL) | ||
294 | usage4 (_("Password not specified")); | ||
295 | if (config_file == NULL) | ||
296 | usage4 (_("Configuration file not specified")); | ||
297 | |||
312 | return OK; | 298 | return OK; |
313 | } | 299 | } |
314 | 300 | ||