summaryrefslogtreecommitdiffstats
path: root/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS')
-rw-r--r--web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS195
1 files changed, 195 insertions, 0 deletions
diff --git a/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS b/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS
new file mode 100644
index 0000000..66046e3
--- /dev/null
+++ b/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS
@@ -0,0 +1,195 @@
1diff -r -p nagios-plugins-1.3.1/configure.in nagios-plugins-1.3.1-patchTLS/configure.in
2*** nagios-plugins-1.3.1/configure.in Fri Jul 11 08:12:23 2003
3--- nagios-plugins-1.3.1-patchTLS/configure.in Tue Sep 14 15:07:12 2004
4*************** if test "$ac_cv_lib_ldap_main" = "yes";
5*** 165,170 ****
6--- 165,171 ----
7 AC_SUBST(LDAPLIBS)
8 AC_SUBST(LDAPINCLUDE)
9 EXTRAS="$EXTRAS check_ldap"
10+ AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
11 else
12 AC_MSG_WARN([Skipping LDAP plugin])
13 AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
14diff -r -p nagios-plugins-1.3.1/plugins/Makefile.am nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am
15*** nagios-plugins-1.3.1/plugins/Makefile.am Fri Jul 11 08:11:06 2003
16--- nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am Sat Sep 11 01:59:42 2004
17*************** $(check_tcp_programs): check_tcp
18*** 132,138 ****
19
20 install-exec-hook:
21 cd $(DESTDIR)$(libexecdir) && \
22! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done
23
24 clean-local:
25 rm -f $(check_tcp_programs)
26--- 132,139 ----
27
28 install-exec-hook:
29 cd $(DESTDIR)$(libexecdir) && \
30! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done ;\
31! rm -f check_ldaps ; ln -s -f check_ldap check_ldaps
32
33 clean-local:
34 rm -f $(check_tcp_programs)
35diff -r -p nagios-plugins-1.3.1/plugins/check_ldap.c nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c
36*** nagios-plugins-1.3.1/plugins/check_ldap.c Wed Jan 29 07:16:15 2003
37--- nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c Tue Sep 14 15:16:05 2004
38***************
39*** 20,26 ****
40 *
41 *****************************************************************************/
42
43! const char *progname = "check_ldap";
44 const char *revision = "$Revision: 1.4 $";
45
46 #include "config.h"
47--- 20,26 ----
48 *
49 *****************************************************************************/
50
51! char *progname = "check_ldap";
52 const char *revision = "$Revision: 1.4 $";
53
54 #include "config.h"
55*************** char *ld_binddn = NULL;
56*** 50,55 ****
57--- 50,56 ----
58 unsigned int ld_port = DEFAULT_PORT;
59 int warn_time = UNDEFINED;
60 int crit_time = UNDEFINED;
61+ char *SERVICE = "LDAP";
62
63 int
64 main (int argc, char *argv[])
65*************** main (int argc, char *argv[])
66*** 60,65 ****
67--- 61,73 ----
68
69 int t_diff;
70 time_t time0, time1;
71+ int tls;
72+
73+ int version=3;
74+
75+ if (strstr(argv[0],"check_ldaps")) {
76+ asprintf (&progname, "check_ldaps");
77+ }
78
79 if (process_arguments (argc, argv) == ERROR)
80 usage ("check_ldap: could not parse arguments\n");
81*************** main (int argc, char *argv[])
82*** 74,84 ****
83 time (&time0);
84
85 /* initialize ldap */
86 if (!(ld = ldap_open (ld_host, ld_port))) {
87- /*ldap_perror(ld, "ldap_open"); */
88 printf ("Could not connect to the server at port %i\n", ld_port);
89 return STATE_CRITICAL;
90 }
91
92 /* bind to the ldap server */
93 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) !=
94--- 82,145 ----
95 time (&time0);
96
97 /* initialize ldap */
98+ #ifdef HAVE_LDAP_INIT
99+ if (!(ld = ldap_init (ld_host, ld_port))) {
100+ printf ("Could not connect to the server at port %i\n", ld_port);
101+ return STATE_CRITICAL;
102+ }
103+ #else
104 if (!(ld = ldap_open (ld_host, ld_port))) {
105 printf ("Could not connect to the server at port %i\n", ld_port);
106 return STATE_CRITICAL;
107 }
108+ #endif /* HAVE_LDAP_INIT */
109+
110+ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_PROTOCOL_VERSION)
111+ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
112+ #endif /* LDAP_OPT_PROTOCOL_VERSION */
113+
114+ if (strstr(argv[0],"check_ldaps")) {
115+ /* with TLS */
116+ if ( ld_port == LDAPS_PORT ) {
117+ asprintf (&SERVICE, "LDAPS");
118+ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS)
119+ /* ldaps: set option tls */
120+ tls = LDAP_OPT_X_TLS_HARD;
121+ if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS)
122+ {
123+ /*ldap_perror(ld, "ldaps_option"); */
124+ printf ("Could not init TLS at port %i!\n", ld_port);
125+ return STATE_CRITICAL;
126+ }
127+ #else
128+ printf ("TLS not supported by the libraries!\n", ld_port);
129+ return STATE_CRITICAL;
130+ #endif /* LDAP_OPT_X_TLS */
131+ } else {
132+ asprintf (&SERVICE, "LDAP-TLS");
133+ #if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S)
134+ /* ldap with startTLS: set option version */
135+ if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS )
136+ {
137+ if (version < LDAP_VERSION3)
138+ {
139+ version = LDAP_VERSION3;
140+ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
141+ }
142+ }
143+ /* call start_tls */
144+ if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS)
145+ {
146+ /*ldap_perror(ld, "ldap_start_tls"); */
147+ printf ("Could not init startTLS at port %i!\n", ld_port);
148+ return STATE_CRITICAL;
149+ }
150+ #else
151+ printf ("startTLS not supported by the library, needs LDAPv3!\n");
152+ return STATE_CRITICAL;
153+ #endif /* HAVE_LDAP_START_TLS_S */
154+ }
155+ }
156
157 /* bind to the ldap server */
158 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) !=
159*************** main (int argc, char *argv[])
160*** 109,125 ****
161 t_diff = time1 - time0;
162
163 if (crit_time!=UNDEFINED && t_diff>=crit_time) {
164! printf ("LDAP critical - %i seconds response time\n", t_diff);
165 return STATE_CRITICAL;
166 }
167
168 if (warn_time!=UNDEFINED && t_diff>=warn_time) {
169! printf ("LDAP warning - %i seconds response time\n", t_diff);
170 return STATE_WARNING;
171 }
172
173 /* print out the result */
174! printf ("LDAP ok - %i seconds response time\n", t_diff);
175
176 return STATE_OK;
177 }
178--- 170,186 ----
179 t_diff = time1 - time0;
180
181 if (crit_time!=UNDEFINED && t_diff>=crit_time) {
182! printf ("%s critical - %i seconds response time\n", SERVICE, t_diff);
183 return STATE_CRITICAL;
184 }
185
186 if (warn_time!=UNDEFINED && t_diff>=warn_time) {
187! printf ("%s warning - %i seconds response time\n", SERVICE, t_diff);
188 return STATE_WARNING;
189 }
190
191 /* print out the result */
192! printf ("%s ok - %i seconds response time\n", SERVICE, t_diff);
193
194 return STATE_OK;
195 }