From cf8feb2876762a24f0ee7b7991a7a53e7567537c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 24 Mar 2021 08:54:17 -0600 Subject: [PATCH] Remove support for obsolete ISC UNIX and MIPS RISC/OS systems. They were getting in the way of net_its.c simplification. --- configure | 146 -------------------------------------------------- configure.ac | 18 ------- src/net_ifs.c | 88 +++++++++++------------------- 3 files changed, 31 insertions(+), 221 deletions(-) diff --git a/configure b/configure index f27b00bb5..9e3a000e8 100755 --- a/configure +++ b/configure @@ -16732,152 +16732,6 @@ fi # lockf() is broken on the Hurd ac_cv_func_lockf=no ;; - *-*-riscos*) - LIBS="${LIBS} -lsun -lbsd" - -if test ${CPPFLAGS+y} -then : - - case " $CPPFLAGS " in #( - *" -I/usr/include "*) : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS already contains -I/usr/include"; } >&5 - (: CPPFLAGS already contains -I/usr/include) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } ;; #( - *) : - - as_fn_append CPPFLAGS " -I/usr/include" - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; -esac - -else $as_nop - - CPPFLAGS=-I/usr/include - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - -fi - - -if test ${CPPFLAGS+y} -then : - - case " $CPPFLAGS " in #( - *" -I/usr/include/bsd "*) : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS already contains -I/usr/include/bsd"; } >&5 - (: CPPFLAGS already contains -I/usr/include/bsd) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } ;; #( - *) : - - as_fn_append CPPFLAGS " -I/usr/include/bsd" - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; -esac - -else $as_nop - - CPPFLAGS=-I/usr/include/bsd - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - -fi - - -if test ${CPPFLAGS+y} -then : - - case " $CPPFLAGS " in #( - *" -D_MIPS "*) : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS already contains -D_MIPS"; } >&5 - (: CPPFLAGS already contains -D_MIPS) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } ;; #( - *) : - - as_fn_append CPPFLAGS " -D_MIPS" - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; -esac - -else $as_nop - - CPPFLAGS=-D_MIPS - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - -fi - - : ${mansectsu='1m'} - : ${mansectform='4'} - ;; - *-*-isc*) - -if test ${CPPFLAGS+y} -then : - - case " $CPPFLAGS " in #( - *" -D_ISC "*) : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS already contains -D_ISC"; } >&5 - (: CPPFLAGS already contains -D_ISC) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } ;; #( - *) : - - as_fn_append CPPFLAGS " -D_ISC" - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; -esac - -else $as_nop - - CPPFLAGS=-D_ISC - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS\""; } >&5 - (: CPPFLAGS="$CPPFLAGS") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - -fi - - ac_cv_search_crypt="-lcrypt" - - shadow_funcs="getspnam" - shadow_libs="-lsec" - - : ${mansectsu='1m'} - : ${mansectform='4'} - ;; *-*-sco*|*-sco-*) shadow_funcs="getprpwnam" shadow_libs="-lprot -lx" diff --git a/configure.ac b/configure.ac index d554be2f4..d80d16940 100644 --- a/configure.ac +++ b/configure.ac @@ -2184,24 +2184,6 @@ case "$host" in # lockf() is broken on the Hurd ac_cv_func_lockf=no ;; - *-*-riscos*) - LIBS="${LIBS} -lsun -lbsd" - AX_APPEND_FLAG([-I/usr/include], [CPPFLAGS]) - AX_APPEND_FLAG([-I/usr/include/bsd], [CPPFLAGS]) - AX_APPEND_FLAG([-D_MIPS], [CPPFLAGS]) - : ${mansectsu='1m'} - : ${mansectform='4'} - ;; - *-*-isc*) - AX_APPEND_FLAG([-D_ISC], [CPPFLAGS]) - ac_cv_search_crypt="-lcrypt" - - shadow_funcs="getspnam" - shadow_libs="-lsec" - - : ${mansectsu='1m'} - : ${mansectform='4'} - ;; *-*-sco*|*-sco-*) shadow_funcs="getprpwnam" shadow_libs="-lprot -lx" diff --git a/src/net_ifs.c b/src/net_ifs.c index a6059fc9c..4ece7916f 100644 --- a/src/net_ifs.c +++ b/src/net_ifs.c @@ -57,18 +57,6 @@ struct rtentry; #include #include #include -#ifdef _ISC -# include -# include -# include -# define STRSET(cmd, param, len) {strioctl.ic_cmd=(cmd);\ - strioctl.ic_dp=(param);\ - strioctl.ic_timout=0;\ - strioctl.ic_len=(len);} -#endif /* _ISC */ -#ifdef _MIPS -# include -#endif /* _MIPS */ #include #include #ifdef NEED_RESOLV_H @@ -277,7 +265,7 @@ get_net_ifs(char **addrinfo) lifn.lifn_count = 512; } - /* Allocate space for the interface buffer. */ + /* Allocate and fill in the interface buffer. */ memset(&lifconf, 0, sizeof(lifconf)); lifconf.lifc_len = lifn.lifn_count * sizeof(struct lifreq); lifconf.lifc_buf = malloc(lifconf.lifc_len); @@ -430,18 +418,15 @@ get_net_ifs(char **addrinfo) { long ifr_tmpbuf[1024 / sizeof(long)]; struct ifreq *ifr, *ifr_tmp = (struct ifreq *)ifr_tmpbuf; - struct ifconf *ifconf; + struct ifconf ifconf; struct sockaddr_in *sin; # ifdef HAVE_STRUCT_IN6_ADDR struct sockaddr_in6 *sin6; # endif char addrstr[INET6_ADDRSTRLEN], maskstr[INET6_ADDRSTRLEN]; int i, n, sock, sock4, sock6 = -1, num_interfaces = 0; - size_t ailen, buflen = sizeof(struct ifconf) + BUFSIZ; + size_t ailen; char *cp, *ifconf_buf = NULL; -#ifdef _ISC - struct strioctl strioctl; -#endif /* _ISC */ debug_decl(get_net_ifs, SUDO_DEBUG_NETIF); if (!sudo_conf_probe_interfaces()) @@ -457,48 +442,42 @@ get_net_ifs(char **addrinfo) /* Use INET6 socket with SIOCGIFCONF if possible (may not matter). */ sock = sock6 != -1 ? sock6 : sock4; - /* - * Get interface configuration or return. - */ - for (;;) { - if ((ifconf_buf = malloc(buflen)) == NULL) { - sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, - "unable to allocate memory"); - num_interfaces = -1; - goto done; - } - ifconf = (struct ifconf *)ifconf_buf; - ifconf->ifc_len = buflen - sizeof(struct ifconf); - ifconf->ifc_buf = (caddr_t)(ifconf_buf + sizeof(struct ifconf)); + /* Get the size of the interface buffer (if possible). */ + memset(&ifconf, 0, sizeof(ifconf)); +# if defined(SIOCGSIZIFCONF) + if (ioctl(sock, SIOCGSIZIFCONF, &i) != -1) { + ifconf.ifc_len = i; + } +# elif defined(SIOCGIFNUM) + if (ioctl(sock, SIOCGIFNUM, &i) != -1) { + ifconf.ifc_len = sizeof(struct ifreq) * (i + 4); + } +# endif + if (ifconf.ifc_len = 0) + ifconf.ifc_len = sizeof(struct ifreq) * 512; -#ifdef _ISC - STRSET(SIOCGIFCONF, (caddr_t)ifconf, buflen); - if (ioctl(sock, I_STR, (caddr_t)&strioctl) < 0) -#else - /* Note that some kernels return EINVAL if the buffer is too small */ - if (ioctl(sock, SIOCGIFCONF, ifconf) < 0 && errno != EINVAL) -#endif /* _ISC */ - { - num_interfaces = -1; - goto done; - } - - /* Break out of loop if we have a big enough buffer. */ - if (ifconf->ifc_len + sizeof(struct ifreq) < buflen) - break; - buflen += BUFSIZ; - free(ifconf_buf); + /* Allocate and fill in the interface buffer. */ + ifconf.ifc_buf = malloc(ifconf.ifc_len); + if (ifconf.ifc_buf == NULL) { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, + "unable to allocate memory"); + num_interfaces = -1; + goto done; + } + if (ioctl(sock, SIOCGIFCONF, &ifconf) < 0) { + num_interfaces = -1; + goto done; } /* * Allocate space for the maximum number of interfaces that could exist. * We walk the list for systems with sa_len in struct sockaddr. */ - for (i = 0, n = 0; i < ifconf->ifc_len; n++) { + for (i = 0, n = 0; i < ifconf.ifc_len; n++) { /* Set i to the subscript of the next interface. */ i += sizeof(struct ifreq); #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - ifr = (struct ifreq *)&ifconf->ifc_buf[i]; + ifr = (struct ifreq *)&ifconf.ifc_buf[i]; if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_addr)) i += ifr->ifr_addr.sa_len - sizeof(struct sockaddr); #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ @@ -515,9 +494,9 @@ get_net_ifs(char **addrinfo) *addrinfo = cp; /* For each interface, store the ip address and netmask. */ - for (i = 0; i < ifconf->ifc_len; ) { + for (i = 0; i < ifconf.ifc_len; ) { /* Get a pointer to the current interface. */ - ifr = (struct ifreq *)&ifconf->ifc_buf[i]; + ifr = (struct ifreq *)&ifconf.ifc_buf[i]; /* Set i to the subscript of the next interface. */ i += sizeof(struct ifreq); @@ -579,12 +558,7 @@ get_net_ifs(char **addrinfo) /* Fetch and store the netmask. */ memset(ifr_tmp, 0, sizeof(*ifr_tmp)); memcpy(ifr_tmp->ifr_name, ifr->ifr_name, sizeof(ifr_tmp->ifr_name)); -#ifdef _ISC - STRSET(SIOCGIFNETMASK, (caddr_t)ifr_tmp, sizeof(*ifr_tmp)); - if (ioctl(sock, I_STR, &strioctl) < 0) -#else if (ioctl(sock, SIOCGIFNETMASK, ifr_tmp) < 0) -#endif /* _ISC */ continue; /* Convert the mask to string form. */