]> granicus.if.org Git - sudo/commitdiff
Fix inet_ntop() replacement on older systems without it.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 23 Oct 2014 21:44:03 +0000 (15:44 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 23 Oct 2014 21:44:03 +0000 (15:44 -0600)
We only expose the prototype for net_ifs.c due to the
use of socklen_t.

configure
configure.ac
include/sudo_compat.h
lib/util/inet_ntop.c
src/net_ifs.c

index a50f3d7059e283abb9527a042e1512d5171a6a2a..bcdc35d748bc9af9f2602ebd3335d6775aee71d5 100755 (executable)
--- a/configure
+++ b/configure
@@ -19216,6 +19216,20 @@ $as_echo "no" >&6; }
 fi
 
 LIBS="$OLIBS"
+if test X"$found" != X"true"; then
+    case " $LIBOBJS " in
+  *" inet_ntop.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext"
+ ;;
+esac
+
+
+    for _sym in sudo_inet_ntop; do
+       COMPAT_EXP="${COMPAT_EXP}${_sym}
+"
+    done
+
+fi
 OLIBS="$LIBS"
 LIBS="${LIBS} ${NET_LIBS}"
 found=false
index be976daf3854bda38e40470ff47f92d8d5110596..b660d89e47301c70407ca2d0714588fb4bd14afa 100644 (file)
@@ -2686,6 +2686,10 @@ AC_CHECK_FUNC(inet_ntop, [
     done
 ])
 LIBS="$OLIBS"
+if test X"$found" != X"true"; then
+    AC_LIBOBJ(inet_ntop)
+    SUDO_APPEND_COMPAT_EXP(sudo_inet_ntop)
+fi
 dnl
 dnl If inet_pton(3) not in libc, check -lnsl and -linet
 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
index f374ebde0fc91f3017e2c9091772b8c4b4789e5f..a314dc41aa7e9c80039b2d0233a9760adc35a260 100644 (file)
@@ -19,8 +19,8 @@
  * Materiel Command, USAF, under agreement number F39502-99-1-0512.
  */
 
-#ifndef _SUDO_MISSING_H
-#define _SUDO_MISSING_H
+#ifndef _SUDO_COMPAT_H
+#define _SUDO_COMPAT_H
 
 #include <stdio.h>
 #ifdef STDC_HEADERS
@@ -467,6 +467,11 @@ __dso_public int sudo_clock_gettime(clockid_t clock_id, struct timespec *tp);
 # undef clock_gettime
 # define clock_gettime(_a, _b) sudo_clock_gettime((_a), (_b))
 #endif /* HAVE_CLOCK_GETTIME */
+#if !defined(HAVE_INET_NTOP) && defined(_SUDO_NET_IFS_C)
+__dso_public char *sudo_inet_ntop(int af, const void *src, char *dst, socklen_t size);
+# undef inet_ntop
+# define inet_ntop(_a, _b, _c, _d) sudo_inet_ntop((_a), (_b), (_c), (_d))
+#endif /* HAVE_INET_NTOP */
 #ifndef HAVE_INET_PTON
 __dso_public int sudo_inet_pton(int af, const char *src, void *dst);
 # undef inet_pton
@@ -478,4 +483,4 @@ __dso_public const char *sudo_getprogname(void);
 # define getprogname() sudo_getprogname()
 #endif /* HAVE_GETPROGNAME */
 
-#endif /* _SUDO_MISSING_H */
+#endif /* _SUDO_COMPAT_H */
index 28b6a9eb7b494d42b52df879ad5c558a6cff1b27..ebf87b3c47ea2295de4c9d30c0e9c7e198d77411 100644 (file)
@@ -211,7 +211,7 @@ inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
  *     Paul Vixie, 1996.
  */
 const char *
-inet_ntop(int af, const void *src, char *dst, socklen_t size)
+sudo_inet_ntop(int af, const void *src, char *dst, socklen_t size)
 {
        switch (af) {
        case AF_INET:
index 1cee550c9ab584170c074ce8f70ff510db723fcb..157c9e3d417cf00aa625568d510f6c886edb6704 100644 (file)
@@ -84,6 +84,8 @@ struct rtentry;
 # include <ifaddrs.h>
 #endif
 
+#define _SUDO_NET_IFS_C                /* to expose sudo_inet_ntop in sudo_compat.h */
+
 #define DEFAULT_TEXT_DOMAIN    "sudo"
 #include "sudo_gettext.h"      /* must be included before sudo_compat.h */