summaryrefslogtreecommitdiffstats
path: root/web/attachments/38944-check_ldap.c.patch
blob: 50c5f867bd504542fdb861231ca2d581ec140579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- 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 <ldap.h>
 
 #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 <warn> the STATE_WARNING will be returned\n"
 		 "\t-c [--crit] ... time in secs. - if the exceeds <crit> the STATE_CRITICAL will be returned\n"
 		 "\n");
@@ -252,7 +254,7 @@
 print_usage ()
 {
 	printf
-		("Usage: %s -H <host> -b <base_dn> -p <port> [-a <attr>] [-D <binddn>]\n"
-		 "         [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
+	("Usage: %s -H <host> -b <base_dn>  -w <warn_time> -c <crit_time>\n" 
+	 "[-p <port>] [-a <attr>] [-D <binddn>] [-P <password>] [-t time out]\n"
 		 "(Note: all times are in seconds.)\n", PROGNAME);
 }