From 1b1c5e9c29941bfe4bda8925da11499ac49f2dcd Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Sat, 5 Nov 2016 19:05:15 +0100 Subject: [PATCH] Adding d/p/20_check_radius_radcli to add support for radcli (Closes: #822337) --- debian/patches/20_check_radius_radcli | 347 ++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 348 insertions(+) create mode 100644 debian/patches/20_check_radius_radcli diff --git a/debian/patches/20_check_radius_radcli b/debian/patches/20_check_radius_radcli new file mode 100644 index 0000000..4aa32d1 --- /dev/null +++ b/debian/patches/20_check_radius_radcli @@ -0,0 +1,347 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -273,26 +273,33 @@ + dnl Check for radius libraries + AS_IF([test "x$with_radius" != "xno"], [ + _SAVEDLIBS="$LIBS" +- AC_CHECK_LIB(freeradius-client,rc_read_config) +- if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then ++ AC_CHECK_LIB(radcli,rc_read_config) ++ if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then + EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lfreeradius-client" ++ RADIUSLIBS="-lradcli" + AC_SUBST(RADIUSLIBS) + else +- AC_CHECK_LIB(radiusclient-ng,rc_read_config) +- if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then ++ AC_CHECK_LIB(freeradius-client,rc_read_config) ++ if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then + EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lradiusclient-ng" ++ RADIUSLIBS="-lfreeradius-client" + AC_SUBST(RADIUSLIBS) + else +- AC_CHECK_LIB(radiusclient,rc_read_config) +- if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then ++ AC_CHECK_LIB(radiusclient-ng,rc_read_config) ++ if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then + EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lradiusclient" ++ RADIUSLIBS="-lradiusclient-ng" + AC_SUBST(RADIUSLIBS) + else +- AC_MSG_WARN([Skipping radius plugin]) +- AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) ++ AC_CHECK_LIB(radiusclient,rc_read_config) ++ if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then ++ EXTRAS="$EXTRAS check_radius\$(EXEEXT)" ++ RADIUSLIBS="-lradiusclient" ++ AC_SUBST(RADIUSLIBS) ++ else ++ AC_MSG_WARN([Skipping radius plugin]) ++ AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) ++ fi + fi + fi + fi +--- a/plugins/check_radius.c ++++ b/plugins/check_radius.c +@@ -36,7 +36,9 @@ + #include "utils.h" + #include "netutils.h" + +-#if defined(HAVE_LIBFREERADIUS_CLIENT) ++#if defined(HAVE_LIBRADCLI) ++#include ++#elif defined(HAVE_LIBFREERADIUS_CLIENT) + #include + #elif defined(HAVE_LIBRADIUSCLIENT_NG) + #include +@@ -48,22 +50,24 @@ + void print_help (void); + void print_usage (void); + +-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) ++#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) + #define my_rc_conf_str(a) rc_conf_str(rch,a) ++#if defined(HAVE_LIBRADCLI) ++#define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH) ++#else + #define my_rc_send_server(a,b) rc_send_server(rch,a,b) +-#ifdef HAVE_LIBFREERADIUS_CLIENT ++#endif ++#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI) + #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f) + #else + #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) + #endif +-#define my_rc_own_ipaddress() rc_own_ipaddress(rch) + #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) + #define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) + #else + #define my_rc_conf_str(a) rc_conf_str(a) + #define my_rc_send_server(a,b) rc_send_server(a, b) + #define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) +-#define my_rc_own_ipaddress() rc_own_ipaddress() + #define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) + #define my_rc_read_dictionary(a) rc_read_dictionary(a) + #endif +@@ -76,7 +80,7 @@ + + int my_rc_read_config(char *); + +-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) ++#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) + rc_handle *rch = NULL; + #endif + +@@ -90,7 +94,6 @@ + unsigned short port = PW_AUTH_UDP_PORT; + int retries = 1; + int verbose = FALSE; +-ENV *env = NULL; + + /****************************************************************************** + +@@ -150,6 +153,8 @@ + int + main (int argc, char **argv) + { ++ struct sockaddr_storage ss; ++ char name[HOST_NAME_MAX]; + char msg[BUFFER_LEN]; + SEND_DATA data; + int result = STATE_UNKNOWN; +@@ -185,15 +190,14 @@ + die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); + } + +- if (nasipaddress != NULL) { +- if (rc_good_ipaddr (nasipaddress)) +- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); +- if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) +- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); +- } else { +- if ((client_id = my_rc_own_ipaddress ()) == 0) +- die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n")); ++ if (nasipaddress == NULL) { ++ if (gethostname (name, sizeof(name)) != 0) ++ die (STATE_UNKNOWN, _("gethostname() failed!\n")); ++ nasipaddress = name; + } ++ if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */ ++ die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); ++ client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr); + if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) + die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); + +@@ -399,7 +403,7 @@ + + int my_rc_read_config(char * a) + { +-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) ++#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) + rch = rc_read_config(a); + return (rch == NULL) ? 1 : 0; + #else +--- a/config.h.in ++++ b/config.h.in +@@ -483,6 +483,9 @@ + /* Define to 1 if you have the `pthread' library (-lpthread). */ + #undef HAVE_LIBPTHREAD + ++/* Define to 1 if you have the `radcli' library (-lradcli). */ ++#undef HAVE_LIBRADCLI ++ + /* Define to 1 if you have the `radiusclient' library (-lradiusclient). */ + #undef HAVE_LIBRADIUSCLIENT + +--- a/configure ++++ b/configure +@@ -14963,7 +14963,57 @@ + if test "x$with_radius" != "xno"; then : + + _SAVEDLIBS="$LIBS" +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradcli" >&5 ++$as_echo_n "checking for rc_read_config in -lradcli... " >&6; } ++if ${ac_cv_lib_radcli_rc_read_config+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lradcli $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char rc_read_config (); ++int ++main () ++{ ++return rc_read_config (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_radcli_rc_read_config=yes ++else ++ ac_cv_lib_radcli_rc_read_config=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radcli_rc_read_config" >&5 ++$as_echo "$ac_cv_lib_radcli_rc_read_config" >&6; } ++if test "x$ac_cv_lib_radcli_rc_read_config" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LIBRADCLI 1 ++_ACEOF ++ ++ LIBS="-lradcli $LIBS" ++ ++fi ++ ++ if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then ++ EXTRAS="$EXTRAS check_radius\$(EXEEXT)" ++ RADIUSLIBS="-lradcli" ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5 + $as_echo_n "checking for rc_read_config in -lfreeradius-client... " >&6; } + if ${ac_cv_lib_freeradius_client_rc_read_config+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -15008,12 +15058,12 @@ + + fi + +- if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then +- EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lfreeradius-client" ++ if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then ++ EXTRAS="$EXTRAS check_radius\$(EXEEXT)" ++ RADIUSLIBS="-lfreeradius-client" + +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5 + $as_echo_n "checking for rc_read_config in -lradiusclient-ng... " >&6; } + if ${ac_cv_lib_radiusclient_ng_rc_read_config+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -15058,12 +15108,12 @@ + + fi + +- if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then +- EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lradiusclient-ng" ++ if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then ++ EXTRAS="$EXTRAS check_radius\$(EXEEXT)" ++ RADIUSLIBS="-lradiusclient-ng" + +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient" >&5 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient" >&5 + $as_echo_n "checking for rc_read_config in -lradiusclient... " >&6; } + if ${ac_cv_lib_radiusclient_rc_read_config+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -15108,15 +15158,16 @@ + + fi + +- if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then +- EXTRAS="$EXTRAS check_radius\$(EXEEXT)" +- RADIUSLIBS="-lradiusclient" ++ if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then ++ EXTRAS="$EXTRAS check_radius\$(EXEEXT)" ++ RADIUSLIBS="-lradiusclient" + +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping radius plugin" >&5 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping radius plugin" >&5 + $as_echo "$as_me: WARNING: Skipping radius plugin" >&2;} +- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&5 + $as_echo "$as_me: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&2;} ++ fi + fi + fi + fi +--- a/plugins/netutils.c ++++ b/plugins/netutils.c +@@ -357,20 +357,21 @@ + } + + int +-resolve_host_or_addr (const char *address, int family) ++dns_lookup (const char *in, struct sockaddr_storage *ss, int family) + { + struct addrinfo hints; + struct addrinfo *res; + int retval; + +- memset (&hints, 0, sizeof (hints)); ++ memset (&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = family; +- retval = getaddrinfo (address, NULL, &hints, &res); + ++ retval = getaddrinfo (in, NULL, &hints, &res); + if (retval != 0) + return FALSE; +- else { +- freeaddrinfo (res); +- return TRUE; +- } ++ ++ if (ss != NULL) ++ memcpy (ss, res->ai_addr, res->ai_addrlen); ++ freeaddrinfo (res); ++ return TRUE; + } +--- a/plugins/netutils.h ++++ b/plugins/netutils.h +@@ -45,6 +45,10 @@ + # endif /* UNIX_PATH_MAX */ + #endif /* HAVE_SYS_UN_H */ + ++#ifndef HOST_MAX_BYTES ++# define HOST_MAX_BYTES 255 ++#endif ++ + /* process_request and wrapper macros */ + #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ + process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) +@@ -71,8 +75,9 @@ + /* "is_*" wrapper macros and functions */ + int is_host (const char *); + int is_addr (const char *); +-int resolve_host_or_addr (const char *, int); ++int dns_lookup (const char *, struct sockaddr_storage *, int); + void host_or_die(const char *str); ++#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) + #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) + #ifdef USE_IPV6 + # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) +--- a/plugins/check_smtp.c ++++ b/plugins/check_smtp.c +@@ -59,10 +59,6 @@ + #define SMTP_STARTTLS "STARTTLS\r\n" + #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" + +-#ifndef HOST_MAX_BYTES +-#define HOST_MAX_BYTES 255 +-#endif +- + #define EHLO_SUPPORTS_STARTTLS 1 + + int process_arguments (int, char **); diff --git a/debian/patches/series b/debian/patches/series index 051cf08..1538bc9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -8,3 +8,4 @@ 15_check_smtp_expect 16_check_smtp_quit 17_check_smtp_forcetls_on_cert +20_check_radius_radcli