]>
git.saurik.com Git - apple/libinfo.git/blob - gen.subproj/configuration_profile.c
1a0f0a2cf541e15afedb675b90fa4f725c5b97e4
2 * Copyright (c) 2012 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@
26 #include <xpc/private.h>
28 #include <TargetConditionals.h>
29 #include "configuration_profile.h"
31 #define NOTIFY_PATH_SERVICE "com.apple.system.notify.service.path:0x87:"
32 #define CPROF_PATH "/Library/Managed Preferences/mobile"
35 configuration_profile_create_notification_key(const char *ident
)
39 if (ident
== NULL
) return NULL
;
43 asprintf(&out
, "%s%s", NOTIFY_PATH_SERVICE
, ident
);
47 #if TARGET_OS_EMBEDDED
48 if (strchr(ident
+ 1, '/') != NULL
) return NULL
;
49 asprintf(&out
, "%s%s/%s.plist", NOTIFY_PATH_SERVICE
, CPROF_PATH
, ident
);
56 configuration_profile_copy_property_list(const char *ident
)
58 char path
[MAXPATHLEN
];
62 xpc_object_t out
= NULL
;
64 if (ident
== NULL
) return NULL
;
69 snprintf(path
, sizeof(path
), "%s", ident
);
71 #if TARGET_OS_EMBEDDED
74 if (strchr(ident
+ 1, '/') != NULL
) return NULL
;
75 snprintf(path
, sizeof(path
), "%s/%s.plist", CPROF_PATH
, ident
);
79 if (path
[0] == '\0') return NULL
;
81 fd
= open(path
, O_RDONLY
, 0);
82 if (fd
< 0) return NULL
;
84 memset(&sb
, 0, sizeof(struct stat
));
85 if (fstat(fd
, &sb
) < 0)
91 data
= mmap(NULL
, sb
.st_size
, PROT_READ
, MAP_PRIVATE
, fd
, 0);
92 if (data
!= NULL
) out
= xpc_create_from_plist(data
, sb
.st_size
);
94 munmap(data
, sb
.st_size
);