1*1b191cb5SApple OSS Distributions /*
2*1b191cb5SApple OSS Distributions * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
3*1b191cb5SApple OSS Distributions *
4*1b191cb5SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*1b191cb5SApple OSS Distributions *
6*1b191cb5SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*1b191cb5SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*1b191cb5SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*1b191cb5SApple OSS Distributions * compliance with the License. The rights granted to you under the License
10*1b191cb5SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
11*1b191cb5SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
12*1b191cb5SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
13*1b191cb5SApple OSS Distributions * terms of an Apple operating system software license agreement.
14*1b191cb5SApple OSS Distributions *
15*1b191cb5SApple OSS Distributions * Please obtain a copy of the License at
16*1b191cb5SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*1b191cb5SApple OSS Distributions *
18*1b191cb5SApple OSS Distributions * The Original Code and all software distributed under the License are
19*1b191cb5SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*1b191cb5SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*1b191cb5SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*1b191cb5SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*1b191cb5SApple OSS Distributions * Please see the License for the specific language governing rights and
24*1b191cb5SApple OSS Distributions * limitations under the License.
25*1b191cb5SApple OSS Distributions *
26*1b191cb5SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*1b191cb5SApple OSS Distributions */
28*1b191cb5SApple OSS Distributions
29*1b191cb5SApple OSS Distributions #include <mach/port.h>
30*1b191cb5SApple OSS Distributions #include <mach/message.h>
31*1b191cb5SApple OSS Distributions #include <mach/kern_return.h>
32*1b191cb5SApple OSS Distributions #include <mach/host_priv.h>
33*1b191cb5SApple OSS Distributions
34*1b191cb5SApple OSS Distributions #include <kern/kern_types.h>
35*1b191cb5SApple OSS Distributions #include <kern/kalloc.h>
36*1b191cb5SApple OSS Distributions #include <kern/host.h>
37*1b191cb5SApple OSS Distributions #include <kern/ipc_kobject.h>
38*1b191cb5SApple OSS Distributions
39*1b191cb5SApple OSS Distributions #include <ipc/ipc_port.h>
40*1b191cb5SApple OSS Distributions
41*1b191cb5SApple OSS Distributions #include <UserNotification/UNDTypes.h>
42*1b191cb5SApple OSS Distributions #include <UserNotification/UNDRequest.h>
43*1b191cb5SApple OSS Distributions #include <UserNotification/UNDReplyServer.h>
44*1b191cb5SApple OSS Distributions #include <UserNotification/KUNCUserNotifications.h>
45*1b191cb5SApple OSS Distributions
46*1b191cb5SApple OSS Distributions #ifdef KERNEL_CF
47*1b191cb5SApple OSS Distributions // external
48*1b191cb5SApple OSS Distributions #include <IOKit/IOCFSerialize.h>
49*1b191cb5SApple OSS Distributions #include <IOKit/IOCFUnserialize.h>
50*1b191cb5SApple OSS Distributions #endif
51*1b191cb5SApple OSS Distributions
52*1b191cb5SApple OSS Distributions #if CONFIG_USER_NOTIFICATION
53*1b191cb5SApple OSS Distributions /*
54*1b191cb5SApple OSS Distributions * DEFINES AND STRUCTURES
55*1b191cb5SApple OSS Distributions */
56*1b191cb5SApple OSS Distributions
57*1b191cb5SApple OSS Distributions struct UNDReply {
58*1b191cb5SApple OSS Distributions decl_lck_mtx_data(, lock); /* UNDReply lock */
59*1b191cb5SApple OSS Distributions int userLandNotificationKey;
60*1b191cb5SApple OSS Distributions KUNCUserNotificationCallBack callback;
61*1b191cb5SApple OSS Distributions boolean_t inprogress;
62*1b191cb5SApple OSS Distributions ipc_port_t self_port; /* Our port */
63*1b191cb5SApple OSS Distributions };
64*1b191cb5SApple OSS Distributions
65*1b191cb5SApple OSS Distributions static void
66*1b191cb5SApple OSS Distributions UNDReply_no_senders(ipc_port_t port, mach_port_mscount_t mscount);
67*1b191cb5SApple OSS Distributions
68*1b191cb5SApple OSS Distributions IPC_KOBJECT_DEFINE(IKOT_UND_REPLY,
69*1b191cb5SApple OSS Distributions .iko_op_stable = true,
70*1b191cb5SApple OSS Distributions .iko_op_no_senders = UNDReply_no_senders);
71*1b191cb5SApple OSS Distributions
72*1b191cb5SApple OSS Distributions #define UNDReply_lock(reply) lck_mtx_lock(&reply->lock)
73*1b191cb5SApple OSS Distributions #define UNDReply_unlock(reply) lck_mtx_unlock(&reply->lock)
74*1b191cb5SApple OSS Distributions
75*1b191cb5SApple OSS Distributions LCK_GRP_DECLARE(UNDLckGrp, "UND");
76*1b191cb5SApple OSS Distributions
77*1b191cb5SApple OSS Distributions static UNDServerRef
UNDServer_reference(void)78*1b191cb5SApple OSS Distributions UNDServer_reference(void)
79*1b191cb5SApple OSS Distributions {
80*1b191cb5SApple OSS Distributions UNDServerRef UNDServer;
81*1b191cb5SApple OSS Distributions kern_return_t kr;
82*1b191cb5SApple OSS Distributions
83*1b191cb5SApple OSS Distributions kr = host_get_user_notification_port(host_priv_self(), &UNDServer);
84*1b191cb5SApple OSS Distributions assert(kr == KERN_SUCCESS);
85*1b191cb5SApple OSS Distributions return UNDServer;
86*1b191cb5SApple OSS Distributions }
87*1b191cb5SApple OSS Distributions
88*1b191cb5SApple OSS Distributions static void
UNDServer_deallocate(UNDServerRef UNDServer)89*1b191cb5SApple OSS Distributions UNDServer_deallocate(
90*1b191cb5SApple OSS Distributions UNDServerRef UNDServer)
91*1b191cb5SApple OSS Distributions {
92*1b191cb5SApple OSS Distributions if (IP_VALID(UNDServer)) {
93*1b191cb5SApple OSS Distributions ipc_port_release_send(UNDServer);
94*1b191cb5SApple OSS Distributions }
95*1b191cb5SApple OSS Distributions }
96*1b191cb5SApple OSS Distributions
97*1b191cb5SApple OSS Distributions /*
98*1b191cb5SApple OSS Distributions * UND Mig Callbacks
99*1b191cb5SApple OSS Distributions */
100*1b191cb5SApple OSS Distributions
101*1b191cb5SApple OSS Distributions kern_return_t
UNDAlertCompletedWithResult_rpc(UNDReplyRef reply,int result,xmlData_t keyRef,mach_msg_type_number_t keyLen)102*1b191cb5SApple OSS Distributions UNDAlertCompletedWithResult_rpc(
103*1b191cb5SApple OSS Distributions UNDReplyRef reply,
104*1b191cb5SApple OSS Distributions int result,
105*1b191cb5SApple OSS Distributions xmlData_t keyRef, /* raw XML bytes */
106*1b191cb5SApple OSS Distributions #ifdef KERNEL_CF
107*1b191cb5SApple OSS Distributions mach_msg_type_number_t keyLen)
108*1b191cb5SApple OSS Distributions #else
109*1b191cb5SApple OSS Distributions __unused mach_msg_type_number_t keyLen)
110*1b191cb5SApple OSS Distributions #endif
111*1b191cb5SApple OSS Distributions {
112*1b191cb5SApple OSS Distributions #ifdef KERNEL_CF
113*1b191cb5SApple OSS Distributions CFStringRef xmlError = NULL;
114*1b191cb5SApple OSS Distributions CFDictionaryRef dict = NULL;
115*1b191cb5SApple OSS Distributions #else
116*1b191cb5SApple OSS Distributions const void *dict = (const void *)keyRef;
117*1b191cb5SApple OSS Distributions #endif
118*1b191cb5SApple OSS Distributions
119*1b191cb5SApple OSS Distributions if (reply == UND_REPLY_NULL || !reply->inprogress) {
120*1b191cb5SApple OSS Distributions return KERN_INVALID_ARGUMENT;
121*1b191cb5SApple OSS Distributions }
122*1b191cb5SApple OSS Distributions
123*1b191cb5SApple OSS Distributions /*
124*1b191cb5SApple OSS Distributions * JMM - No C vesion of the Unserialize code in-kernel
125*1b191cb5SApple OSS Distributions * and no C type for a CFDictionary either. For now,
126*1b191cb5SApple OSS Distributions * just pass the raw keyRef through.
127*1b191cb5SApple OSS Distributions */
128*1b191cb5SApple OSS Distributions #ifdef KERNEL_CF
129*1b191cb5SApple OSS Distributions if (keyRef && keyLen) {
130*1b191cb5SApple OSS Distributions dict = IOCFUnserialize(keyRef, NULL, NULL, &xmlError);
131*1b191cb5SApple OSS Distributions }
132*1b191cb5SApple OSS Distributions
133*1b191cb5SApple OSS Distributions if (xmlError) {
134*1b191cb5SApple OSS Distributions CFShow(xmlError);
135*1b191cb5SApple OSS Distributions CFRelease(xmlError);
136*1b191cb5SApple OSS Distributions }
137*1b191cb5SApple OSS Distributions #endif /* KERNEL_CF */
138*1b191cb5SApple OSS Distributions
139*1b191cb5SApple OSS Distributions if (reply->callback) {
140*1b191cb5SApple OSS Distributions (reply->callback)((int)(KUNCUserNotificationID)reply, result, dict);
141*1b191cb5SApple OSS Distributions }
142*1b191cb5SApple OSS Distributions
143*1b191cb5SApple OSS Distributions UNDReply_lock(reply);
144*1b191cb5SApple OSS Distributions reply->inprogress = FALSE;
145*1b191cb5SApple OSS Distributions reply->userLandNotificationKey = -1;
146*1b191cb5SApple OSS Distributions UNDReply_unlock(reply);
147*1b191cb5SApple OSS Distributions
148*1b191cb5SApple OSS Distributions return KERN_SUCCESS;
149*1b191cb5SApple OSS Distributions }
150*1b191cb5SApple OSS Distributions
151*1b191cb5SApple OSS Distributions /*
152*1b191cb5SApple OSS Distributions * Routine: UNDNotificationCreated_rpc
153*1b191cb5SApple OSS Distributions *
154*1b191cb5SApple OSS Distributions * Intermediate routine. Allows the kernel mechanism
155*1b191cb5SApple OSS Distributions * to be informed that the notification request IS
156*1b191cb5SApple OSS Distributions * being processed by the user-level daemon, and how
157*1b191cb5SApple OSS Distributions * to identify that request.
158*1b191cb5SApple OSS Distributions */
159*1b191cb5SApple OSS Distributions kern_return_t
UNDNotificationCreated_rpc(UNDReplyRef reply,int userLandNotificationKey)160*1b191cb5SApple OSS Distributions UNDNotificationCreated_rpc(
161*1b191cb5SApple OSS Distributions UNDReplyRef reply,
162*1b191cb5SApple OSS Distributions int userLandNotificationKey)
163*1b191cb5SApple OSS Distributions {
164*1b191cb5SApple OSS Distributions if (reply == UND_REPLY_NULL) {
165*1b191cb5SApple OSS Distributions return KERN_INVALID_ARGUMENT;
166*1b191cb5SApple OSS Distributions }
167*1b191cb5SApple OSS Distributions
168*1b191cb5SApple OSS Distributions UNDReply_lock(reply);
169*1b191cb5SApple OSS Distributions if (reply->inprogress || reply->userLandNotificationKey != -1) {
170*1b191cb5SApple OSS Distributions UNDReply_unlock(reply);
171*1b191cb5SApple OSS Distributions return KERN_INVALID_ARGUMENT;
172*1b191cb5SApple OSS Distributions }
173*1b191cb5SApple OSS Distributions reply->userLandNotificationKey = userLandNotificationKey;
174*1b191cb5SApple OSS Distributions UNDReply_unlock(reply);
175*1b191cb5SApple OSS Distributions return KERN_SUCCESS;
176*1b191cb5SApple OSS Distributions }
177*1b191cb5SApple OSS Distributions
178*1b191cb5SApple OSS Distributions /*
179*1b191cb5SApple OSS Distributions * KUNC Functions
180*1b191cb5SApple OSS Distributions */
181*1b191cb5SApple OSS Distributions
182*1b191cb5SApple OSS Distributions
183*1b191cb5SApple OSS Distributions KUNCUserNotificationID
KUNCGetNotificationID(void)184*1b191cb5SApple OSS Distributions KUNCGetNotificationID(void)
185*1b191cb5SApple OSS Distributions {
186*1b191cb5SApple OSS Distributions UNDReplyRef reply;
187*1b191cb5SApple OSS Distributions
188*1b191cb5SApple OSS Distributions reply = kalloc_type(struct UNDReply, Z_WAITOK | Z_ZERO | Z_NOFAIL);
189*1b191cb5SApple OSS Distributions reply->self_port = ipc_kobject_alloc_port((ipc_kobject_t)reply,
190*1b191cb5SApple OSS Distributions IKOT_UND_REPLY, IPC_KOBJECT_ALLOC_NSREQUEST);
191*1b191cb5SApple OSS Distributions lck_mtx_init(&reply->lock, &UNDLckGrp, LCK_ATTR_NULL);
192*1b191cb5SApple OSS Distributions reply->userLandNotificationKey = -1;
193*1b191cb5SApple OSS Distributions reply->inprogress = FALSE;
194*1b191cb5SApple OSS Distributions
195*1b191cb5SApple OSS Distributions return (KUNCUserNotificationID) reply;
196*1b191cb5SApple OSS Distributions }
197*1b191cb5SApple OSS Distributions
198*1b191cb5SApple OSS Distributions static void
UNDReply_no_senders(ipc_port_t port,mach_port_mscount_t mscount)199*1b191cb5SApple OSS Distributions UNDReply_no_senders(ipc_port_t port, mach_port_mscount_t mscount)
200*1b191cb5SApple OSS Distributions {
201*1b191cb5SApple OSS Distributions UNDReplyRef reply;
202*1b191cb5SApple OSS Distributions
203*1b191cb5SApple OSS Distributions reply = ipc_kobject_dealloc_port(port, mscount, IKOT_UND_REPLY);
204*1b191cb5SApple OSS Distributions lck_mtx_destroy(&reply->lock, &UNDLckGrp);
205*1b191cb5SApple OSS Distributions kfree_type(struct UNDReply, reply);
206*1b191cb5SApple OSS Distributions }
207*1b191cb5SApple OSS Distributions
208*1b191cb5SApple OSS Distributions kern_return_t
KUNCExecute(char executionPath[1024],int uid,int gid)209*1b191cb5SApple OSS Distributions KUNCExecute(char executionPath[1024], int uid, int gid)
210*1b191cb5SApple OSS Distributions {
211*1b191cb5SApple OSS Distributions UNDServerRef UNDServer;
212*1b191cb5SApple OSS Distributions
213*1b191cb5SApple OSS Distributions UNDServer = UNDServer_reference();
214*1b191cb5SApple OSS Distributions if (IP_VALID(UNDServer)) {
215*1b191cb5SApple OSS Distributions kern_return_t kr;
216*1b191cb5SApple OSS Distributions kr = UNDExecute_rpc(UNDServer, executionPath, uid, gid);
217*1b191cb5SApple OSS Distributions UNDServer_deallocate(UNDServer);
218*1b191cb5SApple OSS Distributions return kr;
219*1b191cb5SApple OSS Distributions }
220*1b191cb5SApple OSS Distributions return MACH_SEND_INVALID_DEST;
221*1b191cb5SApple OSS Distributions }
222*1b191cb5SApple OSS Distributions
223*1b191cb5SApple OSS Distributions kern_return_t
KUNCUserNotificationDisplayNotice(int noticeTimeout,unsigned flags,char * iconPath,char * soundPath,char * localizationPath,char * alertHeader,char * alertMessage,char * defaultButtonTitle)224*1b191cb5SApple OSS Distributions KUNCUserNotificationDisplayNotice(
225*1b191cb5SApple OSS Distributions int noticeTimeout,
226*1b191cb5SApple OSS Distributions unsigned flags,
227*1b191cb5SApple OSS Distributions char *iconPath,
228*1b191cb5SApple OSS Distributions char *soundPath,
229*1b191cb5SApple OSS Distributions char *localizationPath,
230*1b191cb5SApple OSS Distributions char *alertHeader,
231*1b191cb5SApple OSS Distributions char *alertMessage,
232*1b191cb5SApple OSS Distributions char *defaultButtonTitle)
233*1b191cb5SApple OSS Distributions {
234*1b191cb5SApple OSS Distributions UNDServerRef UNDServer;
235*1b191cb5SApple OSS Distributions
236*1b191cb5SApple OSS Distributions UNDServer = UNDServer_reference();
237*1b191cb5SApple OSS Distributions if (IP_VALID(UNDServer)) {
238*1b191cb5SApple OSS Distributions kern_return_t kr;
239*1b191cb5SApple OSS Distributions kr = UNDDisplayNoticeSimple_rpc(UNDServer,
240*1b191cb5SApple OSS Distributions noticeTimeout,
241*1b191cb5SApple OSS Distributions flags,
242*1b191cb5SApple OSS Distributions iconPath,
243*1b191cb5SApple OSS Distributions soundPath,
244*1b191cb5SApple OSS Distributions localizationPath,
245*1b191cb5SApple OSS Distributions alertHeader,
246*1b191cb5SApple OSS Distributions alertMessage,
247*1b191cb5SApple OSS Distributions defaultButtonTitle);
248*1b191cb5SApple OSS Distributions UNDServer_deallocate(UNDServer);
249*1b191cb5SApple OSS Distributions return kr;
250*1b191cb5SApple OSS Distributions }
251*1b191cb5SApple OSS Distributions return MACH_SEND_INVALID_DEST;
252*1b191cb5SApple OSS Distributions }
253*1b191cb5SApple OSS Distributions
254*1b191cb5SApple OSS Distributions kern_return_t
KUNCUserNotificationDisplayAlert(int alertTimeout,unsigned flags,char * iconPath,char * soundPath,char * localizationPath,char * alertHeader,char * alertMessage,char * defaultButtonTitle,char * alternateButtonTitle,char * otherButtonTitle,unsigned * responseFlags)255*1b191cb5SApple OSS Distributions KUNCUserNotificationDisplayAlert(
256*1b191cb5SApple OSS Distributions int alertTimeout,
257*1b191cb5SApple OSS Distributions unsigned flags,
258*1b191cb5SApple OSS Distributions char *iconPath,
259*1b191cb5SApple OSS Distributions char *soundPath,
260*1b191cb5SApple OSS Distributions char *localizationPath,
261*1b191cb5SApple OSS Distributions char *alertHeader,
262*1b191cb5SApple OSS Distributions char *alertMessage,
263*1b191cb5SApple OSS Distributions char *defaultButtonTitle,
264*1b191cb5SApple OSS Distributions char *alternateButtonTitle,
265*1b191cb5SApple OSS Distributions char *otherButtonTitle,
266*1b191cb5SApple OSS Distributions unsigned *responseFlags)
267*1b191cb5SApple OSS Distributions {
268*1b191cb5SApple OSS Distributions UNDServerRef UNDServer;
269*1b191cb5SApple OSS Distributions
270*1b191cb5SApple OSS Distributions UNDServer = UNDServer_reference();
271*1b191cb5SApple OSS Distributions if (IP_VALID(UNDServer)) {
272*1b191cb5SApple OSS Distributions kern_return_t kr;
273*1b191cb5SApple OSS Distributions kr = UNDDisplayAlertSimple_rpc(UNDServer,
274*1b191cb5SApple OSS Distributions alertTimeout,
275*1b191cb5SApple OSS Distributions flags,
276*1b191cb5SApple OSS Distributions iconPath,
277*1b191cb5SApple OSS Distributions soundPath,
278*1b191cb5SApple OSS Distributions localizationPath,
279*1b191cb5SApple OSS Distributions alertHeader,
280*1b191cb5SApple OSS Distributions alertMessage,
281*1b191cb5SApple OSS Distributions defaultButtonTitle,
282*1b191cb5SApple OSS Distributions alternateButtonTitle,
283*1b191cb5SApple OSS Distributions otherButtonTitle,
284*1b191cb5SApple OSS Distributions responseFlags);
285*1b191cb5SApple OSS Distributions UNDServer_deallocate(UNDServer);
286*1b191cb5SApple OSS Distributions return kr;
287*1b191cb5SApple OSS Distributions }
288*1b191cb5SApple OSS Distributions return MACH_SEND_INVALID_DEST;
289*1b191cb5SApple OSS Distributions }
290*1b191cb5SApple OSS Distributions
291*1b191cb5SApple OSS Distributions kern_return_t
KUNCUserNotificationDisplayFromBundle(KUNCUserNotificationID id,char * bundlePath,char * fileName,char * fileExtension,char * messageKey,char * tokenString,KUNCUserNotificationCallBack callback,__unused int contextKey)292*1b191cb5SApple OSS Distributions KUNCUserNotificationDisplayFromBundle(
293*1b191cb5SApple OSS Distributions KUNCUserNotificationID id,
294*1b191cb5SApple OSS Distributions char *bundlePath,
295*1b191cb5SApple OSS Distributions char *fileName,
296*1b191cb5SApple OSS Distributions char *fileExtension,
297*1b191cb5SApple OSS Distributions char *messageKey,
298*1b191cb5SApple OSS Distributions char *tokenString,
299*1b191cb5SApple OSS Distributions KUNCUserNotificationCallBack callback,
300*1b191cb5SApple OSS Distributions __unused int contextKey)
301*1b191cb5SApple OSS Distributions {
302*1b191cb5SApple OSS Distributions UNDReplyRef reply = (UNDReplyRef)id;
303*1b191cb5SApple OSS Distributions UNDServerRef UNDServer;
304*1b191cb5SApple OSS Distributions ipc_port_t reply_port;
305*1b191cb5SApple OSS Distributions
306*1b191cb5SApple OSS Distributions if (reply == UND_REPLY_NULL) {
307*1b191cb5SApple OSS Distributions return KERN_INVALID_ARGUMENT;
308*1b191cb5SApple OSS Distributions }
309*1b191cb5SApple OSS Distributions UNDReply_lock(reply);
310*1b191cb5SApple OSS Distributions if (reply->inprogress == TRUE || reply->userLandNotificationKey != -1) {
311*1b191cb5SApple OSS Distributions UNDReply_unlock(reply);
312*1b191cb5SApple OSS Distributions return KERN_INVALID_ARGUMENT;
313*1b191cb5SApple OSS Distributions }
314*1b191cb5SApple OSS Distributions reply->inprogress = TRUE;
315*1b191cb5SApple OSS Distributions reply->callback = callback;
316*1b191cb5SApple OSS Distributions reply_port = ipc_kobject_make_send(reply->self_port, reply, IKOT_UND_REPLY);
317*1b191cb5SApple OSS Distributions UNDReply_unlock(reply);
318*1b191cb5SApple OSS Distributions
319*1b191cb5SApple OSS Distributions UNDServer = UNDServer_reference();
320*1b191cb5SApple OSS Distributions if (IP_VALID(UNDServer)) {
321*1b191cb5SApple OSS Distributions kern_return_t kr;
322*1b191cb5SApple OSS Distributions
323*1b191cb5SApple OSS Distributions kr = UNDDisplayCustomFromBundle_rpc(UNDServer,
324*1b191cb5SApple OSS Distributions reply_port,
325*1b191cb5SApple OSS Distributions bundlePath,
326*1b191cb5SApple OSS Distributions fileName,
327*1b191cb5SApple OSS Distributions fileExtension,
328*1b191cb5SApple OSS Distributions messageKey,
329*1b191cb5SApple OSS Distributions tokenString);
330*1b191cb5SApple OSS Distributions UNDServer_deallocate(UNDServer);
331*1b191cb5SApple OSS Distributions return kr;
332*1b191cb5SApple OSS Distributions }
333*1b191cb5SApple OSS Distributions return MACH_SEND_INVALID_DEST;
334*1b191cb5SApple OSS Distributions }
335*1b191cb5SApple OSS Distributions
336*1b191cb5SApple OSS Distributions /*
337*1b191cb5SApple OSS Distributions * Routine: convert_port_to_UNDReply
338*1b191cb5SApple OSS Distributions *
339*1b191cb5SApple OSS Distributions * MIG helper routine to convert from a mach port to a
340*1b191cb5SApple OSS Distributions * UNDReply object.
341*1b191cb5SApple OSS Distributions *
342*1b191cb5SApple OSS Distributions * Assumptions:
343*1b191cb5SApple OSS Distributions * Nothing locked.
344*1b191cb5SApple OSS Distributions */
345*1b191cb5SApple OSS Distributions UNDReplyRef
convert_port_to_UNDReply(ipc_port_t port)346*1b191cb5SApple OSS Distributions convert_port_to_UNDReply(
347*1b191cb5SApple OSS Distributions ipc_port_t port)
348*1b191cb5SApple OSS Distributions {
349*1b191cb5SApple OSS Distributions UNDReplyRef reply = NULL;
350*1b191cb5SApple OSS Distributions if (IP_VALID(port)) {
351*1b191cb5SApple OSS Distributions reply = ipc_kobject_get_stable(port, IKOT_UND_REPLY);
352*1b191cb5SApple OSS Distributions }
353*1b191cb5SApple OSS Distributions
354*1b191cb5SApple OSS Distributions return reply;
355*1b191cb5SApple OSS Distributions }
356*1b191cb5SApple OSS Distributions #endif
357*1b191cb5SApple OSS Distributions
358*1b191cb5SApple OSS Distributions /*
359*1b191cb5SApple OSS Distributions * User interface for setting the host UserNotification Daemon port.
360*1b191cb5SApple OSS Distributions */
361*1b191cb5SApple OSS Distributions
362*1b191cb5SApple OSS Distributions kern_return_t
host_set_UNDServer(host_priv_t host_priv,UNDServerRef server)363*1b191cb5SApple OSS Distributions host_set_UNDServer(
364*1b191cb5SApple OSS Distributions host_priv_t host_priv,
365*1b191cb5SApple OSS Distributions UNDServerRef server)
366*1b191cb5SApple OSS Distributions {
367*1b191cb5SApple OSS Distributions #if CONFIG_USER_NOTIFICATION
368*1b191cb5SApple OSS Distributions return host_set_user_notification_port(host_priv, server);
369*1b191cb5SApple OSS Distributions #else
370*1b191cb5SApple OSS Distributions #pragma unused(host_priv, server)
371*1b191cb5SApple OSS Distributions return KERN_NOT_SUPPORTED;
372*1b191cb5SApple OSS Distributions #endif
373*1b191cb5SApple OSS Distributions }
374*1b191cb5SApple OSS Distributions
375*1b191cb5SApple OSS Distributions /*
376*1b191cb5SApple OSS Distributions * User interface for retrieving the UserNotification Daemon port.
377*1b191cb5SApple OSS Distributions */
378*1b191cb5SApple OSS Distributions
379*1b191cb5SApple OSS Distributions kern_return_t
host_get_UNDServer(host_priv_t host_priv,UNDServerRef * serverp)380*1b191cb5SApple OSS Distributions host_get_UNDServer(
381*1b191cb5SApple OSS Distributions host_priv_t host_priv,
382*1b191cb5SApple OSS Distributions UNDServerRef *serverp)
383*1b191cb5SApple OSS Distributions {
384*1b191cb5SApple OSS Distributions #if CONFIG_USER_NOTIFICATION
385*1b191cb5SApple OSS Distributions return host_get_user_notification_port(host_priv, serverp);
386*1b191cb5SApple OSS Distributions #else
387*1b191cb5SApple OSS Distributions #pragma unused(host_priv, serverp)
388*1b191cb5SApple OSS Distributions return KERN_NOT_SUPPORTED;
389*1b191cb5SApple OSS Distributions #endif
390*1b191cb5SApple OSS Distributions }
391