diff options
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | REQUIREMENTS | 12 | ||||
| -rw-r--r-- | configure.ac | 29 | ||||
| -rwxr-xr-x | plugins-scripts/check_ifoperstatus.pl | 2 | ||||
| -rwxr-xr-x | plugins-scripts/check_ifstatus.pl | 2 | ||||
| -rw-r--r-- | plugins/check_ntp_time.c | 2 | ||||
| -rw-r--r-- | plugins/check_radius.c | 36 | ||||
| -rw-r--r-- | plugins/check_smtp.c | 4 | ||||
| -rw-r--r-- | plugins/netutils.c | 15 | ||||
| -rw-r--r-- | plugins/netutils.h | 7 |
11 files changed, 64 insertions, 48 deletions
diff --git a/.travis.yml b/.travis.yml index 29290fd1..dcf13d58 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -20,7 +20,7 @@ before_install: | |||
| 20 | # - mysql -e "create database IF NOT EXISTS test;" -uroot | 20 | # - mysql -e "create database IF NOT EXISTS test;" -uroot |
| 21 | 21 | ||
| 22 | install: | 22 | install: |
| 23 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps | 23 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps |
| 24 | - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd | 24 | - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd |
| 25 | - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl | 25 | - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl |
| 26 | - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl | 26 | - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl |
| @@ -15,6 +15,7 @@ This file documents the major additions and syntax changes between releases. | |||
| 15 | check_users: add support for range thresholds (John C. Frickson) | 15 | check_users: add support for range thresholds (John C. Frickson) |
| 16 | check_snmp: add ipv6 support (abrist) | 16 | check_snmp: add ipv6 support (abrist) |
| 17 | check_http: report certificate expire date in UTC (pirtoo / ylfingr) | 17 | check_http: report certificate expire date in UTC (pirtoo / ylfingr) |
| 18 | check_radius now supports the radcli library | ||
| 18 | 19 | ||
| 19 | FIXES | 20 | FIXES |
| 20 | Let check_real terminate lines with CRLF when talking to the server, as | 21 | Let check_real terminate lines with CRLF when talking to the server, as |
diff --git a/REQUIREMENTS b/REQUIREMENTS index 303fd62b..ac7b5935 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS | |||
| @@ -50,16 +50,18 @@ check_dbi: | |||
| 50 | http://libdbi.sourceforge.net/ | 50 | http://libdbi.sourceforge.net/ |
| 51 | 51 | ||
| 52 | check_radius: | 52 | check_radius: |
| 53 | - Requires the FreeRADIUS Client library available from: | 53 | - Requires the radcli library available from: |
| 54 | http://radcli.github.io/radcli/ | ||
| 55 | - As an alternative, the FreeRADIUS Client library may be used: | ||
| 54 | http://freeradius.org/freeradius-client/ | 56 | http://freeradius.org/freeradius-client/ |
| 55 | - As an alternative, the radiusclient-ng library may be used: | 57 | - As another alternative, the radiusclient-ng library may be used: |
| 56 | http://sourceforge.net/projects/radiusclient-ng.berlios/ | 58 | http://sourceforge.net/projects/radiusclient-ng.berlios/ |
| 57 | - This plugin also works with the original radiusclient library from | 59 | - This plugin also works with the original radiusclient library from |
| 58 | ftp://ftp.cityline.net/pub/radiusclient/ | 60 | ftp://ftp.cityline.net/pub/radiusclient/ |
| 59 | RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2 | 61 | RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2 |
| 60 | However, you probably want to use the FreeRADIUS Client library, as | 62 | However, you probably want to use either radcli or the FreeRADIUS |
| 61 | both radiusclient and radiusclient-ng are unmaintained and have known | 63 | Client library, as both radiusclient and radiusclient-ng are |
| 62 | issues. | 64 | unmaintained and have known issues. |
| 63 | 65 | ||
| 64 | check_snmp: | 66 | check_snmp: |
| 65 | - Requires the NET-SNMP package available from | 67 | - Requires the NET-SNMP package available from |
diff --git a/configure.ac b/configure.ac index 5ef56f75..367e82a6 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -273,26 +273,33 @@ AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plug | |||
| 273 | dnl Check for radius libraries | 273 | dnl Check for radius libraries |
| 274 | AS_IF([test "x$with_radius" != "xno"], [ | 274 | AS_IF([test "x$with_radius" != "xno"], [ |
| 275 | _SAVEDLIBS="$LIBS" | 275 | _SAVEDLIBS="$LIBS" |
| 276 | AC_CHECK_LIB(freeradius-client,rc_read_config) | 276 | AC_CHECK_LIB(radcli,rc_read_config) |
| 277 | if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then | 277 | if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then |
| 278 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" | 278 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" |
| 279 | RADIUSLIBS="-lfreeradius-client" | 279 | RADIUSLIBS="-lradcli" |
| 280 | AC_SUBST(RADIUSLIBS) | 280 | AC_SUBST(RADIUSLIBS) |
| 281 | else | 281 | else |
| 282 | AC_CHECK_LIB(radiusclient-ng,rc_read_config) | 282 | AC_CHECK_LIB(freeradius-client,rc_read_config) |
| 283 | if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then | 283 | if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then |
| 284 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" | 284 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" |
| 285 | RADIUSLIBS="-lradiusclient-ng" | 285 | RADIUSLIBS="-lfreeradius-client" |
| 286 | AC_SUBST(RADIUSLIBS) | 286 | AC_SUBST(RADIUSLIBS) |
| 287 | else | 287 | else |
| 288 | AC_CHECK_LIB(radiusclient,rc_read_config) | 288 | AC_CHECK_LIB(radiusclient-ng,rc_read_config) |
| 289 | if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then | 289 | if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then |
| 290 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" | 290 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" |
| 291 | RADIUSLIBS="-lradiusclient" | 291 | RADIUSLIBS="-lradiusclient-ng" |
| 292 | AC_SUBST(RADIUSLIBS) | 292 | AC_SUBST(RADIUSLIBS) |
| 293 | else | 293 | else |
| 294 | AC_MSG_WARN([Skipping radius plugin]) | 294 | AC_CHECK_LIB(radiusclient,rc_read_config) |
| 295 | AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) | 295 | if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then |
| 296 | EXTRAS="$EXTRAS check_radius\$(EXEEXT)" | ||
| 297 | RADIUSLIBS="-lradiusclient" | ||
| 298 | AC_SUBST(RADIUSLIBS) | ||
| 299 | else | ||
| 300 | AC_MSG_WARN([Skipping radius plugin]) | ||
| 301 | AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) | ||
| 302 | fi | ||
| 296 | fi | 303 | fi |
| 297 | fi | 304 | fi |
| 298 | fi | 305 | fi |
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl index 3eed4bcb..9ede1633 100755 --- a/plugins-scripts/check_ifoperstatus.pl +++ b/plugins-scripts/check_ifoperstatus.pl | |||
| @@ -325,7 +325,7 @@ sub print_help() { | |||
| 325 | printf " (Implies the use of -I)\n"; | 325 | printf " (Implies the use of -I)\n"; |
| 326 | printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; | 326 | printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; |
| 327 | printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n"; | 327 | printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n"; |
| 328 | printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; | 328 | printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n"; |
| 329 | printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; | 329 | printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; |
| 330 | printf " -V (--version) Plugin version\n"; | 330 | printf " -V (--version) Plugin version\n"; |
| 331 | printf " -h (--help) usage help \n\n"; | 331 | printf " -h (--help) usage help \n\n"; |
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl index 9f2f7c31..32984e53 100755 --- a/plugins-scripts/check_ifstatus.pl +++ b/plugins-scripts/check_ifstatus.pl | |||
| @@ -280,7 +280,7 @@ sub print_help() { | |||
| 280 | printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; | 280 | printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; |
| 281 | printf " privacy password and authEngineID\n"; | 281 | printf " privacy password and authEngineID\n"; |
| 282 | printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n"; | 282 | printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n"; |
| 283 | printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; | 283 | printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n"; |
| 284 | printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; | 284 | printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; |
| 285 | printf " -V (--version) Plugin version\n"; | 285 | printf " -V (--version) Plugin version\n"; |
| 286 | printf " -h (--help) usage help \n\n"; | 286 | printf " -h (--help) usage help \n\n"; |
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index 1cc8cbfb..391b2df2 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
| @@ -633,7 +633,7 @@ void print_help(void){ | |||
| 633 | printf("%s\n", _("Notes:")); | 633 | printf("%s\n", _("Notes:")); |
| 634 | printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use")); | 634 | printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use")); |
| 635 | printf(" %s\n", _("check_ntp_peer.")); | 635 | printf(" %s\n", _("check_ntp_peer.")); |
| 636 | printf(" %s\n", _("--time-offset is usefull for compensating for servers with known")); | 636 | printf(" %s\n", _("--time-offset is useful for compensating for servers with known")); |
| 637 | printf(" %s\n", _("and expected clock skew.")); | 637 | printf(" %s\n", _("and expected clock skew.")); |
| 638 | printf("\n"); | 638 | printf("\n"); |
| 639 | printf(UT_THRESHOLDS_NOTES); | 639 | printf(UT_THRESHOLDS_NOTES); |
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 03cbb8b0..b3b8c829 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
| @@ -36,7 +36,9 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 36 | #include "utils.h" | 36 | #include "utils.h" |
| 37 | #include "netutils.h" | 37 | #include "netutils.h" |
| 38 | 38 | ||
| 39 | #if defined(HAVE_LIBFREERADIUS_CLIENT) | 39 | #if defined(HAVE_LIBRADCLI) |
| 40 | #include <radcli/radcli.h> | ||
| 41 | #elif defined(HAVE_LIBFREERADIUS_CLIENT) | ||
| 40 | #include <freeradius-client.h> | 42 | #include <freeradius-client.h> |
| 41 | #elif defined(HAVE_LIBRADIUSCLIENT_NG) | 43 | #elif defined(HAVE_LIBRADIUSCLIENT_NG) |
| 42 | #include <radiusclient-ng.h> | 44 | #include <radiusclient-ng.h> |
| @@ -48,22 +50,24 @@ int process_arguments (int, char **); | |||
| 48 | void print_help (void); | 50 | void print_help (void); |
| 49 | void print_usage (void); | 51 | void print_usage (void); |
| 50 | 52 | ||
| 51 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) | 53 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) |
| 52 | #define my_rc_conf_str(a) rc_conf_str(rch,a) | 54 | #define my_rc_conf_str(a) rc_conf_str(rch,a) |
| 55 | #if defined(HAVE_LIBRADCLI) | ||
| 56 | #define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH) | ||
| 57 | #else | ||
| 53 | #define my_rc_send_server(a,b) rc_send_server(rch,a,b) | 58 | #define my_rc_send_server(a,b) rc_send_server(rch,a,b) |
| 54 | #ifdef HAVE_LIBFREERADIUS_CLIENT | 59 | #endif |
| 60 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI) | ||
| 55 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f) | 61 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f) |
| 56 | #else | 62 | #else |
| 57 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) | 63 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) |
| 58 | #endif | 64 | #endif |
| 59 | #define my_rc_own_ipaddress() rc_own_ipaddress(rch) | ||
| 60 | #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) | 65 | #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) |
| 61 | #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) | 66 | #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) |
| 62 | #else | 67 | #else |
| 63 | #define my_rc_conf_str(a) rc_conf_str(a) | 68 | #define my_rc_conf_str(a) rc_conf_str(a) |
| 64 | #define my_rc_send_server(a,b) rc_send_server(a, b) | 69 | #define my_rc_send_server(a,b) rc_send_server(a, b) |
| 65 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) | 70 | #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) |
| 66 | #define my_rc_own_ipaddress() rc_own_ipaddress() | ||
| 67 | #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) | 71 | #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) |
| 68 | #define my_rc_read_dictionary(a) rc_read_dictionary(a) | 72 | #define my_rc_read_dictionary(a) rc_read_dictionary(a) |
| 69 | #endif | 73 | #endif |
| @@ -76,7 +80,7 @@ void print_usage (void); | |||
| 76 | 80 | ||
| 77 | int my_rc_read_config(char *); | 81 | int my_rc_read_config(char *); |
| 78 | 82 | ||
| 79 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) | 83 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) |
| 80 | rc_handle *rch = NULL; | 84 | rc_handle *rch = NULL; |
| 81 | #endif | 85 | #endif |
| 82 | 86 | ||
| @@ -90,7 +94,6 @@ char *config_file = NULL; | |||
| 90 | unsigned short port = PW_AUTH_UDP_PORT; | 94 | unsigned short port = PW_AUTH_UDP_PORT; |
| 91 | int retries = 1; | 95 | int retries = 1; |
| 92 | int verbose = FALSE; | 96 | int verbose = FALSE; |
| 93 | ENV *env = NULL; | ||
| 94 | 97 | ||
| 95 | /****************************************************************************** | 98 | /****************************************************************************** |
| 96 | 99 | ||
| @@ -150,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD. | |||
| 150 | int | 153 | int |
| 151 | main (int argc, char **argv) | 154 | main (int argc, char **argv) |
| 152 | { | 155 | { |
| 156 | struct sockaddr_storage ss; | ||
| 157 | char name[HOST_NAME_MAX]; | ||
| 153 | char msg[BUFFER_LEN]; | 158 | char msg[BUFFER_LEN]; |
| 154 | SEND_DATA data; | 159 | SEND_DATA data; |
| 155 | int result = STATE_UNKNOWN; | 160 | int result = STATE_UNKNOWN; |
| @@ -185,15 +190,14 @@ main (int argc, char **argv) | |||
| 185 | die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); | 190 | die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); |
| 186 | } | 191 | } |
| 187 | 192 | ||
| 188 | if (nasipaddress != NULL) { | 193 | if (nasipaddress == NULL) { |
| 189 | if (rc_good_ipaddr (nasipaddress)) | 194 | if (gethostname (name, sizeof(name)) != 0) |
| 190 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | 195 | die (STATE_UNKNOWN, _("gethostname() failed!\n")); |
| 191 | if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) | 196 | nasipaddress = name; |
| 192 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | ||
| 193 | } else { | ||
| 194 | if ((client_id = my_rc_own_ipaddress ()) == 0) | ||
| 195 | die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n")); | ||
| 196 | } | 197 | } |
| 198 | if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */ | ||
| 199 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | ||
| 200 | client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr); | ||
| 197 | if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) | 201 | if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) |
| 198 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | 202 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); |
| 199 | 203 | ||
| @@ -399,7 +403,7 @@ print_usage (void) | |||
| 399 | 403 | ||
| 400 | int my_rc_read_config(char * a) | 404 | int my_rc_read_config(char * a) |
| 401 | { | 405 | { |
| 402 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) | 406 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) |
| 403 | rch = rc_read_config(a); | 407 | rch = rc_read_config(a); |
| 404 | return (rch == NULL) ? 1 : 0; | 408 | return (rch == NULL) ? 1 : 0; |
| 405 | #else | 409 | #else |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index f5a6fa3d..587a7245 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -59,10 +59,6 @@ enum { | |||
| 59 | #define SMTP_STARTTLS "STARTTLS\r\n" | 59 | #define SMTP_STARTTLS "STARTTLS\r\n" |
| 60 | #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" | 60 | #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" |
| 61 | 61 | ||
| 62 | #ifndef HOST_MAX_BYTES | ||
| 63 | #define HOST_MAX_BYTES 255 | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #define EHLO_SUPPORTS_STARTTLS 1 | 62 | #define EHLO_SUPPORTS_STARTTLS 1 |
| 67 | 63 | ||
| 68 | int process_arguments (int, char **); | 64 | int process_arguments (int, char **); |
diff --git a/plugins/netutils.c b/plugins/netutils.c index 705aaf09..1bb4f076 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
| @@ -359,20 +359,21 @@ is_addr (const char *address) | |||
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | int | 361 | int |
| 362 | resolve_host_or_addr (const char *address, int family) | 362 | dns_lookup (const char *in, struct sockaddr_storage *ss, int family) |
| 363 | { | 363 | { |
| 364 | struct addrinfo hints; | 364 | struct addrinfo hints; |
| 365 | struct addrinfo *res; | 365 | struct addrinfo *res; |
| 366 | int retval; | 366 | int retval; |
| 367 | 367 | ||
| 368 | memset (&hints, 0, sizeof (hints)); | 368 | memset (&hints, 0, sizeof(struct addrinfo)); |
| 369 | hints.ai_family = family; | 369 | hints.ai_family = family; |
| 370 | retval = getaddrinfo (address, NULL, &hints, &res); | ||
| 371 | 370 | ||
| 371 | retval = getaddrinfo (in, NULL, &hints, &res); | ||
| 372 | if (retval != 0) | 372 | if (retval != 0) |
| 373 | return FALSE; | 373 | return FALSE; |
| 374 | else { | 374 | |
| 375 | freeaddrinfo (res); | 375 | if (ss != NULL) |
| 376 | return TRUE; | 376 | memcpy (ss, res->ai_addr, res->ai_addrlen); |
| 377 | } | 377 | freeaddrinfo (res); |
| 378 | return TRUE; | ||
| 378 | } | 379 | } |
diff --git a/plugins/netutils.h b/plugins/netutils.h index 2766029e..d7ee0ddd 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
| @@ -45,6 +45,10 @@ | |||
| 45 | # endif /* UNIX_PATH_MAX */ | 45 | # endif /* UNIX_PATH_MAX */ |
| 46 | #endif /* HAVE_SYS_UN_H */ | 46 | #endif /* HAVE_SYS_UN_H */ |
| 47 | 47 | ||
| 48 | #ifndef HOST_MAX_BYTES | ||
| 49 | # define HOST_MAX_BYTES 255 | ||
| 50 | #endif | ||
| 51 | |||
| 48 | /* process_request and wrapper macros */ | 52 | /* process_request and wrapper macros */ |
| 49 | #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ | 53 | #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ |
| 50 | process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) | 54 | process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) |
| @@ -71,8 +75,9 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, | |||
| 71 | /* "is_*" wrapper macros and functions */ | 75 | /* "is_*" wrapper macros and functions */ |
| 72 | int is_host (const char *); | 76 | int is_host (const char *); |
| 73 | int is_addr (const char *); | 77 | int is_addr (const char *); |
| 74 | int resolve_host_or_addr (const char *, int); | 78 | int dns_lookup (const char *, struct sockaddr_storage *, int); |
| 75 | void host_or_die(const char *str); | 79 | void host_or_die(const char *str); |
| 80 | #define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) | ||
| 76 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) | 81 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) |
| 77 | #ifdef USE_IPV6 | 82 | #ifdef USE_IPV6 |
| 78 | # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) | 83 | # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) |
