2 * Copyright (c) 2019 Apple Inc. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "xpc_services.h"
18 #include <xpc/private.h> // xpc_connection_copy_entitlement_value
20 #include "mDNSMacOSX.h" // KQueueLock/KQueueUnlock
21 #include "dnsproxy.h" // DNSProxyInit/ProxyUDPCallback/ProxyTCPCallback
22 #include "xpc_service_dns_proxy.h" // init_dnsproxy_service
23 #include "xpc_service_log_utility.h" // init_dnsctl_service
25 extern mDNS mDNSStorage
;
27 mDNSexport
void xpc_server_init()
29 // add XPC Services here
30 init_dnsproxy_service();
31 init_log_utility_service();
36 mDNSexport mDNSBool
IsEntitled(xpc_connection_t conn
, const char *entitlement_name
)
38 mDNSBool entitled
= mDNSfalse
;
39 xpc_object_t entitled_obj
= xpc_connection_copy_entitlement_value(conn
, entitlement_name
);
42 if (xpc_get_type(entitled_obj
) == XPC_TYPE_BOOL
&& xpc_bool_get_value(entitled_obj
)) {
45 xpc_release(entitled_obj
);
47 LogRedact(MDNS_LOG_CATEGORY_DEFAULT
, MDNS_LOG_DEFAULT
, "IsEntitled: Client Entitlement is NULL");
51 LogRedact(MDNS_LOG_CATEGORY_DEFAULT
, MDNS_LOG_DEFAULT
, "IsEntitled: Client is missing Entitlement!");