Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | Fix various issues which cause problems under musl. |
| 2 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 3 | Upstream-Status: Backport [bd1326ba7d68df38c5ccaafd2403a5fb30bd452b] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 4 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
| 5 | |
| 6 | From 630516bcc0233b047f65665c003201ba6e77453d Mon Sep 17 00:00:00 2001 |
| 7 | From: Ross Burton <ross.burton@intel.com> |
| 8 | Date: Tue, 9 Aug 2016 16:22:36 +0100 |
| 9 | Subject: [PATCH 1/3] Use AC_USE_SYSTEM_EXTENSIONS |
| 10 | |
| 11 | Instead of using #define _GNU_SOURCE in some source files which causes problems |
| 12 | when building with musl as more files need the define, simply use |
| 13 | AC_USE_SYSTEM_EXTENSIONS in configure.ac to get it defined globally. |
| 14 | --- |
| 15 | configure.ac | 1 + |
| 16 | gdhcp/client.c | 1 - |
| 17 | plugins/tist.c | 1 - |
| 18 | src/backtrace.c | 1 - |
| 19 | src/inet.c | 1 - |
| 20 | src/log.c | 1 - |
| 21 | src/ntp.c | 1 - |
| 22 | src/resolver.c | 1 - |
| 23 | src/rfkill.c | 1 - |
| 24 | src/stats.c | 1 - |
| 25 | src/timezone.c | 1 - |
| 26 | tools/stats-tool.c | 1 - |
| 27 | tools/tap-test.c | 1 - |
| 28 | tools/wispr.c | 1 - |
| 29 | vpn/plugins/vpn.c | 1 - |
| 30 | 15 files changed, 1 insertion(+), 14 deletions(-) |
| 31 | |
| 32 | diff --git a/configure.ac b/configure.ac |
| 33 | index 6e66ab3..bacf5ec 100644 |
| 34 | --- a/configure.ac |
| 35 | +++ b/configure.ac |
| 36 | @@ -20,6 +20,7 @@ AC_SUBST(abs_top_srcdir) |
| 37 | AC_SUBST(abs_top_builddir) |
| 38 | |
| 39 | AC_LANG_C |
| 40 | +AC_USE_SYSTEM_EXTENSIONS |
| 41 | |
| 42 | AC_PROG_CC |
| 43 | AM_PROG_CC_C_O |
| 44 | diff --git a/gdhcp/client.c b/gdhcp/client.c |
| 45 | index fbb40ab..3aeb089 100644 |
| 46 | --- a/gdhcp/client.c |
| 47 | +++ b/gdhcp/client.c |
| 48 | @@ -23,7 +23,6 @@ |
| 49 | #include <config.h> |
| 50 | #endif |
| 51 | |
| 52 | -#define _GNU_SOURCE |
| 53 | #include <stdio.h> |
| 54 | #include <errno.h> |
| 55 | #include <unistd.h> |
| 56 | diff --git a/plugins/tist.c b/plugins/tist.c |
| 57 | index ad5ef79..cc2800a 100644 |
| 58 | --- a/plugins/tist.c |
| 59 | +++ b/plugins/tist.c |
| 60 | @@ -23,7 +23,6 @@ |
| 61 | #include <config.h> |
| 62 | #endif |
| 63 | |
| 64 | -#define _GNU_SOURCE |
| 65 | #include <stdio.h> |
| 66 | #include <stdbool.h> |
| 67 | #include <stdlib.h> |
| 68 | diff --git a/src/backtrace.c b/src/backtrace.c |
| 69 | index 6a66c0a..4dbdda8 100644 |
| 70 | --- a/src/backtrace.c |
| 71 | +++ b/src/backtrace.c |
| 72 | @@ -24,7 +24,6 @@ |
| 73 | #include <config.h> |
| 74 | #endif |
| 75 | |
| 76 | -#define _GNU_SOURCE |
| 77 | #include <stdio.h> |
| 78 | #include <unistd.h> |
| 79 | #include <stdlib.h> |
| 80 | diff --git a/src/inet.c b/src/inet.c |
| 81 | index 69ded19..81d92c2 100644 |
| 82 | --- a/src/inet.c |
| 83 | +++ b/src/inet.c |
| 84 | @@ -25,7 +25,6 @@ |
| 85 | #include <config.h> |
| 86 | #endif |
| 87 | |
| 88 | -#define _GNU_SOURCE |
| 89 | #include <stdio.h> |
| 90 | #include <errno.h> |
| 91 | #include <unistd.h> |
| 92 | diff --git a/src/log.c b/src/log.c |
| 93 | index 9bae4a3..f7e82e5 100644 |
| 94 | --- a/src/log.c |
| 95 | +++ b/src/log.c |
| 96 | @@ -23,7 +23,6 @@ |
| 97 | #include <config.h> |
| 98 | #endif |
| 99 | |
| 100 | -#define _GNU_SOURCE |
| 101 | #include <stdio.h> |
| 102 | #include <unistd.h> |
| 103 | #include <stdarg.h> |
| 104 | diff --git a/src/ntp.c b/src/ntp.c |
| 105 | index dd246eb..db8ae96 100644 |
| 106 | --- a/src/ntp.c |
| 107 | +++ b/src/ntp.c |
| 108 | @@ -23,7 +23,6 @@ |
| 109 | #include <config.h> |
| 110 | #endif |
| 111 | |
| 112 | -#define _GNU_SOURCE |
| 113 | #include <errno.h> |
| 114 | #include <fcntl.h> |
| 115 | #include <unistd.h> |
| 116 | diff --git a/src/resolver.c b/src/resolver.c |
| 117 | index fbe4be7..ef61f92 100644 |
| 118 | --- a/src/resolver.c |
| 119 | +++ b/src/resolver.c |
| 120 | @@ -23,7 +23,6 @@ |
| 121 | #include <config.h> |
| 122 | #endif |
| 123 | |
| 124 | -#define _GNU_SOURCE |
| 125 | #include <stdio.h> |
| 126 | #include <errno.h> |
| 127 | #include <fcntl.h> |
| 128 | diff --git a/src/rfkill.c b/src/rfkill.c |
| 129 | index 2bfb092..af49d12 100644 |
| 130 | --- a/src/rfkill.c |
| 131 | +++ b/src/rfkill.c |
| 132 | @@ -23,7 +23,6 @@ |
| 133 | #include <config.h> |
| 134 | #endif |
| 135 | |
| 136 | -#define _GNU_SOURCE |
| 137 | #include <stdio.h> |
| 138 | #include <errno.h> |
| 139 | #include <fcntl.h> |
| 140 | diff --git a/src/stats.c b/src/stats.c |
| 141 | index 26343b1..cfcdc94 100644 |
| 142 | --- a/src/stats.c |
| 143 | +++ b/src/stats.c |
| 144 | @@ -23,7 +23,6 @@ |
| 145 | #include <config.h> |
| 146 | #endif |
| 147 | |
| 148 | -#define _GNU_SOURCE |
| 149 | #include <errno.h> |
| 150 | #include <sys/mman.h> |
| 151 | #include <sys/types.h> |
| 152 | diff --git a/src/timezone.c b/src/timezone.c |
| 153 | index e346b11..8e91267 100644 |
| 154 | --- a/src/timezone.c |
| 155 | +++ b/src/timezone.c |
| 156 | @@ -23,7 +23,6 @@ |
| 157 | #include <config.h> |
| 158 | #endif |
| 159 | |
| 160 | -#define _GNU_SOURCE |
| 161 | #include <errno.h> |
| 162 | #include <stdio.h> |
| 163 | #include <fcntl.h> |
| 164 | diff --git a/tools/stats-tool.c b/tools/stats-tool.c |
| 165 | index b076478..428d94b 100644 |
| 166 | --- a/tools/stats-tool.c |
| 167 | +++ b/tools/stats-tool.c |
| 168 | @@ -22,7 +22,6 @@ |
| 169 | #include <config.h> |
| 170 | #endif |
| 171 | |
| 172 | -#define _GNU_SOURCE |
| 173 | #include <sys/mman.h> |
| 174 | #include <sys/types.h> |
| 175 | #include <sys/stat.h> |
| 176 | diff --git a/tools/tap-test.c b/tools/tap-test.c |
| 177 | index fdc098a..57917f5 100644 |
| 178 | --- a/tools/tap-test.c |
| 179 | +++ b/tools/tap-test.c |
| 180 | @@ -23,7 +23,6 @@ |
| 181 | #include <config.h> |
| 182 | #endif |
| 183 | |
| 184 | -#define _GNU_SOURCE |
| 185 | #include <stdio.h> |
| 186 | #include <errno.h> |
| 187 | #include <fcntl.h> |
| 188 | diff --git a/tools/wispr.c b/tools/wispr.c |
| 189 | index d5f9341..e56dfc1 100644 |
| 190 | --- a/tools/wispr.c |
| 191 | +++ b/tools/wispr.c |
| 192 | @@ -23,7 +23,6 @@ |
| 193 | #include <config.h> |
| 194 | #endif |
| 195 | |
| 196 | -#define _GNU_SOURCE |
| 197 | #include <stdio.h> |
| 198 | #include <fcntl.h> |
| 199 | #include <unistd.h> |
| 200 | diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c |
| 201 | index 9a42385..479c3a7 100644 |
| 202 | --- a/vpn/plugins/vpn.c |
| 203 | +++ b/vpn/plugins/vpn.c |
| 204 | @@ -23,7 +23,6 @@ |
| 205 | #include <config.h> |
| 206 | #endif |
| 207 | |
| 208 | -#define _GNU_SOURCE |
| 209 | #include <string.h> |
| 210 | #include <fcntl.h> |
| 211 | #include <unistd.h> |
| 212 | -- |
| 213 | 2.8.1 |
| 214 | |
| 215 | |
| 216 | From b8b7878e6cb2a1ed4fcfa256f7e232511a40e3d9 Mon Sep 17 00:00:00 2001 |
| 217 | From: Ross Burton <ross.burton@intel.com> |
| 218 | Date: Tue, 9 Aug 2016 15:37:50 +0100 |
| 219 | Subject: [PATCH 2/3] Check for in6_pktinfo.ipi6_addr explicitly |
| 220 | |
| 221 | Instead of assuming that just glibc has this structure, check for it at |
| 222 | configure as musl also has it. |
| 223 | |
| 224 | Based on work by Khem Raj <raj.khem@gmail.com>. |
| 225 | --- |
| 226 | configure.ac | 2 ++ |
| 227 | gdhcp/common.h | 5 +++-- |
| 228 | 2 files changed, 5 insertions(+), 2 deletions(-) |
| 229 | |
| 230 | diff --git a/configure.ac b/configure.ac |
| 231 | index bacf5ec..ad00456 100644 |
| 232 | --- a/configure.ac |
| 233 | +++ b/configure.ac |
| 234 | @@ -186,6 +186,8 @@ AC_CHECK_LIB(resolv, ns_initparse, dummy=yes, [ |
| 235 | AC_CHECK_HEADERS([execinfo.h]) |
| 236 | AM_CONDITIONAL([BACKTRACE], [test "${ac_cv_header_execinfo_h}" = "yes"]) |
| 237 | |
| 238 | +AC_CHECK_MEMBERS([struct in6_pktinfo.ipi6_addr], [], [], [[#include <netinet/in.h>]]) |
| 239 | + |
| 240 | AC_CHECK_FUNC(signalfd, dummy=yes, |
| 241 | AC_MSG_ERROR(signalfd support is required)) |
| 242 | |
| 243 | diff --git a/gdhcp/common.h b/gdhcp/common.h |
| 244 | index 75abc18..6899499 100644 |
| 245 | --- a/gdhcp/common.h |
| 246 | +++ b/gdhcp/common.h |
| 247 | @@ -19,6 +19,7 @@ |
| 248 | * |
| 249 | */ |
| 250 | |
| 251 | +#include <config.h> |
| 252 | #include <netinet/udp.h> |
| 253 | #include <netinet/ip.h> |
| 254 | |
| 255 | @@ -170,8 +171,8 @@ static const uint8_t dhcp_option_lengths[] = { |
| 256 | [OPTION_U32] = 4, |
| 257 | }; |
| 258 | |
| 259 | -/* already defined within netinet/in.h if using GNU compiler */ |
| 260 | -#ifndef __USE_GNU |
| 261 | +/* already defined within netinet/in.h if using glibc or musl */ |
| 262 | +#ifndef HAVE_STRUCT_IN6_PKTINFO_IPI6_ADDR |
| 263 | struct in6_pktinfo { |
| 264 | struct in6_addr ipi6_addr; /* src/dst IPv6 address */ |
| 265 | unsigned int ipi6_ifindex; /* send/recv interface index */ |
| 266 | -- |
| 267 | 2.8.1 |
| 268 | |
| 269 | |
| 270 | From c0726e432fa0274a2b9c70179b03df6720972816 Mon Sep 17 00:00:00 2001 |
| 271 | From: Ross Burton <ross.burton@intel.com> |
| 272 | Date: Tue, 9 Aug 2016 15:19:23 +0100 |
| 273 | Subject: [PATCH 3/3] Rationalise includes |
| 274 | |
| 275 | gweb/gresolv.c uses snprintf() and isspace() so it should include stdio.h and |
| 276 | ctype.h. |
| 277 | |
| 278 | tools/dnsproxy-test uses functions from stdio.h. |
| 279 | |
| 280 | musl warns when sys/ headers are included when the non-sys form should be used, |
| 281 | so switch sys/errno.h and so on to errno.h. |
| 282 | |
| 283 | musl also causes redefinition errors when pieces of the networking headers are |
| 284 | included, so remove the redundant includes. |
| 285 | |
| 286 | Based on work by Khem Raj <raj.khem@gmail.com>. |
| 287 | --- |
| 288 | gweb/gresolv.c | 2 ++ |
| 289 | plugins/wifi.c | 3 +-- |
| 290 | src/ippool.c | 1 - |
| 291 | src/iptables.c | 2 +- |
| 292 | src/tethering.c | 2 -- |
| 293 | tools/dhcp-test.c | 1 - |
| 294 | tools/dnsproxy-test.c | 1 + |
| 295 | tools/private-network-test.c | 2 +- |
| 296 | tools/tap-test.c | 2 +- |
| 297 | 9 files changed, 7 insertions(+), 9 deletions(-) |
| 298 | |
| 299 | diff --git a/gweb/gresolv.c b/gweb/gresolv.c |
| 300 | index 8a51a9f..d55027c 100644 |
| 301 | --- a/gweb/gresolv.c |
| 302 | +++ b/gweb/gresolv.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 303 | @@ -29,6 +29,7 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 304 | #include <string.h> |
| 305 | #include <stdlib.h> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 306 | #include <resolv.h> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 307 | +#include <stdio.h> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 308 | #include <sys/types.h> |
| 309 | #include <sys/socket.h> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 310 | #include <netdb.h> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 311 | diff --git a/plugins/wifi.c b/plugins/wifi.c |
| 312 | index 9d56671..148131d 100644 |
| 313 | --- a/plugins/wifi.c |
| 314 | +++ b/plugins/wifi.c |
| 315 | @@ -30,9 +30,8 @@ |
| 316 | #include <string.h> |
| 317 | #include <sys/ioctl.h> |
| 318 | #include <sys/socket.h> |
| 319 | -#include <linux/if_arp.h> |
| 320 | -#include <linux/wireless.h> |
| 321 | #include <net/ethernet.h> |
| 322 | +#include <linux/wireless.h> |
| 323 | |
| 324 | #ifndef IFF_LOWER_UP |
| 325 | #define IFF_LOWER_UP 0x10000 |
| 326 | diff --git a/src/ippool.c b/src/ippool.c |
| 327 | index cea1dcc..8a645da 100644 |
| 328 | --- a/src/ippool.c |
| 329 | +++ b/src/ippool.c |
| 330 | @@ -28,7 +28,6 @@ |
| 331 | #include <stdio.h> |
| 332 | #include <string.h> |
| 333 | #include <unistd.h> |
| 334 | -#include <sys/errno.h> |
| 335 | #include <sys/socket.h> |
| 336 | |
| 337 | #include "connman.h" |
| 338 | diff --git a/src/iptables.c b/src/iptables.c |
| 339 | index 5ef757a..82e3ac4 100644 |
| 340 | --- a/src/iptables.c |
| 341 | +++ b/src/iptables.c |
| 342 | @@ -28,7 +28,7 @@ |
| 343 | #include <stdio.h> |
| 344 | #include <string.h> |
| 345 | #include <unistd.h> |
| 346 | -#include <sys/errno.h> |
| 347 | +#include <errno.h> |
| 348 | #include <sys/socket.h> |
| 349 | #include <xtables.h> |
| 350 | #include <inttypes.h> |
| 351 | diff --git a/src/tethering.c b/src/tethering.c |
| 352 | index 3153349..ad062d5 100644 |
| 353 | --- a/src/tethering.c |
| 354 | +++ b/src/tethering.c |
| 355 | @@ -31,10 +31,8 @@ |
| 356 | #include <stdio.h> |
| 357 | #include <sys/ioctl.h> |
| 358 | #include <net/if.h> |
| 359 | -#include <linux/sockios.h> |
| 360 | #include <string.h> |
| 361 | #include <fcntl.h> |
| 362 | -#include <linux/if_tun.h> |
| 363 | #include <netinet/in.h> |
| 364 | #include <linux/if_bridge.h> |
| 365 | |
| 366 | diff --git a/tools/dhcp-test.c b/tools/dhcp-test.c |
| 367 | index c34e10a..eae66fc 100644 |
| 368 | --- a/tools/dhcp-test.c |
| 369 | +++ b/tools/dhcp-test.c |
| 370 | @@ -33,7 +33,6 @@ |
| 371 | #include <arpa/inet.h> |
| 372 | #include <net/route.h> |
| 373 | #include <net/ethernet.h> |
| 374 | -#include <linux/if_arp.h> |
| 375 | |
| 376 | #include <gdhcp/gdhcp.h> |
| 377 | |
| 378 | diff --git a/tools/dnsproxy-test.c b/tools/dnsproxy-test.c |
| 379 | index 551cae9..371e2e2 100644 |
| 380 | --- a/tools/dnsproxy-test.c |
| 381 | +++ b/tools/dnsproxy-test.c |
| 382 | @@ -24,6 +24,7 @@ |
| 383 | #endif |
| 384 | |
| 385 | #include <errno.h> |
| 386 | +#include <stdio.h> |
| 387 | #include <stdlib.h> |
| 388 | #include <string.h> |
| 389 | #include <unistd.h> |
| 390 | diff --git a/tools/private-network-test.c b/tools/private-network-test.c |
| 391 | index 3dd115b..2828bb3 100644 |
| 392 | --- a/tools/private-network-test.c |
| 393 | +++ b/tools/private-network-test.c |
| 394 | @@ -32,7 +32,7 @@ |
| 395 | #include <stdlib.h> |
| 396 | #include <string.h> |
| 397 | #include <signal.h> |
| 398 | -#include <sys/poll.h> |
| 399 | +#include <poll.h> |
| 400 | #include <sys/signalfd.h> |
| 401 | #include <unistd.h> |
| 402 | |
| 403 | diff --git a/tools/tap-test.c b/tools/tap-test.c |
| 404 | index 57917f5..cb3ee62 100644 |
| 405 | --- a/tools/tap-test.c |
| 406 | +++ b/tools/tap-test.c |
| 407 | @@ -28,7 +28,7 @@ |
| 408 | #include <fcntl.h> |
| 409 | #include <unistd.h> |
| 410 | #include <string.h> |
| 411 | -#include <sys/poll.h> |
| 412 | +#include <poll.h> |
| 413 | #include <sys/ioctl.h> |
| 414 | |
| 415 | #include <netinet/in.h> |
| 416 | -- |
| 417 | 2.8.1 |