Merge pull request #20731 from pprindeville/isc-dhcp-update-4.4.3-P1
[feed/packages.git] / utils / open-vm-tools / patches / 0005-Use-configure-to-test-for-feature-instead-of-platfor.patch
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
5
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.
8
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
11 the future.
12
13 The features we test for are:
14 - getifaddrs
15 - getauxval
16 - issetugid
17 - __secure_getenv
18
19 This is needed for musl libc.
20
21 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
22 ---
23 configure.ac | 4 ++++
24 lib/misc/idLinux.c | 30 +++++++++++-------------
25 lib/nicInfo/nicInfoPosix.c | 11 +++++----
26 3 files changed, 24 insertions(+), 21 deletions(-)
27
28 --- a/configure.ac
29 +++ b/configure.ac
30 @@ -1179,6 +1179,7 @@ AC_CHECK_FUNCS(
31
32 AC_CHECK_FUNCS([ecvt])
33 AC_CHECK_FUNCS([fcvt])
34 +AC_CHECK_FUNCS([getifaddrs getauxval issetugid __secure_getenv])
35
36 AC_CHECK_FUNC([mkdtemp], [have_mkdtemp=yes])
37
38 @@ -1388,10 +1389,13 @@ fi
39 ###
40
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
54 @@ -27,12 +27,9 @@
55 #include <sys/syscall.h>
56 #include <string.h>
57 #include <unistd.h>
58 -#ifdef __linux__
59 -#if defined(__GLIBC__) && \
60 - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
61 +#ifdef HAVE_SYS_AUXV_H
62 #include <sys/auxv.h>
63 #endif
64 -#endif
65 #ifdef __APPLE__
66 #include <sys/socket.h>
67 #include <TargetConditionals.h>
68 @@ -1025,24 +1022,23 @@ Id_EndSuperUser(uid_t uid) // IN:
69 static Bool
70 IdIsSetUGid(void)
71 {
72 -#if defined(__ANDROID__)
73 - /* Android does not have a secure_getenv, so be conservative. */
74 - return TRUE;
75 -#else
76 /*
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
81 *
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.
87 *
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.
90 */
91
92 -#if defined(__GLIBC__) && \
93 - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
94 +#if HAVE_ISSETUGID
95 + return issetugid();
96 +#elif HAVE_GETAUXVAL
97 return getauxval(AT_SECURE) != 0;
98 -#else
99 +#elif HAVE___SECURE_GETENV
100 static const char envName[] = "VMW_SETUGID_TEST";
101
102 /*
103 @@ -1062,7 +1058,9 @@ IdIsSetUGid(void)
104 return secure_getenv(envName) == NULL;
105 }
106 return TRUE;
107 -#endif
108 +#else
109 + /* Android does not have a secure_getenv, so be conservative. */
110 + return TRUE;
111 #endif
112 }
113 #endif
114 --- a/lib/nicInfo/nicInfoPosix.c
115 +++ b/lib/nicInfo/nicInfoPosix.c
116 @@ -35,9 +35,13 @@
117 #include <sys/stat.h>
118 #include <errno.h>
119 #include <limits.h>
120 -#if defined(__FreeBSD__) || defined(__APPLE__)
121 +#if HAVE_SYS_SYSCTL_H
122 # include <sys/sysctl.h>
123 +#endif
124 +#if HAVE_IFADDRS_H
125 # include <ifaddrs.h>
126 +#endif
127 +#if HAVE_NET_IF_H
128 # include <net/if.h>
129 #endif
130 #ifndef NO_DNET
131 @@ -499,10 +503,7 @@ GuestInfoGetNicInfo(unsigned int maxIPv4
132 *
133 ******************************************************************************
134 */
135 -#if defined(__FreeBSD__) || \
136 - defined(__APPLE__) || \
137 - defined(USERWORLD) || \
138 - (defined(__linux__) && defined(NO_DNET))
139 +#if defined(NO_DNET) && defined(HAVE_GETIFADDRS)
140
141 char *
142 GuestInfoGetPrimaryIP(void)