diff options
| author | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-11-17 17:22:37 +0100 |
|---|---|---|
| committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-11-17 17:22:37 +0100 |
| commit | 487a9d0a8b0700c06857d4bc35423db4e4dbc3d6 (patch) | |
| tree | abfdc545a658550e32a69f0dfdd8ace3aa9f5a41 | |
| parent | bfc745a79d4912479b725c00375aa171f8528ca2 (diff) | |
| download | monitoring-plugins-487a9d0.tar.gz | |
check_radius: Replace functions removed in radcli
The radcli library no longer offers the rc_get_ipaddr(),
rc_good_ipaddr(), and rc_own_ipaddress() functions.
| -rw-r--r-- | plugins/check_radius.c | 19 | ||||
| -rw-r--r-- | plugins/check_smtp.c | 4 | ||||
| -rw-r--r-- | plugins/netutils.c | 15 | ||||
| -rw-r--r-- | plugins/netutils.h | 7 |
4 files changed, 23 insertions, 22 deletions
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 518f1588..b3b8c829 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
| @@ -62,14 +62,12 @@ void print_usage (void); | |||
| 62 | #else | 62 | #else |
| 63 | #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) |
| 64 | #endif | 64 | #endif |
| 65 | #define my_rc_own_ipaddress() rc_own_ipaddress(rch) | ||
| 66 | #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) |
| 67 | #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) | 66 | #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) |
| 68 | #else | 67 | #else |
| 69 | #define my_rc_conf_str(a) rc_conf_str(a) | 68 | #define my_rc_conf_str(a) rc_conf_str(a) |
| 70 | #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) |
| 71 | #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) |
| 72 | #define my_rc_own_ipaddress() rc_own_ipaddress() | ||
| 73 | #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) |
| 74 | #define my_rc_read_dictionary(a) rc_read_dictionary(a) | 72 | #define my_rc_read_dictionary(a) rc_read_dictionary(a) |
| 75 | #endif | 73 | #endif |
| @@ -155,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD. | |||
| 155 | int | 153 | int |
| 156 | main (int argc, char **argv) | 154 | main (int argc, char **argv) |
| 157 | { | 155 | { |
| 156 | struct sockaddr_storage ss; | ||
| 157 | char name[HOST_NAME_MAX]; | ||
| 158 | char msg[BUFFER_LEN]; | 158 | char msg[BUFFER_LEN]; |
| 159 | SEND_DATA data; | 159 | SEND_DATA data; |
| 160 | int result = STATE_UNKNOWN; | 160 | int result = STATE_UNKNOWN; |
| @@ -190,15 +190,14 @@ main (int argc, char **argv) | |||
| 190 | die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); | 190 | die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | if (nasipaddress != NULL) { | 193 | if (nasipaddress == NULL) { |
| 194 | if (rc_good_ipaddr (nasipaddress)) | 194 | if (gethostname (name, sizeof(name)) != 0) |
| 195 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | 195 | die (STATE_UNKNOWN, _("gethostname() failed!\n")); |
| 196 | if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) | 196 | nasipaddress = name; |
| 197 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | ||
| 198 | } else { | ||
| 199 | if ((client_id = my_rc_own_ipaddress ()) == 0) | ||
| 200 | die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n")); | ||
| 201 | } | 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); | ||
| 202 | 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) |
| 203 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); | 202 | die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); |
| 204 | 203 | ||
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 1996c6d3..05e81f2c 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) |
