logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

SF.net SVN: nagiosplug: [1800] nagiosplug/trunk: msg#00025

Subject: SF.net SVN: nagiosplug: [1800] nagiosplug/trunk
Revision: 1800
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1800&view=rev
Author:   hweiss
Date:     2007-09-26 03:57:44 -0700 (Wed, 26 Sep 2007)

Log Message:
-----------
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).

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/plugins/check_radius.c

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS       2007-09-26 04:16:21 UTC (rev 1799)
+++ nagiosplug/trunk/NEWS       2007-09-26 10:57:44 UTC (rev 1800)
@@ -29,6 +29,8 @@
          - enforce a full path for the command to run
        The "negate" utility can now remap custom states
        Check_radius now supports radiusclient-ng
+       The (undocumented) positional parameter parsing which check_radius used
+         instead of getopt(3) if 8 arguments were given is no longer available
        Check_by_ssh now supports multiline output
        IPv6 support can now be disabled using ./configure --without-ipv6
        Fix check_ntp now honor ntp flags

Modified: nagiosplug/trunk/plugins/check_radius.c
===================================================================
--- nagiosplug/trunk/plugins/check_radius.c     2007-09-26 04:16:21 UTC (rev 
1799)
+++ nagiosplug/trunk/plugins/check_radius.c     2007-09-26 10:57:44 UTC (rev 
1800)
@@ -225,30 +225,6 @@
                {0, 0, 0, 0}
        };
 
-       if (argc < 2)
-               return ERROR;
-
-       if (argc == 9) {
-               config_file = argv[1];
-               username = argv[2];
-               password = argv[3];
-               if (is_intpos (argv[4]))
-                       timeout_interval = atoi (argv[4]);
-               else
-                       usage2 (_("Timeout interval must be a positive 
integer"), optarg);
-               if (is_intpos (argv[5]))
-                       retries = atoi (argv[5]);
-               else
-                       usage4 (_("Number of retries must be a positive 
integer"));
-               server = argv[6];
-               if (is_intpos (argv[7]))
-                       port = atoi (argv[7]);
-               else
-                       usage4 (_("Port must be a positive integer"));
-               expect = argv[8];
-               return OK;
-       }
-
        while (1) {
                c = getopt_long (argc, argv, "+hVvH:P:F:u:p:n:t:r:e:", longopts,
                                                                         
&option);
@@ -309,6 +285,16 @@
                        break;
                }
        }
+
+       if (server == NULL)
+               usage4 (_("Host not specified"));
+       if (username == NULL)
+               usage4 (_("User not specified"));
+       if (password == NULL)
+               usage4 (_("Password not specified"));
+       if (config_file == NULL)
+               usage4 (_("Configuration file not specified"));
+
        return OK;
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


<Prev in Thread] Current Thread [Next in Thread>