MacOS legacy: Attempt to support last MacOS PPC release - 10.6

pull/775/head
Brad House 7 months ago
parent 45ba9bcfd8
commit 23392f5dc6
  1. 13
      src/lib/ares_sysconfig_mac.c
  2. 22
      src/lib/thirdparty/apple/README.md
  3. 30
      src/lib/thirdparty/apple/dnsinfo.h

@ -53,6 +53,7 @@
# include <arpa/inet.h>
# include "thirdparty/apple/dnsinfo.h"
# include <SystemConfiguration/SCNetworkConfiguration.h>
# include <AvailabilityMacros.h>
# include "ares.h"
# include "ares_private.h"
@ -148,6 +149,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
return ARES_SUCCESS;
}
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */
/* Check to see if DNS server should be used, base this on if the server is
* reachable or can be reachable automatically if we send traffic that
* direction. */
@ -156,6 +158,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
kSCNetworkReachabilityFlagsConnectionOnTraffic))) {
return ARES_SUCCESS;
}
#endif
/* NOTE: it doesn't look like resolver->flags is relevant */
@ -219,7 +222,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
* - resolver->timeout appears unused, always 0, so we ignore this
* - resolver->service_identifier doesn't appear relevant to us
* - resolver->cid also isn't relevant
* - resolver->if_index we don't need, if_name is used instead.
* - resolver->if_name we won't use since it isn't available in MacOS 10.8
* or earlier, use resolver->if_index instead to then lookup the name.
*/
/* XXX: resolver->search_order appears like it might be relevant, we might
@ -233,6 +237,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
struct ares_addr addr;
unsigned short addrport;
const struct sockaddr *sockaddr;
char if_name_str[256] = "";
const char *if_name;
/* UBSAN alignment workaround to fetch memory address */
memcpy(&sockaddr, resolver->nameserver + i, sizeof(sockaddr));
@ -262,8 +268,11 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
if (addrport == 0) {
addrport = port;
}
if_name = ares__if_indextoname(resolver->if_index, if_name_str,
sizeof(if_name_str));
status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport,
addrport, resolver->if_name);
addrport, if_name);
if (status != ARES_SUCCESS) {
return status;
}

@ -1,12 +1,18 @@
The `dnsinfo.h` header was extracted from Apple's OpenSource repository:
[https://opensource.apple.com/source/configd/configd-963.50.8/dnsinfo/dnsinfo.h](https://opensource.apple.com/source/configd/configd-963.50.8/dnsinfo/dnsinfo.h)
[https://opensource.apple.com/source/configd/configd-453.19/dnsinfo/dnsinfo.h](https://opensource.apple.com/source/configd/configd-453.19/dnsinfo/dnsinfo.h)
We did make one tweak to this file to put `(void)` as the parameter list for both `dns_configuration_notify_key()`
and `dns_configuration_copy()` to sidestep compiler warnings in this old header.
We then had to make a few edits to this file:
1. Add `AvailabilityMacros.h` header file
2. conditionalize `reach_flags` in `dns_resolver_t` on MacOS 10.8 or higher, in
order to maintain compatibility with the last MacOS PPC release, 10.6.
3. conditionalize `_dns_configuration_ack()` on MacOS 10.8 or higher.
4. Update parameter list to `(void)` for both `dns_configuration_notify_key()`
and `dns_configuration_copy()` to sidestep compiler warnings in this old
header.
NOTE: For legacy MacOS compatibility, we needed to import 963.50.8. We tried with the
latest (at this time) of 1109.140.1, and it caused issues with MacPorts still supporting
MacOS versions 10.8-10.11. There's really not any reason to not support these if it doesn't
take much effort if MacPorts still is.
We had tried initially to use the latest 1109.140.1 which only worked on
MacOS 11+, then downgraded to 963.50.8 for MacOS 10.8+ support, then finally
to 453.19 with additional patches.
This is needed to call into `dns_configuration_copy()` and `dns_configuration_free()`.
This is needed to call into `dns_configuration_copy()` and
`dns_configuration_free()`.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015-2017 Apple Inc. All rights reserved.
* Copyright (c) 2004-2006, 2008, 2009, 2011 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@ -34,8 +34,9 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <AvailabilityMacros.h>
#define DNSINFO_VERSION 20170629
#define DNSINFO_VERSION 20111104
#define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */
@ -72,23 +73,17 @@ typedef struct {
DNS_VAR(uint32_t, search_order); /* search_order */
DNS_VAR(uint32_t, if_index);
DNS_VAR(uint32_t, flags);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 /* MacOS 10.8 */
DNS_VAR(uint32_t, reserved[6]);
#else
DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */
DNS_VAR(uint32_t, service_identifier);
DNS_PTR(char *, cid); /* configuration identifer */
DNS_PTR(char *, if_name); /* if_index interface name */
DNS_VAR(uint32_t, reserved[5]);
#endif
} dns_resolver_t;
#pragma pack()
#define DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS 0x0002 /* always requesting for A dns records in queries */
#define DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS 0x0004 /* always requesting for AAAA dns records in queries */
#define DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS \
(DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS | DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS)
#define DNS_RESOLVER_FLAGS_SCOPED 0x1000 /* configuration is for scoped questions */
#define DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC 0x2000 /* configuration is service-specific */
#define DNS_RESOLVER_FLAGS_SUPPLEMENTAL 0x4000 /* supplemental match configuration */
#define DNS_RESOLVER_FLAGS_SCOPED 1 /* configuration is for scoped questions */
#pragma pack(4)
@ -97,10 +92,7 @@ typedef struct {
DNS_PTR(dns_resolver_t **, resolver);
DNS_VAR(int32_t, n_scoped_resolver); /* "scoped" resolver configurations */
DNS_PTR(dns_resolver_t **, scoped_resolver);
DNS_VAR(uint64_t, generation);
DNS_VAR(int32_t, n_service_specific_resolver);
DNS_PTR(dns_resolver_t **, service_specific_resolver);
DNS_VAR(uint32_t, version);
DNS_VAR(uint32_t, reserved[5]);
} dns_config_t;
#pragma pack()
@ -119,9 +111,11 @@ dns_configuration_copy (void) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2
void
dns_configuration_free (dns_config_t *config) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0);
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
void
_dns_configuration_ack (dns_config_t *config,
const char *bundle_id) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0);
#endif
__END_DECLS

Loading…
Cancel
Save