2 * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015-2017 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * Modification History
27 * May 19, 2001 Allan Nathanson <ajn@apple.com>
36 __SCDynamicStoreNotifyValue(SCDynamicStoreRef store
, CFStringRef key
, Boolean internal
)
39 Boolean newValue
= FALSE
;
40 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
41 int sc_status
= kSCStatusOK
;
44 SC_trace("%s : %5d : %@",
45 internal
? "*notify" : "notify ",
50 * Tickle the value in the dynamic store
52 dict
= CFDictionaryGetValue(storeData
, key
);
53 if (!dict
|| !CFDictionaryGetValueIfPresent(dict
, kSCDData
, (const void **)&value
)) {
54 /* key doesn't exist (or data never defined) */
55 (void)_SCSerialize(kCFBooleanTrue
, &value
, NULL
, NULL
);
59 /* replace or store initial/temporary existing value */
60 __SCDynamicStoreSetValue(store
, key
, value
, TRUE
);
63 /* remove the value we just created */
64 __SCDynamicStoreRemoveValue(store
, key
, TRUE
);
70 __SCDynamicStorePush();
79 _confignotify(mach_port_t server
,
80 xmlData_t keyRef
, /* raw XML bytes */
81 mach_msg_type_number_t keyLen
,
83 audit_token_t audit_token
)
85 CFStringRef key
= NULL
; /* key (un-serialized) */
86 serverSessionRef mySession
;
88 /* un-serialize the key */
89 if (!_SCUnserializeString(&key
, NULL
, (void *)keyRef
, keyLen
)) {
90 *sc_status
= kSCStatusFailed
;
94 if (!isA_CFString(key
)) {
95 *sc_status
= kSCStatusInvalidArgument
;
99 mySession
= getSession(server
);
100 if (mySession
== NULL
) {
101 mySession
= tempSession(server
, CFSTR("SCDynamicStoreNotifyValue"), audit_token
);
102 if (mySession
== NULL
) {
103 /* you must have an open session to play */
104 *sc_status
= kSCStatusNoStoreSession
;
109 if (!hasWriteAccess(mySession
, "notify", key
)) {
110 *sc_status
= kSCStatusAccessError
;
114 *sc_status
= __SCDynamicStoreNotifyValue(mySession
->store
, key
, FALSE
);
118 if (key
) CFRelease(key
);