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