diff options
Diffstat (limited to 'mDNSResponder/mDNSMacOSX/Private/xpc_services.c')
-rw-r--r-- | mDNSResponder/mDNSMacOSX/Private/xpc_services.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/mDNSResponder/mDNSMacOSX/Private/xpc_services.c b/mDNSResponder/mDNSMacOSX/Private/xpc_services.c index 7a0e29fb..fb357806 100644 --- a/mDNSResponder/mDNSMacOSX/Private/xpc_services.c +++ b/mDNSResponder/mDNSMacOSX/Private/xpc_services.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 4 -*- * - * Copyright (c) 2012 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015 Apple Inc. All rights reserved. * * xpc_services.c * mDNSResponder @@ -90,7 +90,7 @@ mDNSlocal void handle_dps_request(xpc_object_t req) xpc_object_t reply = xpc_dictionary_create(NULL, NULL, 0); if (reply) { - xpc_dictionary_set_uint64(reply, kDNSDaemonReply, kDNSDaemonEngaged); + xpc_dictionary_set_uint64(reply, kDNSDaemonReply, kDNSMsg_BadArg); xpc_connection_send_message(remote_conn, reply); xpc_release(reply); } @@ -104,12 +104,13 @@ mDNSlocal void handle_dps_request(xpc_object_t req) return; } } - + + + xpc_object_t response = xpc_dictionary_create_reply(req); // Return Success Status to the client - xpc_object_t response = xpc_dictionary_create(NULL, NULL, 0); if (response) { - xpc_dictionary_set_uint64(response, kDNSDaemonReply, kDNSMsgReceived); + xpc_dictionary_set_uint64(response, kDNSDaemonReply, kDNSMsg_NoError); xpc_connection_send_message(remote_conn, response); xpc_release(response); } @@ -155,21 +156,26 @@ mDNSlocal mDNSBool IsEntitled(xpc_connection_t conn, const char *password) LogMsg("IsEntitled: Client Entitlement is NULL"); } + if (!entitled) + LogMsg("IsEntitled: DNSProxyService Client is missing Entitlement!"); + return entitled; } mDNSlocal void accept_dps_client(xpc_connection_t conn) { - uid_t euid; - euid = xpc_connection_get_euid(conn); + uid_t c_euid; + int c_pid; + c_euid = xpc_connection_get_euid(conn); + c_pid = xpc_connection_get_pid(conn); - if (euid != 0 || !IsEntitled(conn, kDNSProxyService)) + if (c_euid != 0 || !IsEntitled(conn, kDNSProxyService)) { - LogMsg("accept_dps_client: DNSProxyService Client Pid[%d] is missing Entitlement or is not root!", (int) xpc_connection_get_pid(conn)); + LogMsg("accept_dps_client: DNSProxyService Client PID[%d] is missing Entitlement or is not running as root!", c_pid); xpc_connection_cancel(conn); return; } - + xpc_retain(conn); xpc_connection_set_target_queue(conn, dps_queue); xpc_connection_set_event_handler(conn, ^(xpc_object_t req_msg) @@ -180,16 +186,16 @@ mDNSlocal void accept_dps_client(xpc_connection_t conn) { handle_dps_request(req_msg); } - // We hit the case below only if Client Terminated DPS Connection OR Crashed - else + else // We hit this case ONLY if Client Terminated DPS Connection OR Crashed { LogInfo("accept_dps_client: DPS Client %p teared down the connection or Crashed", (void *) conn); // Only the Client that has activated DPS should be able to terminate it - if (((int)xpc_connection_get_pid(conn)) == dps_client_pid) + if (c_pid == dps_client_pid) handle_dps_terminate(); xpc_release(conn); } }); + xpc_connection_resume(conn); } @@ -215,8 +221,7 @@ mDNSlocal void init_dnsproxy_service(void) LogInfo("init_dnsproxy_service: New DNSProxyService Client %p", eventmsg); accept_dps_client(eventmsg); } - // Ideally, we would never hit the cases below - else if (type == XPC_TYPE_ERROR) + else if (type == XPC_TYPE_ERROR) // Ideally, we would never hit these cases { LogMsg("init_dnsproxy_service: XPCError: %s", xpc_dictionary_get_string(eventmsg, XPC_ERROR_KEY_DESCRIPTION)); return; @@ -227,6 +232,7 @@ mDNSlocal void init_dnsproxy_service(void) return; } }); + xpc_connection_resume(dps_listener); } |