1 From da7d7951c3b4f11485accf54e8e925c04709ed78 Mon Sep 17 00:00:00 2001
2 From: Natanael Copa <ncopa@alpinelinux.org>
3 Date: Wed, 18 Nov 2015 10:05:07 +0000
4 Subject: [PATCH] Use configure to test for feature instead of platform
6 Test for various functions instead of trying to keep track of what
7 platform and what version of the given platform has support for what.
9 This should make it easier to port to currently unknown platforms and
10 will solve the issue if a platform add support for a missing feature in
13 The features we test for are:
19 This is needed for musl libc.
21 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
24 lib/misc/idLinux.c | 30 +++++++++++-------------
25 lib/nicInfo/nicInfoPosix.c | 11 +++++----
26 3 files changed, 24 insertions(+), 21 deletions(-)
30 @@ -1179,6 +1179,7 @@ AC_CHECK_FUNCS(
32 AC_CHECK_FUNCS([ecvt])
33 AC_CHECK_FUNCS([fcvt])
34 +AC_CHECK_FUNCS([getifaddrs getauxval issetugid __secure_getenv])
36 AC_CHECK_FUNC([mkdtemp], [have_mkdtemp=yes])
38 @@ -1388,10 +1389,13 @@ fi
41 AC_CHECK_HEADERS([crypt.h])
42 +AC_CHECK_HEADERS([ifaddrs.h])
43 AC_CHECK_HEADERS([inttypes.h])
44 AC_CHECK_HEADERS([stdint.h])
45 AC_CHECK_HEADERS([stdlib.h])
46 AC_CHECK_HEADERS([wchar.h])
47 +AC_CHECK_HEADERS([net/if.h])
48 +AC_CHECK_HEADERS([sys/auxv.h])
49 AC_CHECK_HEADERS([sys/inttypes.h])
50 AC_CHECK_HEADERS([sys/io.h])
51 AC_CHECK_HEADERS([sys/param.h]) # Required to make the sys/user.h check work correctly on FreeBSD
52 --- a/lib/misc/idLinux.c
53 +++ b/lib/misc/idLinux.c
55 #include <sys/syscall.h>
59 -#if defined(__GLIBC__) && \
60 - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
61 +#ifdef HAVE_SYS_AUXV_H
66 #include <sys/socket.h>
67 #include <TargetConditionals.h>
68 @@ -1025,24 +1022,23 @@ Id_EndSuperUser(uid_t uid) // IN:
72 -#if defined(__ANDROID__)
73 - /* Android does not have a secure_getenv, so be conservative. */
77 * We use __secure_getenv, which returns NULL if the binary is
78 - * setuid or setgid. Alternatives include,
79 + * setuid or setgid, when issetugid or getauxval(AT_SECURE) is not
80 + * available. Alternatives included
82 - * a) getauxval(AT_SECURE); not available until glibc 2.16.
83 - * b) __libc_enable_secure; may not be exported.
84 + * a) issetugid(); not (yet?) available in glibc.
85 + * b) getauxval(AT_SECURE); not available until glibc 2.16.
86 + * c) c) __libc_enable_secure; may not be exported.
88 - * Use (a) when we are based on glibc 2.16, or newer.
89 + * Use (b) when we are based on glibc 2.16, or newer.
92 -#if defined(__GLIBC__) && \
93 - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
97 return getauxval(AT_SECURE) != 0;
99 +#elif HAVE___SECURE_GETENV
100 static const char envName[] = "VMW_SETUGID_TEST";
103 @@ -1062,7 +1058,9 @@ IdIsSetUGid(void)
104 return secure_getenv(envName) == NULL;
109 + /* Android does not have a secure_getenv, so be conservative. */
114 --- a/lib/nicInfo/nicInfoPosix.c
115 +++ b/lib/nicInfo/nicInfoPosix.c
117 #include <sys/stat.h>
120 -#if defined(__FreeBSD__) || defined(__APPLE__)
121 +#if HAVE_SYS_SYSCTL_H
122 # include <sys/sysctl.h>
125 # include <ifaddrs.h>
131 @@ -499,10 +503,7 @@ GuestInfoGetNicInfo(unsigned int maxIPv4
133 ******************************************************************************
135 -#if defined(__FreeBSD__) || \
136 - defined(__APPLE__) || \
137 - defined(USERWORLD) || \
138 - (defined(__linux__) && defined(NO_DNET))
139 +#if defined(NO_DNET) && defined(HAVE_GETIFADDRS)
142 GuestInfoGetPrimaryIP(void)