--- check_ldap.c Thu Nov 14 17:04:51 2002 +++ check_ldap.c.new Mon Jan 6 02:15:41 2003 @@ -32,6 +32,7 @@ #include #define UNKNOWN -1 +#define E_MOREARGS 3 int process_arguments (int, char **); int validate_arguments (void); @@ -53,10 +54,11 @@ int t_diff; time_t time0, time1; - - if (process_arguments (argc, argv) == ERROR) + int state = process_arguments (argc, argv); + if (state == ERROR) usage ("check_ldap: could not parse arguments\n"); - + if (state == E_MOREARGS) + usage ("check_ldap: four arguments are required\n"); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); @@ -143,7 +145,7 @@ #endif if (argc < 2) - return ERROR; + return E_MOREARGS; for (c = 1; c < argc; c++) { if (strcmp ("-to", argv[c]) == 0) @@ -212,10 +214,10 @@ int validate_arguments () { - if (ld_host[0] == 0 || - ld_base[0] == 0 || + if (ld_host == 0 || + ld_base == 0 || ld_port == UNKNOWN || warn_time == UNKNOWN || crit_time == UNKNOWN) { - return ERROR; + return E_MOREARGS; } else { return OK; @@ -241,7 +243,7 @@ "\t-b [--base] ... ldap base (eg. ou=my unit, o=my org, c=at)\n" "\t-D [--bind] ... ldap bind DN (if required)\n" "\t-P [--pass] ... ldap password (if required)\n" - "\t-p [--port] ... ldap port (normaly 389)\n" + "\t-p [--port] ... ldap port (defaults to 389)\n" "\t-w [--warn] ... time in secs. - if the exceeds the STATE_WARNING will be returned\n" "\t-c [--crit] ... time in secs. - if the exceeds the STATE_CRITICAL will be returned\n" "\n"); @@ -252,7 +254,7 @@ print_usage () { printf - ("Usage: %s -H -b -p [-a ] [-D ]\n" - " [-P ] [-w ] [-c ] [-t timeout]\n" + ("Usage: %s -H -b -w -c \n" + "[-p ] [-a ] [-D ] [-P ] [-t time out]\n" "(Note: all times are in seconds.)\n", PROGNAME); }