]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferencesInternal.h
configd-1061.40.2.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCPreferencesInternal.h
1 /*
2 * Copyright (c) 2000, 2001, 2003-2005, 2007-2011, 2013-2018 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _SCPREFERENCESINTERNAL_H
25 #define _SCPREFERENCESINTERNAL_H
26
27 #include <dispatch/dispatch.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/time.h>
31 #include <os/log.h>
32 #include <os/state_private.h>
33 #include <CoreFoundation/CoreFoundation.h>
34 #include <CoreFoundation/CFRuntime.h>
35
36 #ifndef SC_LOG_HANDLE
37 #define SC_LOG_HANDLE __log_SCPreferences
38 #endif // SC_LOG_HANDLE
39 #include <SystemConfiguration/SystemConfiguration.h>
40 #include <SystemConfiguration/SCValidation.h>
41 #include <SystemConfiguration/SCPrivate.h>
42
43 #include <SystemConfiguration/SCPreferences.h>
44 #include <SystemConfiguration/SCDynamicStore.h>
45
46
47 #define PREFS_DEFAULT_DIR CFSTR("/Library/Preferences/SystemConfiguration")
48 #define PREFS_DEFAULT_CONFIG CFSTR("preferences.plist")
49
50 #define PREFS_DEFAULT_DIR_OLD CFSTR("/var/db/SystemConfiguration")
51 #define PREFS_DEFAULT_CONFIG_OLD CFSTR("preferences.xml")
52
53 #define PREFS_DEFAULT_USER_DIR CFSTR("Library/Preferences")
54
55 #define NETWORK_INTERFACES_PREFS CFSTR("NetworkInterfaces.plist")
56 #define INTERFACES CFSTR("Interfaces")
57
58
59 /* Define the per-preference-handle structure */
60 typedef struct {
61
62 /* base CFType information */
63 CFRuntimeBase cfBase;
64
65 /* lock */
66 pthread_mutex_t lock;
67
68 /* session name */
69 CFStringRef name;
70
71 /* preferences ID */
72 CFStringRef prefsID;
73
74 /* options */
75 CFDictionaryRef options;
76
77 /* configuration file */
78 char *path;
79 char *newPath;
80
81 /* preferences lock, lock file */
82 Boolean locked;
83 int lockFD;
84 char *lockPath;
85 struct timeval lockTime;
86
87 /* configuration file signature */
88 CFDataRef signature;
89
90 /* configd session */
91 SCDynamicStoreRef session;
92 SCDynamicStoreRef sessionNoO_EXLOCK;
93 int sessionRefcnt;
94
95 /* configd session keys */
96 CFStringRef sessionKeyLock;
97 CFStringRef sessionKeyCommit;
98 CFStringRef sessionKeyApply;
99
100 /* run loop source, callout, context, rl scheduling info */
101 Boolean scheduled;
102 CFRunLoopSourceRef rls;
103 SCPreferencesCallBack rlsFunction;
104 SCPreferencesContext rlsContext;
105 CFMutableArrayRef rlList;
106 dispatch_queue_t dispatchQueue; // SCPreferencesSetDispatchQueue
107
108 /* preferences */
109 CFMutableDictionaryRef prefs;
110
111 /* flags */
112 Boolean accessed;
113 Boolean changed;
114 Boolean isRoot;
115 Boolean limit_SCNetworkConfiguration;
116
117 /* authorization, helper */
118 CFDataRef authorizationData;
119 mach_port_t helper_port;
120
121 } SCPreferencesPrivate, *SCPreferencesPrivateRef;
122
123
124 /* Define signature data */
125 typedef struct {
126 int64_t st_dev; /* inode's device */
127 uint64_t st_ino; /* inode's number */
128 uint64_t tv_sec; /* time of last data modification */
129 uint64_t tv_nsec;
130 off_t st_size; /* file size, in bytes */
131 } SCPSignatureData, *SCPSignatureDataRef;
132
133
134 __BEGIN_DECLS
135
136 os_log_t
137 __log_SCPreferences (void);
138
139 Boolean
140 __SCPreferencesCreate_helper (SCPreferencesRef prefs);
141
142 void
143 __SCPreferencesAccess (SCPreferencesRef prefs);
144
145 void
146 __SCPreferencesAddSessionKeys (SCPreferencesRef prefs);
147
148 Boolean
149 __SCPreferencesAddSession (SCPreferencesRef prefs);
150
151 void
152 __SCPreferencesRemoveSession (SCPreferencesRef prefs);
153
154 void
155 __SCPreferencesUpdateLockedState (SCPreferencesRef prefs,
156 Boolean locked);
157
158 CF_RETURNS_RETAINED
159 CFDataRef
160 __SCPSignatureFromStatbuf (const struct stat *statBuf);
161
162 char *
163 __SCPreferencesPath (CFAllocatorRef allocator,
164 CFStringRef prefsID,
165 Boolean useNewPrefs);
166
167 off_t
168 __SCPreferencesPrefsSize (SCPreferencesRef prefs);
169
170 CF_RETURNS_RETAINED
171 CFStringRef
172 _SCPNotificationKey (CFAllocatorRef allocator,
173 CFStringRef prefsID,
174 int keyType);
175 Boolean
176 __SCPreferencesGetLimitSCNetworkConfiguration (SCPreferencesRef prefs);
177
178 void
179 __SCPreferencesSetLimitSCNetworkConfiguration
180 (SCPreferencesRef prefs,
181 Boolean limit_SCNetworkConfiguration);
182
183 Boolean
184 __SCPreferencesUsingDefaultPrefs (SCPreferencesRef prefs);
185
186 SCPreferencesRef
187 __SCPreferencesCreateNIPrefsFromPrefs (SCPreferencesRef prefs);
188
189 __END_DECLS
190
191 #endif /* _SCPREFERENCESINTERNAL_H */