From e71d2c2b71d20ba3110030b4c6f3de1d9e827313 Mon Sep 17 00:00:00 2001 From: Benoit Mortier Date: Wed, 8 Dec 2004 00:36:19 +0000 Subject: [PATCH] patch 1028033 minor internationalization fixes git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1013 f882894a-f735-0410-b71e-b25c423dba1c --- configure.in | 1 + plugins/Makefile.am | 5 +-- plugins/check_by_ssh.c | 4 +-- plugins/check_game.c | 4 +-- plugins/check_http.c | 4 +-- plugins/check_ide_smart.c | 2 +- plugins/check_ldap.c | 67 ++++++++++++++++++++++++++++++++++++++- plugins/check_snmp.c | 2 +- plugins/check_tcp.c | 2 +- 9 files changed, 79 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 36f8605..65dc698 100644 --- a/configure.in +++ b/configure.in @@ -204,6 +204,7 @@ if test "$ac_cv_lib_ldap_main" = "yes"; then AC_SUBST(LDAPINCLUDE) AC_CHECK_FUNCS(ldap_set_option) EXTRAS="$EXTRAS check_ldap" + AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s) else AC_MSG_WARN([Skipping LDAP plugin]) AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).]) diff --git a/plugins/Makefile.am b/plugins/Makefile.am index eb67e45..2c0a5c2 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -140,8 +140,9 @@ $(check_tcp_programs): check_tcp install-exec-hook: cd $(DESTDIR)$(libexecdir) && \ - for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done - + for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done ;\ + rm -f check_ldaps ; ln -s -f check_ldap check_ldaps + clean-local: rm -f $(check_tcp_programs) diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index dd2230a..f31c9c6 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -393,13 +393,13 @@ To use passive mode, provide multiple '-C' options, and provide\n\ all of -O, -s, and -n options (servicelist order must match '-C'\n\ options)\n")); - printf (_("\n\ + printf ("\n\ $ check_by_ssh -H localhost -n lh -s c1:c2:c3 \\\n\ -C uptime -C uptime -C uptime -O /tmp/foo\n\ $ cat /tmp/foo\n\ [1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c1;0; up 2 days...\n\ [1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c2;0; up 2 days...\n\ -[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c3;0; up 2 days...\n")); +[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c3;0; up 2 days...\n"); printf (_(UT_SUPPORT)); } diff --git a/plugins/check_game.c b/plugins/check_game.c index 9a6e53e..6699c71 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c @@ -300,9 +300,9 @@ print_help (void) print_revision (progname, revision); printf ("Copyright (c) 1999 Ian Cass, Knowledge Matters Limited\n"); - printf (_(COPYRIGHT), copyright, email); + printf (COPYRIGHT, copyright, email); - printf (_("This plugin tests game server connections with the specified host."), progname); + printf (_("This plugin tests game server connections with the specified host.")); print_usage (); diff --git a/plugins/check_http.c b/plugins/check_http.c index dd05821..5f96e31 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1490,11 +1490,11 @@ the certificate is expired.\n")); void print_usage (void) { - printf (_("\ + printf ("\ Usage: %s -H | -I ) [-u ] [-p ]\n\ [-w ] [-c ] [-t ] [-L]\n\ [-a auth] [-f ] [-e ]\n\ [-s string] [-l] [-r | -R ]\n\ [-P string] [-m min_pg_size] [-4|-6] [-N] [-M ]\n\ - [-A string] [-k string]\n"), progname); + [-A string] [-k string]\n", progname); } diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 1c0af31..644dc48 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c @@ -498,7 +498,7 @@ print_help () printf ("(C) 1999 Ragnar Hojland Espinosa \n"); printf (COPYRIGHT, copyright, email); - printf (_("\ + printf ("\ Usage: %s [DEVICE] [OPTION]\n\ -d, --device=DEVICE\n\ Select device DEVICE\n\ diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index e77ad30..29bc01b 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -57,6 +57,10 @@ double warn_time = UNDEFINED; double crit_time = UNDEFINED; struct timeval tv; +/* for ldap tls */ + +char *SERVICE = "LDAP"; + int main (int argc, char *argv[]) { @@ -69,11 +73,20 @@ main (int argc, char *argv[]) int status = STATE_UNKNOWN; long microsec; double elapsed_time; + + /* for ldap tls */ + + int tls; + int version=3; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); + if (strstr(argv[0],"check_ldaps")) { + asprintf (&progname, "check_ldaps"); + } + if (process_arguments (argc, argv) == ERROR) usage4 (_("Could not parse arguments")); @@ -87,12 +100,19 @@ main (int argc, char *argv[]) gettimeofday (&tv, NULL); /* initialize ldap */ +#ifdef HAVE_LDAP_INIT + if (!(ld = ldap_init (ld_host, ld_port))) { + printf ("Could not connect to the server at port %i\n", ld_port); + return STATE_CRITICAL; + } +#else if (!(ld = ldap_open (ld_host, ld_port))) { /*ldap_perror(ld, "ldap_open"); */ printf (_("Could not connect to the server at port %i\n"), ld_port); return STATE_CRITICAL; } - +#endif /* HAVE_LDAP_INIT */ + #ifdef HAVE_LDAP_SET_OPTION /* set ldap options */ if (ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &ld_protocol) != @@ -101,6 +121,51 @@ main (int argc, char *argv[]) return STATE_CRITICAL; } #endif + + if (strstr(argv[0],"check_ldaps")) { + /* with TLS */ + if ( ld_port == LDAPS_PORT ) { + asprintf (&SERVICE, "LDAPS"); +#if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS) + /* ldaps: set option tls */ + tls = LDAP_OPT_X_TLS_HARD; + + if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) + { + /*ldap_perror(ld, "ldaps_option"); */ + printf ("Could not init TLS at port %i!\n", ld_port); + return STATE_CRITICAL; + } +#else + printf ("TLS not supported by the libraries!\n", ld_port); + return STATE_CRITICAL; +#endif /* LDAP_OPT_X_TLS */ + } else { + asprintf (&SERVICE, "LDAP-TLS"); +#if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S) + /* ldap with startTLS: set option version */ + if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS ) + { + if (version < LDAP_VERSION3) + { + version = LDAP_VERSION3; + ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); + } + } + /* call start_tls */ + if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) + { + /*ldap_perror(ld, "ldap_start_tls"); */ + printf ("Could not init startTLS at port %i!\n", ld_port); + return STATE_CRITICAL; + } +#else + printf ("startTLS not supported by the library, needs LDAPv3!\n"); + return STATE_CRITICAL; +#endif /* HAVE_LDAP_START_TLS_S */ + } + } + /* bind to the ldap server */ if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) { diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index ab110fb..c1c4ea8 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -656,7 +656,7 @@ validate_arguments () } else if ( strcmp(seclevel, "authPriv") == 0 ) { if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) { - printf (("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd ); + printf (_("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd ); print_usage (); exit (STATE_UNKNOWN); } diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index ce57631..7d8d814 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -479,7 +479,7 @@ process_arguments (int argc, char **argv) break; case 'H': /* hostname */ if (is_host (optarg) == FALSE) - usage2 (_("invalid hostname/address"), optarg); + usage2 (_("Invalid hostname/address"), optarg); server_address = optarg; break; case 'c': /* critical */ -- 2.30.2