summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/libdns_sd/README3
-rw-r--r--usr/src/lib/libdns_sd/common/dns_sd.h47
-rw-r--r--usr/src/lib/libdns_sd/common/dnssd_clientlib.c4
-rw-r--r--usr/src/lib/libdns_sd/common/dnssd_clientstub.c114
-rw-r--r--usr/src/lib/libdns_sd/common/dnssd_ipc.c4
-rw-r--r--usr/src/lib/libdns_sd/common/dnssd_ipc.h6
6 files changed, 77 insertions, 101 deletions
diff --git a/usr/src/lib/libdns_sd/README b/usr/src/lib/libdns_sd/README
index 81491ffd91..9bae6c7404 100644
--- a/usr/src/lib/libdns_sd/README
+++ b/usr/src/lib/libdns_sd/README
@@ -21,8 +21,7 @@
#
# CDDL HEADER END
#
-# Copyright 2016 Toomas Soome <tsoome@me.com>
-#
+Updated from upstream version mDNSResponder-625.41.2
Updated from upstream version mDNSResponder-576.30.4
Multicast DNS and Service Discovery support in Solaris using the
diff --git a/usr/src/lib/libdns_sd/common/dns_sd.h b/usr/src/lib/libdns_sd/common/dns_sd.h
index 3831527313..cf32ea1eda 100644
--- a/usr/src/lib/libdns_sd/common/dns_sd.h
+++ b/usr/src/lib/libdns_sd/common/dns_sd.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2003-2013 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
@@ -66,7 +66,7 @@
*/
#ifndef _DNS_SD_H
-#define _DNS_SD_H 5763004
+#define _DNS_SD_H 6254102
#ifdef __cplusplus
extern "C" {
@@ -497,12 +497,18 @@ enum
* as the "serviceIndex".
*/
- kDNSServiceFlagsDenyExpensive = 0x20000000
+ kDNSServiceFlagsDenyExpensive = 0x20000000,
/*
* This flag is meaningful only for Unicast DNS queries. When set, the kernel will restrict
* DNS resolutions on interfaces defined as expensive for that request.
*/
+ kDNSServiceFlagsPathEvaluationDone = 0x40000000
+ /*
+ * This flag is meaningful for only Unicast DNS queries.
+ * When set, it indicates that Network PathEvaluation has already been performed.
+ */
+
};
#define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault)
@@ -724,9 +730,8 @@ enum
* DNS server." Normally, most clients will use 0 for interface index to
* automatically get the default sensible behaviour.
*
- * If the client passes a positive interface index, then for multicast names that
- * indicates to do the operation only on that one interface. For unicast names the
- * interface index is ignored unless kDNSServiceFlagsForceMulticast is also set.
+ * If the client passes a positive interface index, then that indicates to do the
+ * operation only on that one specified interface.
*
* If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
* a service, then that service will be found *only* by other local clients
@@ -2606,34 +2611,6 @@ DNSServiceErrorType DNSSD_API DNSServiceSleepKeepalive
);
#endif
-#ifdef APPLE_OSX_mDNSResponder
-/* DNSServiceCreateDelegateConnection()
- *
- * Create a delegate connection to the daemon allowing efficient registration of
- * multiple individual records.
- *
- * Parameters:
- *
- * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
- * the reference (via DNSServiceRefDeallocate()) severs the
- * connection and deregisters all records registered on this connection.
- *
- * pid : Process ID of the delegate
- *
- * uuid: UUID of the delegate
- *
- * Note that only one of the two arguments (pid or uuid) can be specified. If pid
- * is zero, uuid will be assumed to be a valid value; otherwise pid will be used.
- *
- * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
- * an error code indicating the specific failure that occurred (in which
- * case the DNSServiceRef is not initialized). kDNSServiceErr_NotAuth is
- * returned to indicate that the calling process does not have entitlements
- * to use this API.
- */
-DNSServiceErrorType DNSSD_API DNSServiceCreateDelegateConnection(DNSServiceRef *sdRef, int32_t pid, uuid_t uuid);
-#endif
-
#ifdef __APPLE_API_PRIVATE
#define kDNSServiceCompPrivateDNS "PrivateDNS"
diff --git a/usr/src/lib/libdns_sd/common/dnssd_clientlib.c b/usr/src/lib/libdns_sd/common/dnssd_clientlib.c
index c22e54db61..649d403f02 100644
--- a/usr/src/lib/libdns_sd/common/dnssd_clientlib.c
+++ b/usr/src/lib/libdns_sd/common/dnssd_clientlib.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004-2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
diff --git a/usr/src/lib/libdns_sd/common/dnssd_clientstub.c b/usr/src/lib/libdns_sd/common/dnssd_clientstub.c
index 6c44dae48d..b0fd9f9983 100644
--- a/usr/src/lib/libdns_sd/common/dnssd_clientstub.c
+++ b/usr/src/lib/libdns_sd/common/dnssd_clientstub.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
@@ -30,14 +30,15 @@
#include <stdlib.h>
#include <fcntl.h>
+#include "dnssd_ipc.h"
+
#if APPLE_OSX_mDNSResponder
#include <mach-o/dyld.h>
#include <uuid/uuid.h>
#include <TargetConditionals.h>
+#include "dns_sd_private.h"
#endif
-#include "dnssd_ipc.h"
-
#if defined(_WIN32)
#define _SSIZE_T
@@ -75,7 +76,7 @@ static void syslog( int priority, const char * message, ...)
va_start( args, message );
len = _vscprintf( message, args ) + 1;
buffer = malloc( len * sizeof(char) );
- if ( buffer ) { vsprintf( buffer, message, args ); OutputDebugString( buffer ); free( buffer ); }
+ if ( buffer ) { vsnprintf( buffer, len, message, args ); OutputDebugString( buffer ); free( buffer ); }
WSASetLastError( err );
}
#else
@@ -285,7 +286,7 @@ static int more_bytes(dnssd_sock_t sd)
// two ints and not just one.
int nfdbits = sizeof (int) * 8;
int nints = (sd/nfdbits) + 1;
- fs = (fd_set *)calloc(nints, sizeof(int));
+ fs = (fd_set *)calloc(nints, (size_t)sizeof(int));
if (fs == NULL)
{
syslog(LOG_WARNING, "dnssd_clientstub more_bytes: malloc failed");
@@ -356,7 +357,7 @@ static ipc_msg_hdr *create_hdr(uint32_t op, size_t *len, char **data_start, int
struct timeval tv;
if (gettimeofday(&tv, NULL) < 0)
{ syslog(LOG_WARNING, "dnssd_clientstub create_hdr: gettimeofday failed %d %s", dnssd_errno, dnssd_strerror(dnssd_errno)); return NULL; }
- sprintf(ctrl_path, "%s%d-%.3lx-%.6lu", CTL_PATH_PREFIX, (int)getpid(),
+ snprintf(ctrl_path, sizeof(ctrl_path), "%s%d-%.3lx-%.6lu", CTL_PATH_PREFIX, (int)getpid(),
(unsigned long)(tv.tv_sec & 0xFFF), (unsigned long)(tv.tv_usec));
*len += strlen(ctrl_path) + 1;
#else
@@ -406,7 +407,11 @@ static void FreeDNSServiceOp(DNSServiceOp *x)
// We don't use our DNSServiceRefValid macro here because if we're cleaning up after a socket() call failed
// then sockfd could legitimately contain a failing value (e.g. dnssd_InvalidSocket)
if ((x->sockfd ^ x->validator) != ValidatorBits)
+ {
+ static DNSServiceOp *op_were_not_going_to_free_but_we_need_to_fool_the_analyzer;
syslog(LOG_WARNING, "dnssd_clientstub attempt to dispose invalid DNSServiceRef %p %08X %08X", x, x->sockfd, x->validator);
+ op_were_not_going_to_free_but_we_need_to_fool_the_analyzer = x;
+ }
else
{
x->next = NULL;
@@ -531,6 +536,11 @@ static DNSServiceErrorType ConnectToServer(DNSServiceRef *ref, DNSServiceFlags f
char* uds_serverpath = getenv(MDNS_UDS_SERVERPATH_ENVVAR);
if (uds_serverpath == NULL)
uds_serverpath = MDNS_UDS_SERVERPATH;
+ else if (strlen(uds_serverpath) >= MAX_CTLPATH)
+ {
+ uds_serverpath = MDNS_UDS_SERVERPATH;
+ syslog(LOG_WARNING, "dnssd_clientstub ConnectToServer: using default path since env len is invalid");
+ }
#endif
*ref = NULL;
sdr->sockfd = socket(AF_DNSSD, SOCK_STREAM, 0);
@@ -579,8 +589,10 @@ static DNSServiceErrorType ConnectToServer(DNSServiceRef *ref, DNSServiceFlags f
}
else
{
+ #if !defined(USE_TCP_LOOPBACK)
syslog(LOG_WARNING, "dnssd_clientstub ConnectToServer: connect() failed path:%s Socket:%d Err:%d Errno:%d %s",
uds_serverpath, sdr->sockfd, err, dnssd_errno, dnssd_strerror(dnssd_errno));
+ #endif
dnssd_close(sdr->sockfd);
FreeDNSServiceOp(sdr);
return kDNSServiceErr_ServiceNotRunning;
@@ -598,21 +610,25 @@ static DNSServiceErrorType ConnectToServer(DNSServiceRef *ref, DNSServiceFlags f
static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
{
+ if (!hdr)
+ {
+ syslog(LOG_WARNING, "dnssd_clientstub deliver_request: !hdr");
+ return kDNSServiceErr_Unknown;
+ }
+
uint32_t datalen = hdr->datalen; // We take a copy here because we're going to convert hdr->datalen to network byte order
#if defined(USE_TCP_LOOPBACK) || defined(USE_NAMED_ERROR_RETURN_SOCKET)
char *const data = (char *)hdr + sizeof(ipc_msg_hdr);
#endif
dnssd_sock_t listenfd = dnssd_InvalidSocket, errsd = dnssd_InvalidSocket;
DNSServiceErrorType err = kDNSServiceErr_Unknown; // Default for the "goto cleanup" cases
- int MakeSeparateReturnSocket = 0;
// Note: need to check hdr->op, not sdr->op.
// hdr->op contains the code for the specific operation we're currently doing, whereas sdr->op
// contains the original parent DNSServiceOp (e.g. for an add_record_request, hdr->op will be
// add_record_request but the parent sdr->op will be connection_request or reg_service_request)
- if (sdr->primary ||
- hdr->op == reg_record_request || hdr->op == add_record_request || hdr->op == update_record_request || hdr->op == remove_record_request)
- MakeSeparateReturnSocket = 1;
+ const int MakeSeparateReturnSocket = (sdr->primary ||
+ hdr->op == reg_record_request || hdr->op == add_record_request || hdr->op == update_record_request || hdr->op == remove_record_request);
if (!DNSServiceRefValid(sdr))
{
@@ -622,12 +638,6 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
return kDNSServiceErr_BadReference;
}
- if (!hdr)
- {
- syslog(LOG_WARNING, "dnssd_clientstub deliver_request: !hdr");
- return kDNSServiceErr_Unknown;
- }
-
if (MakeSeparateReturnSocket)
{
#if defined(USE_TCP_LOOPBACK)
@@ -637,21 +647,21 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
dnssd_socklen_t len = (dnssd_socklen_t) sizeof(caddr);
listenfd = socket(AF_DNSSD, SOCK_STREAM, 0);
if (!dnssd_SocketValid(listenfd)) {
- deliver_request_bailout("TCP socket");
- }
+ deliver_request_bailout("TCP socket");
+ }
caddr.sin_family = AF_INET;
caddr.sin_port = 0;
caddr.sin_addr.s_addr = inet_addr(MDNS_TCP_SERVERADDR);
if (bind(listenfd, (struct sockaddr*) &caddr, sizeof(caddr)) < 0) {
- deliver_request_bailout("TCP bind");
- }
- if (getsockname(listenfd, (struct sockaddr*) &caddr, &len) < 0) {
- deliver_request_bailout("TCP getsockname");
- }
- if (listen(listenfd, 1) < 0) {
- deliver_request_bailout("TCP listen");
- }
+ deliver_request_bailout("TCP bind");
+ }
+ if (getsockname(listenfd, (struct sockaddr*) &caddr, &len) < 0) {
+ deliver_request_bailout("TCP getsockname");
+ }
+ if (listen(listenfd, 1) < 0) {
+ deliver_request_bailout("TCP listen");
+ }
port.s = caddr.sin_port;
data[0] = port.b[0]; // don't switch the byte order, as the
data[1] = port.b[1]; // daemon expects it in network byte order
@@ -663,8 +673,8 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
dnssd_sockaddr_t caddr;
listenfd = socket(AF_DNSSD, SOCK_STREAM, 0);
if (!dnssd_SocketValid(listenfd)) {
- deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET socket");
- }
+ deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET socket");
+ }
caddr.sun_family = AF_LOCAL;
// According to Stevens (section 3.2), there is no portable way to
@@ -676,19 +686,19 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
mask = umask(0);
bindresult = bind(listenfd, (struct sockaddr *)&caddr, sizeof(caddr));
umask(mask);
- if (bindresult < 0) {
- deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET bind");
- }
+ if (bindresult < 0) {
+ deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET bind");
+ }
if (listen(listenfd, 1) < 0) {
- deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET listen");
- }
+ deliver_request_bailout("USE_NAMED_ERROR_RETURN_SOCKET listen");
+ }
}
#else
{
dnssd_sock_t sp[2];
if (socketpair(AF_DNSSD, SOCK_STREAM, 0, sp) < 0) {
- deliver_request_bailout("socketpair");
- }
+ deliver_request_bailout("socketpair");
+ }
else
{
errsd = sp[0]; // We'll read our four-byte error code from sp[0]
@@ -756,7 +766,7 @@ static DNSServiceErrorType deliver_request(ipc_msg_hdr *hdr, DNSServiceOp *sdr)
errsd = accept(listenfd, (struct sockaddr *)&daddr, &len);
if (!dnssd_SocketValid(errsd)) {
deliver_request_bailout("accept");
- }
+ }
#else
struct iovec vec = { ((char *)hdr) + sizeof(ipc_msg_hdr) + datalen, 1 }; // Send the last byte along with the SCM_RIGHTS
@@ -1176,6 +1186,8 @@ DNSServiceErrorType DNSSD_API DNSServiceGetProperty(const char *property, void *
put_string(property, &ptr);
err = deliver_request(hdr, tmp); // Will free hdr for us
+ if (err) { DNSServiceRefDeallocate(tmp); return err; }
+
if (read_all(tmp->sockfd, (char*)&actualsize, (int)sizeof(actualsize)) < 0)
{ DNSServiceRefDeallocate(tmp); return kDNSServiceErr_ServiceNotRunning; }
@@ -1200,24 +1212,17 @@ DNSServiceErrorType DNSSD_API DNSServiceGetPID(const uint16_t srcport, int32_t *
size_t len = sizeof(int32_t);
DNSServiceErrorType err = ConnectToServer(&tmp, 0, getpid_request, NULL, NULL, NULL);
- if (err)
- return err;
+ if (err) return err;
hdr = create_hdr(getpid_request, &len, &ptr, 0, tmp);
- if (!hdr)
- {
- DNSServiceRefDeallocate(tmp);
- return kDNSServiceErr_NoMemory;
- }
+ if (!hdr) { DNSServiceRefDeallocate(tmp); return kDNSServiceErr_NoMemory; }
put_uint16(srcport, &ptr);
err = deliver_request(hdr, tmp); // Will free hdr for us
+ if (err) { DNSServiceRefDeallocate(tmp); return err; }
if (read_all(tmp->sockfd, (char*)pid, sizeof(int32_t)) < 0)
- {
- DNSServiceRefDeallocate(tmp);
- return kDNSServiceErr_ServiceNotRunning;
- }
+ { DNSServiceRefDeallocate(tmp); return kDNSServiceErr_ServiceNotRunning; }
DNSServiceRefDeallocate(tmp);
return kDNSServiceErr_NoError;
@@ -1399,16 +1404,17 @@ DNSServiceErrorType DNSSD_API DNSServiceQueryRecord
static void handle_addrinfo_response(DNSServiceOp *const sdr, const CallbackHeader *const cbh, const char *data, const char *const end)
{
char hostname[kDNSServiceMaxDomainName];
- uint16_t rrtype, rdlen;
+ uint16_t rrtype, rrclass, rdlen;
const char *rdata;
uint32_t ttl;
get_string(&data, end, hostname, kDNSServiceMaxDomainName);
rrtype = get_uint16(&data, end);
- (void) get_uint16(&data, end); /* class is not used */
+ rrclass = get_uint16(&data, end);
rdlen = get_uint16(&data, end);
rdata = get_rdata (&data, end, rdlen);
ttl = get_uint32(&data, end);
+ (void)rrclass; // Unused
// We only generate client callbacks for A and AAAA results (including NXDOMAIN results for
// those types, if the client has requested those with the kDNSServiceFlagsReturnIntermediates).
@@ -1631,13 +1637,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister
hdr = create_hdr(reg_service_request, &len, &ptr, (*sdRef)->primary ? 1 : 0, *sdRef);
if (!hdr) { DNSServiceRefDeallocate(*sdRef); *sdRef = NULL; return kDNSServiceErr_NoMemory; }
-
- // If it is going over a shared connection, then don't set the IPC_FLAGS_NOREPLY
- // as it affects all the operations over the shared connection. This is not
- // a normal case and hence receiving the response back from the daemon and
- // discarding it in ConnectionResponse is okay.
-
- if (!(flags & kDNSServiceFlagsShareConnection) && !callBack) hdr->ipc_flags |= IPC_FLAGS_NOREPLY;
+ if (!callBack) hdr->ipc_flags |= IPC_FLAGS_NOREPLY;
put_flags(flags, &ptr);
put_uint32(interfaceIndex, &ptr);
diff --git a/usr/src/lib/libdns_sd/common/dnssd_ipc.c b/usr/src/lib/libdns_sd/common/dnssd_ipc.c
index 6059eb392c..0fd75824f5 100644
--- a/usr/src/lib/libdns_sd/common/dnssd_ipc.c
+++ b/usr/src/lib/libdns_sd/common/dnssd_ipc.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
diff --git a/usr/src/lib/libdns_sd/common/dnssd_ipc.h b/usr/src/lib/libdns_sd/common/dnssd_ipc.h
index ec098032b4..b9c0b144d3 100644
--- a/usr/src/lib/libdns_sd/common/dnssd_ipc.h
+++ b/usr/src/lib/libdns_sd/common/dnssd_ipc.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
@@ -88,7 +88,7 @@ extern char *win32_strerror(int inErrorCode);
# define MDNS_UDS_SERVERPATH_ENVVAR "DNSSD_UDS_PATH"
# define LISTENQ 100
// longest legal control path length
-# define MAX_CTLPATH 256
+# define MAX_CTLPATH (sizeof(((struct sockaddr_un*)0)->sun_path))
# define dnssd_sockaddr_t struct sockaddr_un
#endif