_realhostname_sa
_reexec_to_match_kernel
_reexec_to_match_lp64ness
+_tzlink
_wipefs_alloc
_wipefs_except_blocks
_wipefs_free
objectVersion = 46;
objects = {
+/* Begin PBXAggregateTarget section */
+ FDBC26E41741B09300CA4B2B /* osx */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = FDBC26E71741B09300CA4B2B /* Build configuration list for PBXAggregateTarget "osx" */;
+ buildPhases = (
+ );
+ dependencies = (
+ FDBC27001741B1B300CA4B2B /* PBXTargetDependency */,
+ );
+ name = osx;
+ productName = OSX;
+ };
+ FDBC26E81741B09D00CA4B2B /* ios */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = FDBC26E91741B09D00CA4B2B /* Build configuration list for PBXAggregateTarget "ios" */;
+ buildPhases = (
+ );
+ dependencies = (
+ FDBC27021741B1B500CA4B2B /* PBXTargetDependency */,
+ FDBC27041741B1B700CA4B2B /* PBXTargetDependency */,
+ );
+ name = ios;
+ productName = ios;
+ };
+/* End PBXAggregateTarget section */
+
/* Begin PBXBuildFile section */
BA79F9CB13BB7207006A292D /* ExtentManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA79F9A313BB70FF006A292D /* ExtentManager.cpp */; };
BA79F9CC13BB7207006A292D /* getmntopts.c in Sources */ = {isa = PBXBuildFile; fileRef = BA79F9A613BB70FF006A292D /* getmntopts.c */; };
BA79F9E613BB76B0006A292D /* wipefs.3 in CopyFiles */ = {isa = PBXBuildFile; fileRef = BA79F9BC13BB70FF006A292D /* wipefs.3 */; };
BA79F9E913BB77FA006A292D /* libutil.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = BA79F9AB13BB70FF006A292D /* libutil.plist */; };
BA79F9EA13BB77FF006A292D /* libutil.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = BA79F9AC13BB70FF006A292D /* libutil.txt */; };
+ FDBC27051741B1C300CA4B2B /* com.apple.tzlinkd.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = FDBC26FA1741B19000CA4B2B /* com.apple.tzlinkd.plist */; };
+ FDBC27061741B1CF00CA4B2B /* tzlinkd.c in Sources */ = {isa = PBXBuildFile; fileRef = FDBC26FE1741B19000CA4B2B /* tzlinkd.c */; };
+ FDBC27071741B1D600CA4B2B /* tzlink.c in Sources */ = {isa = PBXBuildFile; fileRef = FDBC26F91741B18500CA4B2B /* tzlink.c */; };
+ FDBC270B1741B55400CA4B2B /* tzlink.h in Headers */ = {isa = PBXBuildFile; fileRef = FDBC27091741B47200CA4B2B /* tzlink.h */; settings = {ATTRIBUTES = (Private, ); }; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ FDBC26FF1741B1B300CA4B2B /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA79F99713BB70D7006A292D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = BA79F9C413BB718B006A292D;
+ remoteInfo = util;
+ };
+ FDBC27011741B1B500CA4B2B /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA79F99713BB70D7006A292D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = BA79F9C413BB718B006A292D;
+ remoteInfo = util;
+ };
+ FDBC27031741B1B700CA4B2B /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA79F99713BB70D7006A292D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = FDBC26EF1741B13400CA4B2B;
+ remoteInfo = tzlinkd;
+ };
+/* End PBXContainerItemProxy section */
+
/* Begin PBXCopyFilesBuildPhase section */
BA79F9DB13BB7698006A292D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
);
runOnlyForDeploymentPostprocessing = 1;
};
+ FDBC26EE1741B13400CA4B2B /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "$(INSTALL_PREFIX)/System/Library/LaunchDaemons";
+ dstSubfolderSpec = 0;
+ files = (
+ FDBC27051741B1C300CA4B2B /* com.apple.tzlinkd.plist in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
BA79F9AA13BB70FF006A292D /* libutil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libutil.h; sourceTree = "<group>"; };
BA79F9AB13BB70FF006A292D /* libutil.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = libutil.plist; sourceTree = "<group>"; };
BA79F9AC13BB70FF006A292D /* libutil.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = libutil.txt; sourceTree = "<group>"; };
- BA79F9AD13BB70FF006A292D /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
BA79F9AE13BB70FF006A292D /* mntopts.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mntopts.h; sourceTree = "<group>"; };
BA79F9AF13BB70FF006A292D /* pidfile.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = pidfile.3; sourceTree = "<group>"; };
BA79F9B013BB70FF006A292D /* pidfile.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = pidfile.c; sourceTree = "<group>"; };
BA79F9BE13BB70FF006A292D /* wipefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = wipefs.h; sourceTree = "<group>"; };
BA79F9C013BB712E006A292D /* BSD.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = BSD.xcconfig; path = Makefiles/CoreOS/Xcode/BSD.xcconfig; sourceTree = DEVELOPER_DIR; };
BA79F9C513BB718B006A292D /* libutil1.0.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libutil1.0.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+ FDBC26F01741B13400CA4B2B /* tzlinkd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tzlinkd; sourceTree = BUILT_PRODUCTS_DIR; };
+ FDBC26F91741B18500CA4B2B /* tzlink.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tzlink.c; sourceTree = "<group>"; };
+ FDBC26FA1741B19000CA4B2B /* com.apple.tzlinkd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = com.apple.tzlinkd.plist; sourceTree = "<group>"; };
+ FDBC26FB1741B19000CA4B2B /* com.apple.tzlinkd.sb */ = {isa = PBXFileReference; lastKnownFileType = text; path = com.apple.tzlinkd.sb; sourceTree = "<group>"; };
+ FDBC26FE1741B19000CA4B2B /* tzlinkd.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tzlinkd.c; sourceTree = "<group>"; };
+ FDBC27081741B47200CA4B2B /* tzlink_internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tzlink_internal.h; sourceTree = "<group>"; };
+ FDBC27091741B47200CA4B2B /* tzlink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tzlink.h; sourceTree = "<group>"; };
+ FDBC270D1741B66500CA4B2B /* tzlinkd.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = tzlinkd.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
);
runOnlyForDeploymentPostprocessing = 0;
};
+ FDBC26ED1741B13400CA4B2B /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
BA79F9AA13BB70FF006A292D /* libutil.h */,
BA79F9AB13BB70FF006A292D /* libutil.plist */,
BA79F9AC13BB70FF006A292D /* libutil.txt */,
- BA79F9AD13BB70FF006A292D /* Makefile */,
BA79F9AE13BB70FF006A292D /* mntopts.h */,
BA79F9AF13BB70FF006A292D /* pidfile.3 */,
BA79F9B013BB70FF006A292D /* pidfile.c */,
BA79F9B713BB70FF006A292D /* reexec_to_match_kernel.c */,
BA79F9B813BB70FF006A292D /* trimdomain.3 */,
BA79F9B913BB70FF006A292D /* trimdomain.c */,
+ FDBC26F91741B18500CA4B2B /* tzlink.c */,
+ FDBC27091741B47200CA4B2B /* tzlink.h */,
+ FDBC27081741B47200CA4B2B /* tzlink_internal.h */,
+ FDBC26F11741B13400CA4B2B /* tzlinkd */,
BA79F9BC13BB70FF006A292D /* wipefs.3 */,
BA79F9BD13BB70FF006A292D /* wipefs.cpp */,
BA79F9BE13BB70FF006A292D /* wipefs.h */,
+ FDBC270C1741B66500CA4B2B /* xcconfigs */,
BA79F9C613BB718B006A292D /* Products */,
);
sourceTree = "<group>";
isa = PBXGroup;
children = (
BA79F9C513BB718B006A292D /* libutil1.0.dylib */,
+ FDBC26F01741B13400CA4B2B /* tzlinkd */,
);
name = Products;
sourceTree = "<group>";
};
+ FDBC26F11741B13400CA4B2B /* tzlinkd */ = {
+ isa = PBXGroup;
+ children = (
+ FDBC26FA1741B19000CA4B2B /* com.apple.tzlinkd.plist */,
+ FDBC26FB1741B19000CA4B2B /* com.apple.tzlinkd.sb */,
+ FDBC26FE1741B19000CA4B2B /* tzlinkd.c */,
+ );
+ path = tzlinkd;
+ sourceTree = "<group>";
+ };
+ FDBC270C1741B66500CA4B2B /* xcconfigs */ = {
+ isa = PBXGroup;
+ children = (
+ FDBC270D1741B66500CA4B2B /* tzlinkd.xcconfig */,
+ );
+ path = xcconfigs;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
files = (
BA79F9D513BB7235006A292D /* libutil.h in Headers */,
BA79F9D613BB7235006A292D /* mntopts.h in Headers */,
+ FDBC270B1741B55400CA4B2B /* tzlink.h in Headers */,
BA79F9D713BB7235006A292D /* wipefs.h in Headers */,
BA79F9D813BB7243006A292D /* ExtentManager.h in Headers */,
);
productReference = BA79F9C513BB718B006A292D /* libutil1.0.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
+ FDBC26EF1741B13400CA4B2B /* tzlinkd */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = FDBC26F81741B13400CA4B2B /* Build configuration list for PBXNativeTarget "tzlinkd" */;
+ buildPhases = (
+ FDBC26EC1741B13400CA4B2B /* Sources */,
+ FDBC26ED1741B13400CA4B2B /* Frameworks */,
+ FDBC26EE1741B13400CA4B2B /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = tzlinkd;
+ productName = tzlinkd;
+ productReference = FDBC26F01741B13400CA4B2B /* tzlinkd */;
+ productType = "com.apple.product-type.tool";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
projectDirPath = "";
projectRoot = "";
targets = (
+ FDBC26E81741B09D00CA4B2B /* ios */,
+ FDBC26E41741B09300CA4B2B /* osx */,
BA79F9C413BB718B006A292D /* util */,
+ FDBC26EF1741B13400CA4B2B /* tzlinkd */,
);
};
/* End PBXProject section */
BA79F9D013BB7207006A292D /* realhostname.c in Sources */,
BA79F9D113BB7207006A292D /* reexec_to_match_kernel.c in Sources */,
BA79F9D213BB7207006A292D /* trimdomain.c in Sources */,
+ FDBC27071741B1D600CA4B2B /* tzlink.c in Sources */,
BA79F9D413BB7207006A292D /* wipefs.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+ FDBC26EC1741B13400CA4B2B /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FDBC27061741B1CF00CA4B2B /* tzlinkd.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ FDBC27001741B1B300CA4B2B /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = BA79F9C413BB718B006A292D /* util */;
+ targetProxy = FDBC26FF1741B1B300CA4B2B /* PBXContainerItemProxy */;
+ };
+ FDBC27021741B1B500CA4B2B /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = BA79F9C413BB718B006A292D /* util */;
+ targetProxy = FDBC27011741B1B500CA4B2B /* PBXContainerItemProxy */;
+ };
+ FDBC27041741B1B700CA4B2B /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = FDBC26EF1741B13400CA4B2B /* tzlinkd */;
+ targetProxy = FDBC27031741B1B700CA4B2B /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin XCBuildConfiguration section */
BA79F99C13BB70D7006A292D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BA79F9C013BB712E006A292D /* BSD.xcconfig */;
buildSettings = {
+ APPLY_RULES_IN_COPY_FILES = YES;
+ "PLIST_FILE_OUTPUT_FORMAT[sdk=iphoneos*]" = binary;
+ USE_HEADERMAP = NO;
};
name = Debug;
};
isa = XCBuildConfiguration;
baseConfigurationReference = BA79F9C013BB712E006A292D /* BSD.xcconfig */;
buildSettings = {
+ APPLY_RULES_IN_COPY_FILES = YES;
+ "PLIST_FILE_OUTPUT_FORMAT[sdk=iphoneos*]" = binary;
+ USE_HEADERMAP = NO;
};
name = Release;
};
};
name = Release;
};
+ FDBC26E51741B09300CA4B2B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ FDBC26E61741B09300CA4B2B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ FDBC26EA1741B09D00CA4B2B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ FDBC26EB1741B09D00CA4B2B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ FDBC26F61741B13400CA4B2B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = FDBC270D1741B66500CA4B2B /* tzlinkd.xcconfig */;
+ buildSettings = {
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ };
+ name = Debug;
+ };
+ FDBC26F71741B13400CA4B2B /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = FDBC270D1741B66500CA4B2B /* tzlinkd.xcconfig */;
+ buildSettings = {
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ FDBC26E71741B09300CA4B2B /* Build configuration list for PBXAggregateTarget "osx" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FDBC26E51741B09300CA4B2B /* Debug */,
+ FDBC26E61741B09300CA4B2B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ FDBC26E91741B09D00CA4B2B /* Build configuration list for PBXAggregateTarget "ios" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FDBC26EA1741B09D00CA4B2B /* Debug */,
+ FDBC26EB1741B09D00CA4B2B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ FDBC26F81741B13400CA4B2B /* Build configuration list for PBXNativeTarget "tzlinkd" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FDBC26F61741B13400CA4B2B /* Debug */,
+ FDBC26F71741B13400CA4B2B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = BA79F99713BB70D7006A292D /* Project object */;
--- /dev/null
+/*
+ * Copyright (c) 2013 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <TargetConditionals.h>
+#include <xpc/xpc.h>
+#include <errno.h>
+
+#include "tzlink.h"
+#include "tzlink_internal.h"
+
+errno_t
+tzlink(const char *tz)
+{
+#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+ xpc_connection_t connection;
+ xpc_object_t request, reply;
+ errno_t e;
+
+ if (tz == NULL) {
+ return EINVAL;
+ }
+
+ connection = xpc_connection_create_mach_service(TZLINK_SERVICE_NAME, NULL, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
+ xpc_connection_set_event_handler(connection, ^(__unused xpc_object_t event) {
+ });
+ xpc_connection_resume(connection);
+
+ request = xpc_dictionary_create(NULL, NULL, 0);
+ xpc_dictionary_set_string(request, TZLINK_KEY_REQUEST_TIMEZONE, tz);
+
+ reply = xpc_connection_send_message_with_reply_sync(connection, request);
+ if (xpc_get_type(reply) == XPC_TYPE_DICTIONARY) {
+ e = (errno_t)xpc_dictionary_get_uint64(reply, TZLINK_KEY_REPLY_ERROR);
+ } else {
+ e = EIO;
+ }
+
+ xpc_release(reply);
+ xpc_release(request);
+ xpc_release(connection);
+
+ return e;
+#else /* !TARGET_OS_IPHONE */
+#pragma unused (tz)
+ return ENOTSUP;
+#endif /* TARGET_OS_IPHONE */
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _TZLINK_H_
+#define _TZLINK_H_
+
+/*!
+ * @function tzlink
+ * Create the timezone link at TZDEFAULT
+ *
+ * @param tz
+ * New timezone, e.g. "America/Los_Angeles". This path is relative to TZDIR,
+ * and must not contain any relative path components or stray slashes.
+ * The file must exist and must be a valid timezone file with correct
+ * ownership (root:wheel) and permissions (0644).
+ *
+ * @result
+ * If the call succeeds, will return zero. Otherwise, returns an error:
+ * EINVAL: Invalid input, e.g. NULL or a path with relative components.
+ * ENAMETOOLONG: Input too long (generates a path > PATH_MAX)
+ * ENOENT: Specified file doesn't exist or fails owner/perm check.
+ * EPERM: Entitlement check failed.
+ * EIO: Failed to communicate with backing daemon.
+ * ENOTSUP: Always returned on OS X.
+ * And possibly others not documented here.
+ *
+ * @discussion
+ * This call can be used by any sufficiently-entitled client to overwrite
+ * the timezone link at TZDEFAULT (see <tzfile.h>). It communicates with a
+ * root daemon that does the necessary validation and file system work.
+ * Upon success, the "SignificantTimeChangeNotification" notification is
+ * posted.
+ */
+errno_t tzlink(const char *tz);
+
+#endif /* !_TZLINK_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define TZLINK_SERVICE_NAME "com.apple.tzlink"
+
+#define TZLINK_ENTITLEMENT "com.apple.tzlink.allow"
+
+#define TZLINK_KEY_REQUEST_TIMEZONE "tz" // string
+#define TZLINK_KEY_REPLY_ERROR "error" // uint64
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>EnableTransactions</key>
+ <true/>
+ <key>JetsamProperties</key>
+ <dict>
+ <key>JetsamMemoryLimit</key>
+ <integer>300</integer>
+ <key>JetsamPriority</key>
+ <integer>-49</integer>
+ </dict>
+ <key>Label</key>
+ <string>com.apple.tzlinkd</string>
+ <key>MachServices</key>
+ <dict>
+ <key>com.apple.tzlink</key>
+ <true/>
+ </dict>
+ <key>POSIXSpawnType</key>
+ <string>Adaptive</string>
+ <key>Program</key>
+ <string>/usr/libexec/tzlinkd</string>
+</dict>
+</plist>
--- /dev/null
+(version 1)
+
+(deny default)
+
+(import "system.sb")
+
+(allow file-write-create file-write-unlink
+ (literal "/private/var/db/timezone/localtime"))
+
+(allow file-read*
+ (literal "/private/var/db/timezone/zoneinfo"))
--- /dev/null
+/*
+ * Copyright (c) 2013 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <xpc/xpc.h>
+#include <xpc/private.h>
+#include <notify.h>
+#include <tzfile.h>
+
+#include "tzlink_internal.h"
+
+static bool peer_entitled(xpc_connection_t);
+static int set_timezone(const char *);
+static int build_source_path(char *, size_t, const char *);
+static int validate_source_path(const char *);
+
+int
+main(void)
+{
+ dispatch_queue_t queue;
+ xpc_connection_t listener;
+
+ xpc_track_activity();
+
+ queue = dispatch_queue_create(TZLINK_SERVICE_NAME, NULL);
+
+ listener = xpc_connection_create_mach_service(TZLINK_SERVICE_NAME, queue, XPC_CONNECTION_MACH_SERVICE_LISTENER);
+ xpc_connection_set_event_handler(listener, ^(xpc_object_t peer) {
+ if (xpc_get_type(peer) != XPC_TYPE_CONNECTION) {
+ return;
+ }
+
+ xpc_connection_set_target_queue(peer, queue);
+ xpc_connection_set_event_handler(peer, ^(xpc_object_t request) {
+ xpc_object_t reply;
+ const char *tz;
+ int error;
+
+ if (xpc_get_type(request) != XPC_TYPE_DICTIONARY) {
+ return;
+ }
+
+ if (peer_entitled(peer)) {
+ tz = xpc_dictionary_get_string(request, TZLINK_KEY_REQUEST_TIMEZONE);
+ error = tz ? set_timezone(tz) : EINVAL;
+ } else {
+ error = EPERM;
+ }
+
+ reply = xpc_dictionary_create_reply(request);
+ xpc_dictionary_set_uint64(reply, TZLINK_KEY_REPLY_ERROR, (uint64_t)error);
+ xpc_connection_send_message(peer, reply);
+ xpc_release(reply);
+ });
+ xpc_connection_resume(peer);
+ });
+ xpc_connection_resume(listener);
+
+ dispatch_main();
+}
+
+static bool
+peer_entitled(xpc_connection_t peer)
+{
+ xpc_object_t val;
+ bool entitled;
+
+ entitled = false;
+
+ val = xpc_connection_copy_entitlement_value(peer, TZLINK_ENTITLEMENT);
+ if (val != NULL) {
+ entitled = xpc_bool_get_value(val);
+ xpc_release(val);
+ }
+
+ return entitled;
+}
+
+static int
+set_timezone(const char *tz)
+{
+ char srcpath[PATH_MAX];
+ int error;
+
+ error = build_source_path(srcpath, sizeof(srcpath), tz);
+ if (error != 0) {
+ return error;
+ }
+
+ error = validate_source_path(srcpath);
+ if (error != 0) {
+ return error;
+ }
+
+ (void)unlink(TZDEFAULT);
+ if (symlink(srcpath, TZDEFAULT) != 0) {
+ return errno ? errno : EFAULT;
+ }
+
+ /*
+ * notifyd posts "com.apple.system.timezone" automatically,
+ * but we also need post this. Sigh.
+ */
+ (void)notify_post("SignificantTimeChangeNotification");
+
+ return 0;
+}
+
+/* Create path from input. */
+static int
+build_source_path(char *path, size_t size, const char *tz)
+{
+ char *str, *str0;
+ char *pathcomp;
+ int error;
+
+ if (strlcpy(path, TZDIR, size) >= size) {
+ return ENAMETOOLONG;
+ }
+
+ error = 0;
+
+ /* Attempt to validate the input; construct a clean path as we go. */
+ str0 = str = strdup(tz);
+ while ((pathcomp = strsep(&str, "/")) != NULL) {
+ if (pathcomp[0] == '\0' || pathcomp[0] == '.') {
+ error = EINVAL;
+ break;
+ }
+ if (strlcat(path, "/", size) >= size) {
+ error = ENAMETOOLONG;
+ break;
+ }
+ if (strlcat(path, pathcomp, size) >= size) {
+ error = ENAMETOOLONG;
+ break;
+ }
+ }
+ free(str0);
+
+ return error;
+}
+
+/* Validate path. */
+static int
+validate_source_path(const char *path)
+{
+ struct stat sb;
+
+ if (lstat(path, &sb) != 0) {
+ return errno ? errno : EFAULT;
+ }
+
+ /* Ensure that the time zone file is... */
+
+ /* ... a regular file. */
+ if (!S_ISREG(sb.st_mode)) {
+ return ENOENT;
+ }
+
+ /* ... owned by root:wheel */
+ if (sb.st_uid != 0 || sb.st_gid != 0) {
+ return ENOENT;
+ }
+
+ /* ... 0644 perms */
+ if ((sb.st_mode & ACCESSPERMS) != 0644) {
+ return ENOENT;
+ }
+
+ /* ... is a real tzfile (starts with TZif) */
+ // TODO: Validate contents of file.
+
+ return 0;
+}
class ExtentManager extMan;
};
-void
+static void
AddExtentsForFutureFS(class ExtentManager *extMan)
{
// we don't know what blocks future FS will use to recognize itself. But we'd better be safe than sorry and write
extMan->AddByteRangeExtent(extMan->totalBytes - size, size);
}
-void
+static void
AddExtentsForHFS(class ExtentManager *extMan)
{
// first 1KB is boot block, last 512B is reserved
extMan->AddByteRangeExtent(extMan->totalBytes - 1024, 1024);
}
-void
+static void
AddExtentsForMSDOS(class ExtentManager *extMan)
{
// MSDOS needs the first block (in theory, up to 32KB)
extMan->AddByteRangeExtent(0, 32 * 1024);
}
-void
+static void
AddExtentsForNTFS(class ExtentManager *extMan)
{
// NTFS supports block size from 256B to 32768B. The first, middle and last block are needed
extMan->AddByteRangeExtent(extMan->totalBytes / 2 - 32 * 1024, 64 * 1024);
}
-void
+static void
AddExtentsForUDF(class ExtentManager *extMan)
{
off_t lastBlockAddr = extMan->totalBlocks - 1;
}
}
-void
+static void
AddExtentsForUFS(class ExtentManager *extMan)
{
// UFS super block is 8KB at offset 8KB
extMan->AddByteRangeExtent(8192, 8192);
}
-void
+static void
AddExtentsForZFS(class ExtentManager *extMan)
{
// ZFS needs the first 512KB and last 512KB for all the 4 disk labels
extMan->AddByteRangeExtent(extMan->totalBytes - 512 * 1024, 512 * 1024);
}
-void
+static void
AddExtentsForPartitions(class ExtentManager *extMan)
{
// MBR (Master Boot Record) needs the first sector
bufSize = 128 * 1024; // issue large I/O to get better performance
+ if (handle->extMan.nativeBlockSize > bufSize) {
+ bufSize = handle->extMan.nativeBlockSize;
+ }
bufZero = new uint8_t[bufSize];
bzero(bufZero, bufSize);
--- /dev/null
+INSTALL_PATH = $(INSTALL_PREFIX)/usr/libexec
+PRODUCT_NAME = tzlinkd
+
+INSTALL_PREFIX = $(INSTALL_PREFIX_$(PLATFORM_NAME))
+INSTALL_PREFIX_iphonesimulator = $(SDKROOT)
+
+USER_HEADER_SEARCH_PATHS = $(SRCROOT)
+
+ALWAYS_SEARCH_USER_PATHS = NO
+
+GCC_TREAT_WARNINGS_AS_ERRORS = YES
+CLANG_WARN_BOOL_CONVERSION = YES
+CLANG_WARN_CONSTANT_CONVERSION = YES
+CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
+CLANG_WARN_EMPTY_BODY = YES
+CLANG_WARN_ENUM_CONVERSION = YES
+CLANG_WARN_INT_CONVERSION = YES
+CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR
+CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
+GCC_WARN_64_TO_32_BIT_CONVERSION = YES
+GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
+GCC_WARN_UNDECLARED_SELECTOR = YES
+GCC_WARN_UNINITIALIZED_AUTOS = YES
+GCC_WARN_UNUSED_FUNCTION = YES
+GCC_WARN_UNUSED_VARIABLE = YES
+GCC_WARN_UNKNOWN_PRAGMAS = YES
+GCC_WARN_UNUSED_LABEL = YES
+GCC_WARN_UNUSED_PARAMETER = YES