From dcace88fe6cde929a524daa9e1f1495bf1e24cfe Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 13 Jul 2011 22:38:10 +0000 Subject: [PATCH] launchd-392.18.tar.gz --- launchd.xcodeproj/project.pbxproj | 192 +- launchd/src/IPC.h | 2 +- launchd/src/StartupItems.c | 5 +- launchd/src/StartupItems.h | 6 +- launchd/src/SystemStarter.c | 6 +- launchd/src/SystemStarter.h | 2 +- launchd/src/SystemStarterIPC.h | 2 +- launchd/src/bootstrap.h | 6 +- launchd/src/bootstrap_priv.h | 32 +- launchd/src/com.apple.SystemStarter.plist | 12 +- launchd/src/config.h | 3 +- launchd/src/launch.h | 6 + launchd/src/launch_internal.h | 37 + launchd/src/launch_priv.h | 43 +- launchd/src/launchctl.c | 712 ++-- launchd/src/launchd.c | 196 +- launchd/src/launchd.h | 1 - launchd/src/launchd.plist.5 | 12 - launchd/src/launchd_core_logic.c | 4514 ++++++++++++++------- launchd/src/launchd_core_logic.h | 2 +- launchd/src/launchd_helper.defs | 24 + launchd/src/launchd_internal.defs | 8 +- launchd/src/launchd_ktrace.h | 2 +- launchd/src/launchd_mig_types.defs | 1 + launchd/src/launchd_runtime.c | 270 +- launchd/src/launchd_runtime.h | 16 +- launchd/src/launchd_unix_ipc.c | 36 +- launchd/src/launchd_unix_ipc.h | 1 + launchd/src/launchproxy.c | 34 +- launchd/src/libbootstrap.c | 87 +- launchd/src/liblaunch.c | 122 +- launchd/src/libvproc.c | 324 +- launchd/src/protocol_job_forward.defs | 23 +- launchd/src/protocol_job_reply.defs | 45 +- launchd/src/protocol_vproc.defs | 448 +- launchd/src/rc.netboot | 4 +- launchd/src/vproc.h | 4 +- launchd/src/vproc_internal.h | 5 +- launchd/src/vproc_priv.h | 82 +- 39 files changed, 4610 insertions(+), 2717 deletions(-) create mode 100644 launchd/src/launchd_helper.defs diff --git a/launchd.xcodeproj/project.pbxproj b/launchd.xcodeproj/project.pbxproj index 5b20b53..0218d29 100644 --- a/launchd.xcodeproj/project.pbxproj +++ b/launchd.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ @@ -50,6 +50,8 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 4B0A3103131F266E002DE2E5 /* events.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B0A30FF131F24AC002DE2E5 /* events.defs */; settings = {ATTRIBUTES = (Server, ); }; }; + 4B0FB8EA1241FE3F00383109 /* domain.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B0FB8E91241FE3F00383109 /* domain.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 4B10F1B90F43BE7E00875782 /* launchd_internal.defs in Sources */ = {isa = PBXBuildFile; fileRef = FC59A0BD0E8C8A2A00D41150 /* launchd_internal.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; }; 4B10F1BA0F43BE7E00875782 /* protocol_vproc.defs in Sources */ = {isa = PBXBuildFile; fileRef = FC3627DF0E9344BF0054F1A3 /* protocol_vproc.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; }; 4B10F1BB0F43BE7E00875782 /* protocol_job_reply.defs in Sources */ = {isa = PBXBuildFile; fileRef = FC3629160E9348390054F1A3 /* protocol_job_reply.defs */; }; @@ -74,9 +76,13 @@ 4B10F1EC0F43BF5C00875782 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FCD713730E95DE49001B0111 /* libedit.dylib */; settings = {ATTRIBUTES = (Weak, ); }; }; 4B10F1EF0F43BF5C00875782 /* launchctl.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FC59A0AD0E8C8A0E00D41150 /* launchctl.1 */; }; 4B1D92010F8BDE7D00125940 /* launchd.ops in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B1D91ED0F8BDE1A00125940 /* launchd.ops */; }; + 4B287733111A509400C07B35 /* launchd_helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B287732111A509400C07B35 /* launchd_helper.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; }; + 4B28781B111A61A400C07B35 /* launchd_helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B287732111A509400C07B35 /* launchd_helper.defs */; }; + 4B9A1C1F132759F700019C67 /* events.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B0A30FF131F24AC002DE2E5 /* events.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 4B9EDCA20EAFC77E00A78496 /* DiskArbitration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9EDCA10EAFC77E00A78496 /* DiskArbitration.framework */; }; + 4BA2F5FD1243063D00C2AADD /* init.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4BA2F5FC1243063D00C2AADD /* init.defs */; }; + 4BF8727C1187A5F000CC7DB5 /* launchd_helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 4B287732111A509400C07B35 /* launchd_helper.defs */; }; 7215DE4C0EFAF2EC00ABD81E /* libauditd.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7215DE4B0EFAF2EC00ABD81E /* libauditd.dylib */; }; - 721FBEBC0EA7AE2F0057462B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 721FBEBB0EA7AE2F0057462B /* Security.framework */; }; 726055EC0EA7EC2400D65FE7 /* mach_exc.defs in Sources */ = {isa = PBXBuildFile; fileRef = FC36291F0E9349410054F1A3 /* mach_exc.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 726056090EA7FCF200D65FE7 /* launchd_ktrace.c in Sources */ = {isa = PBXBuildFile; fileRef = 72FDB15D0EA7D7B200B2AC84 /* launchd_ktrace.c */; }; 72AFE8090EFAF3D9004BDA46 /* libauditd.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7215DE4B0EFAF2EC00ABD81E /* libauditd.dylib */; }; @@ -365,25 +371,29 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 4B0A30FF131F24AC002DE2E5 /* events.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = events.defs; path = /usr/local/include/xpc/events.defs; sourceTree = SDKROOT; }; + 4B0A3100131F24AC002DE2E5 /* types.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = types.defs; path = /usr/local/include/xpc/types.defs; sourceTree = SDKROOT; }; + 4B0FB8E91241FE3F00383109 /* domain.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = domain.defs; path = /usr/local/include/xpc/domain.defs; sourceTree = SDKROOT; }; 4B10F1D30F43BE7E00875782 /* launchd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = launchd; sourceTree = BUILT_PRODUCTS_DIR; }; 4B10F1F30F43BF5C00875782 /* launchctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = launchctl; sourceTree = BUILT_PRODUCTS_DIR; }; 4B1D91ED0F8BDE1A00125940 /* launchd.ops */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = launchd.ops; path = launchd/src/launchd.ops; sourceTree = ""; }; + 4B287732111A509400C07B35 /* launchd_helper.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = launchd_helper.defs; path = launchd/src/launchd_helper.defs; sourceTree = ""; }; 4B9EDCA10EAFC77E00A78496 /* DiskArbitration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DiskArbitration.framework; path = /System/Library/Frameworks/DiskArbitration.framework; sourceTree = ""; }; + 4BA2F5FC1243063D00C2AADD /* init.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = init.defs; path = /usr/local/include/xpc/init.defs; sourceTree = SDKROOT; }; 7215DE4B0EFAF2EC00ABD81E /* libauditd.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libauditd.dylib; path = /usr/lib/libauditd.dylib; sourceTree = ""; }; 721FBEA50EA7ABC40057462B /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = launchd/src/config.h; sourceTree = ""; }; - 721FBEBB0EA7AE2F0057462B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; 72FDB15D0EA7D7B200B2AC84 /* launchd_ktrace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = launchd_ktrace.c; path = launchd/src/launchd_ktrace.c; sourceTree = ""; }; 72FDB15E0EA7D7B200B2AC84 /* launchd_ktrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = launchd_ktrace.h; path = launchd/src/launchd_ktrace.h; sourceTree = ""; }; 72FDB1BF0EA7E21C00B2AC84 /* protocol_job_forward.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = protocol_job_forward.defs; path = launchd/src/protocol_job_forward.defs; sourceTree = ""; }; FC3627DF0E9344BF0054F1A3 /* protocol_vproc.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = protocol_vproc.defs; path = launchd/src/protocol_vproc.defs; sourceTree = ""; }; FC3628070E9345E10054F1A3 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; FC36283E0E93463C0054F1A3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; - FC36290C0E93475F0054F1A3 /* notify.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = notify.defs; path = /usr/include/mach/notify.defs; sourceTree = ""; }; + FC36290C0E93475F0054F1A3 /* notify.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = notify.defs; path = /usr/include/mach/notify.defs; sourceTree = SDKROOT; }; FC3629160E9348390054F1A3 /* protocol_job_reply.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = protocol_job_reply.defs; path = launchd/src/protocol_job_reply.defs; sourceTree = ""; }; - FC36291F0E9349410054F1A3 /* mach_exc.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = mach_exc.defs; path = /usr/include/mach/mach_exc.defs; sourceTree = ""; }; + FC36291F0E9349410054F1A3 /* mach_exc.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = mach_exc.defs; path = /usr/include/mach/mach_exc.defs; sourceTree = SDKROOT; }; FC36292C0E934AA40054F1A3 /* libbsm.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbsm.dylib; path = /usr/lib/libbsm.dylib; sourceTree = ""; }; FC59A0540E8C884700D41150 /* launchd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = launchd; sourceTree = BUILT_PRODUCTS_DIR; }; - FC59A0600E8C885100D41150 /* liblaunch.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblaunch.a; sourceTree = BUILT_PRODUCTS_DIR; }; + FC59A0600E8C885100D41150 /* liblaunch.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = liblaunch.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; FC59A06D0E8C888A00D41150 /* launchctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = launchctl; sourceTree = BUILT_PRODUCTS_DIR; }; FC59A0910E8C892300D41150 /* SystemStarter */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SystemStarter; sourceTree = BUILT_PRODUCTS_DIR; }; FC59A0A40E8C89C100D41150 /* IPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IPC.h; path = launchd/src/IPC.h; sourceTree = SOURCE_ROOT; }; @@ -499,7 +509,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 721FBEBC0EA7AE2F0057462B /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -513,6 +522,26 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 4B0A3102131F24B3002DE2E5 /* XPC */ = { + isa = PBXGroup; + children = ( + 4B0A3100131F24AC002DE2E5 /* types.defs */, + 4B0FB8E91241FE3F00383109 /* domain.defs */, + 4B0A30FF131F24AC002DE2E5 /* events.defs */, + 4BA2F5FC1243063D00C2AADD /* init.defs */, + ); + name = XPC; + sourceTree = ""; + }; + 4B8D8239132C5F400081FD4E /* Mach */ = { + isa = PBXGroup; + children = ( + FC36291F0E9349410054F1A3 /* mach_exc.defs */, + FC36290C0E93475F0054F1A3 /* notify.defs */, + ); + name = Mach; + sourceTree = ""; + }; 4B9EDCD60EAFD11000A78496 /* MIG */ = { isa = PBXGroup; children = ( @@ -521,8 +550,7 @@ FC3629160E9348390054F1A3 /* protocol_job_reply.defs */, FC3627DF0E9344BF0054F1A3 /* protocol_vproc.defs */, FC59A0BD0E8C8A2A00D41150 /* launchd_internal.defs */, - FC36291F0E9349410054F1A3 /* mach_exc.defs */, - FC36290C0E93475F0054F1A3 /* notify.defs */, + 4B287732111A509400C07B35 /* launchd_helper.defs */, ); name = MIG; sourceTree = ""; @@ -571,7 +599,6 @@ isa = PBXGroup; children = ( 4B9EDCA10EAFC77E00A78496 /* DiskArbitration.framework */, - 721FBEBB0EA7AE2F0057462B /* Security.framework */, FC36292C0E934AA40054F1A3 /* libbsm.dylib */, 7215DE4B0EFAF2EC00ABD81E /* libauditd.dylib */, FCD713730E95DE49001B0111 /* libedit.dylib */, @@ -598,6 +625,8 @@ FC59A04E0E8C883300D41150 /* launchd */ = { isa = PBXGroup; children = ( + 4B8D8239132C5F400081FD4E /* Mach */, + 4B0A3102131F24B3002DE2E5 /* XPC */, 4B9EDCD60EAFD11000A78496 /* MIG */, 4B9EDCD70EAFD14500A78496 /* Source */, 4B9EDCD90EAFD19800A78496 /* rc */, @@ -609,7 +638,7 @@ FC59A0550E8C884700D41150 /* Products */ = { isa = PBXGroup; children = ( - FC59A0600E8C885100D41150 /* liblaunch.a */, + FC59A0600E8C885100D41150 /* liblaunch.dylib */, FC59A0540E8C884700D41150 /* launchd */, FC59A06D0E8C888A00D41150 /* launchctl */, FC59A0910E8C892300D41150 /* SystemStarter */, @@ -783,8 +812,8 @@ ); name = liblaunch; productName = launchd_libs; - productReference = FC59A0600E8C885100D41150 /* liblaunch.a */; - productType = "com.apple.product-type.library.static"; + productReference = FC59A0600E8C885100D41150 /* liblaunch.dylib */; + productType = "com.apple.product-type.library.dynamic"; }; FC59A06C0E8C888A00D41150 /* launchctl */ = { isa = PBXNativeTarget; @@ -866,9 +895,19 @@ /* Begin PBXProject section */ FC59A03F0E8C87FD00D41150 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; buildConfigurationList = FC59A0420E8C87FD00D41150 /* Build configuration list for PBXProject "launchd" */; - compatibilityVersion = "Xcode 2.4"; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 0; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = FC59A03D0E8C87FD00D41150; productRefGroup = FC59A0550E8C884700D41150 /* Products */; projectDirPath = ""; @@ -1009,6 +1048,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4B9A1C1F132759F700019C67 /* events.defs in Sources */, + 4BF8727C1187A5F000CC7DB5 /* launchd_helper.defs in Sources */, 4B10F1B90F43BE7E00875782 /* launchd_internal.defs in Sources */, 4B10F1BA0F43BE7E00875782 /* protocol_vproc.defs in Sources */, 4B10F1BB0F43BE7E00875782 /* protocol_job_reply.defs in Sources */, @@ -1036,18 +1077,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4B28781B111A61A400C07B35 /* launchd_helper.defs in Sources */, FC59A0BF0E8C8A2A00D41150 /* launchd_internal.defs in Sources */, FC3627E10E9344BF0054F1A3 /* protocol_vproc.defs in Sources */, FC3629170E9348390054F1A3 /* protocol_job_reply.defs in Sources */, 726055EC0EA7EC2400D65FE7 /* mach_exc.defs in Sources */, FC36290D0E93475F0054F1A3 /* notify.defs in Sources */, + 4B0FB8EA1241FE3F00383109 /* domain.defs in Sources */, + 4B0A3103131F266E002DE2E5 /* events.defs in Sources */, + 4BA2F5FD1243063D00C2AADD /* init.defs in Sources */, + 72FDB1C00EA7E21C00B2AC84 /* protocol_job_forward.defs in Sources */, FC59A0C50E8C8A4700D41150 /* launchd.c in Sources */, FC59A0BA0E8C8A1F00D41150 /* launchd_runtime.c in Sources */, FC59A0B90E8C8A1F00D41150 /* launchd_runtime_kill.c in Sources */, FC59A0BB0E8C8A1F00D41150 /* launchd_core_logic.c in Sources */, FC59A0B80E8C8A1F00D41150 /* launchd_unix_ipc.c in Sources */, 72FDB15F0EA7D7B200B2AC84 /* launchd_ktrace.c in Sources */, - 72FDB1C00EA7E21C00B2AC84 /* protocol_job_forward.defs in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1060,6 +1105,7 @@ FC59A0F70E8C8AA600D41150 /* libbootstrap.c in Sources */, FC3627E00E9344BF0054F1A3 /* protocol_vproc.defs in Sources */, 726056090EA7FCF200D65FE7 /* launchd_ktrace.c in Sources */, + 4B287733111A509400C07B35 /* launchd_helper.defs in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1156,33 +1202,22 @@ 4B10F1D20F43BE7E00875782 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + __LAUNCH_DISABLE_XPC_SUPPORT__, + XPC_BUILDING_LAUNCHD, + ); + HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/local/include"; INSTALL_PATH = /sbin; - PREBINDING = NO; + OTHER_MIGFLAGS = "-DXPC_BUILDING_LAUNCHD -I$(PROJECT_DIR)/launchd/src/ -I$(SDKROOT)/usr/local/include"; PRODUCT_NAME = launchd; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; 4B10F1F20F43BF5C00875782 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; INSTALL_PATH = /bin; - PREBINDING = NO; PRODUCT_NAME = launchctl; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; @@ -1191,7 +1226,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = embedded; ZERO_LINK = NO; }; @@ -1201,7 +1235,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)"; DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = ""; GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; @@ -1214,73 +1250,80 @@ "-Dmig_external=__private_extern__", "-D_DARWIN_USE_64_BIT_INODE=1", ); + STRIP_STYLE = all; + VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = ( "-Wall", "-Wextra", "-Waggregate-return", "-Wmissing-declarations", ); + ZERO_LINK = NO; }; name = Release; }; FC59A0580E8C884800D41150 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PREPROCESSOR_DEFINITIONS = ""; + HEADER_SEARCH_PATHS = ""; INSTALL_PATH = /sbin; - PREBINDING = NO; + OTHER_CFLAGS = ( + "-D__MigTypeCheck=1", + "-Dmig_external=__private_extern__", + "-D_DARWIN_USE_64_BIT_INODE=1", + ); + OTHER_MIGFLAGS = "-DXPC_BUILDING_LAUNCHD -I$(PROJECT_DIR)/launchd/src/"; PRODUCT_NAME = launchd; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; FC59A0620E8C885100D41150 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; BUILD_VARIANTS = ( normal, debug, profile, ); - COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)"; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + CRASHREPORTER_LINKER_FLAGS = ""; + "CRASHREPORTER_LINKER_FLAGS[sdk=macosx*][arch=*]" = "-lCrashReporterClient"; + "CRASHREPORTER_LINKER_FLAGS[sdk=macosx10.6][arch=*]" = ""; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; + EXECUTABLE_PREFIX = lib; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_PATH = /usr/local/lib/system; + INSTALL_PATH = /usr/lib/system; + LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)"; OTHER_CFLAGS = ( "-D__MigTypeCheck=1", "-Dmig_external=__private_extern__", "-D__DARWIN_NON_CANCELABLE=1", "-D_DARWIN_USE_64_BIT_INODE=1", ); + OTHER_LDFLAGS = ( + "-Wl,-umbrella,System", + "$(CRASHREPORTER_LINKER_FLAGS)", + ); PRODUCT_NAME = launch; PUBLIC_HEADERS_FOLDER_PATH = /usr/include; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = __; + STRIP_INSTALLED_PRODUCT = YES; + STRIP_STYLE = "non-global"; + VERSION_INFO_PREFIX = _; }; name = Release; }; FC59A0700E8C888A00D41150 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_DYNAMIC_NO_PIC = NO; INSTALL_PATH = /bin; - PREBINDING = NO; PRODUCT_NAME = launchctl; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; @@ -1289,7 +1332,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = default; ZERO_LINK = NO; }; @@ -1300,7 +1342,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = launchd_libs; ZERO_LINK = NO; }; @@ -1309,48 +1350,31 @@ FC59A0940E8C892400D41150 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_DYNAMIC_NO_PIC = NO; INSTALL_PATH = /sbin; - PREBINDING = NO; PRODUCT_NAME = SystemStarter; - STRIP_STYLE = debugging; - VALID_ARCHS = "i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; + VALID_ARCHS = "i386 x86_64"; }; name = Release; }; FC59A0D10E8C8A5C00D41150 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_DYNAMIC_NO_PIC = NO; INSTALL_PATH = /usr/libexec; - PREBINDING = NO; PRODUCT_NAME = launchproxy; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; FCD7132E0E95D64E001B0111 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_DYNAMIC_NO_PIC = NO; INSTALL_PATH = /bin; - PREBINDING = NO; PRODUCT_NAME = wait4path; - STRIP_STYLE = debugging; - VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; - ZERO_LINK = NO; }; name = Release; }; diff --git a/launchd/src/IPC.h b/launchd/src/IPC.h index d85a482..b28226c 100644 --- a/launchd/src/IPC.h +++ b/launchd/src/IPC.h @@ -35,4 +35,4 @@ **/ void MonitorStartupItem (StartupContext aStartupContext, CFMutableDictionaryRef anItem); -#endif /* _IPC_H_ */ +#endif diff --git a/launchd/src/StartupItems.c b/launchd/src/StartupItems.c index 18677b1..9fc2325 100644 --- a/launchd/src/StartupItems.c +++ b/launchd/src/StartupItems.c @@ -183,7 +183,6 @@ static void SpecialCasesStartupItemHandler(CFMutableDictionaryRef aConfig) break; } if (*c == NULL) { - CFRetain(ci); CFArrayAppendValue(aNewList, ci); CF_syslog(LOG_DEBUG, CFSTR("%@: Keeping %@"), type, ci); } @@ -441,7 +440,7 @@ CFMutableDictionaryRef StartupItemListGetProvider(CFArrayRef anItemList, CFStrin return aResult; } -CFArrayRef StartupItemListGetRunning(CFArrayRef anItemList) +CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList) { CFMutableArrayRef aResult = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); if (aResult) { @@ -837,7 +836,7 @@ CFMutableDictionaryRef StartupItemListGetNext(CFArrayRef aWaitingList, CFDiction return aNextItem; } -CFStringRef StartupItemGetDescription(CFMutableDictionaryRef anItem) +CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem) { CFStringRef aString = NULL; diff --git a/launchd/src/StartupItems.h b/launchd/src/StartupItems.h index d367340..5cf6c08 100644 --- a/launchd/src/StartupItems.h +++ b/launchd/src/StartupItems.h @@ -81,12 +81,12 @@ CFMutableDictionaryRef StartupItemListGetNext (CFArrayRef aWaitingList, CFMutableDictionaryRef StartupItemWithPID (CFArrayRef anItemList, pid_t aPID); pid_t StartupItemGetPID(CFDictionaryRef anItem); -CFStringRef StartupItemGetDescription(CFMutableDictionaryRef anItem); +CFStringRef StartupItemCreateDescription(CFMutableDictionaryRef anItem); /* * Returns a list of currently executing startup items. */ -CFArrayRef StartupItemListGetRunning(CFArrayRef anItemList); +CFArrayRef StartupItemListCreateFromRunning(CFArrayRef anItemList); /* * Returns the total number of "Provides" entries of all loaded items. @@ -112,4 +112,4 @@ void StartupItemSetStatus(CFMutableDictionaryRef aStatusDict, CFMutableDictionar */ bool StartupItemSecurityCheck(const char *aPath); -#endif /* _StartupItems_H_ */ +#endif diff --git a/launchd/src/SystemStarter.c b/launchd/src/SystemStarter.c index fb93db7..02663f8 100644 --- a/launchd/src/SystemStarter.c +++ b/launchd/src/SystemStarter.c @@ -191,10 +191,10 @@ checkForActivity(StartupContext aStartupContext) aWaitingForString = CFSTR("Waiting for %@"); } if (aLastStatusDictionaryCount == aCount) { - CFArrayRef aRunningList = StartupItemListGetRunning(aStartupContext->aWaitingList); + CFArrayRef aRunningList = StartupItemListCreateFromRunning(aStartupContext->aWaitingList); if (aRunningList && CFArrayGetCount(aRunningList) > 0) { CFMutableDictionaryRef anItem = (CFMutableDictionaryRef) CFArrayGetValueAtIndex(aRunningList, 0); - CFStringRef anItemDescription = StartupItemGetDescription(anItem); + CFStringRef anItemDescription = StartupItemCreateDescription(anItem); CFStringRef aString = aWaitingForString && anItemDescription ? CFStringCreateWithFormat(NULL, NULL, aWaitingForString, anItemDescription) : NULL; @@ -377,7 +377,7 @@ CF_syslog(int level, CFStringRef message,...) va_end(ap); if (CFStringGetCString(cooked_msg, buf, sizeof(buf), kCFStringEncodingUTF8)) - syslog(level, buf); + syslog(level, "%s", buf); CFRelease(cooked_msg); } diff --git a/launchd/src/SystemStarter.h b/launchd/src/SystemStarter.h index 6a6c0ab..417d307 100644 --- a/launchd/src/SystemStarter.h +++ b/launchd/src/SystemStarter.h @@ -48,4 +48,4 @@ typedef enum { void CF_syslog(int level, CFStringRef message, ...); extern bool gVerboseFlag; -#endif /* _SYSTEM_STARTER_H_ */ +#endif diff --git a/launchd/src/SystemStarterIPC.h b/launchd/src/SystemStarterIPC.h index 3a94095..9dc0023 100644 --- a/launchd/src/SystemStarterIPC.h +++ b/launchd/src/SystemStarterIPC.h @@ -85,4 +85,4 @@ typedef struct SystemStarterIPCMessage { #define kIPCConfigSettingVerboseFlag CFSTR("VerboseFlag") #define kIPCConfigSettingNetworkUp CFSTR("NetworkUp") -#endif /* _SYSTEM_STARTER_IPC_H */ +#endif diff --git a/launchd/src/bootstrap.h b/launchd/src/bootstrap.h index 15f3248..f09f82f 100644 --- a/launchd/src/bootstrap.h +++ b/launchd/src/bootstrap.h @@ -293,9 +293,9 @@ bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp); * bootstrap_check_in() * * Returns the receive right for the service named by service_name. The - * service must have previously been declared in this bootstrap context via - * a call to bootstrap_create_service(). Attempts to check_in a service - * which is already active are not allowed. + * service must have been declared in the launchd.plist(5) file associated + * with the job. Attempts to check_in a service which is already active + * are not allowed. * * If the service was declared as being associated with a server, the * check_in must come from the server's privileged port (server_port). diff --git a/launchd/src/bootstrap_priv.h b/launchd/src/bootstrap_priv.h index 121e9e9..54d443e 100644 --- a/launchd/src/bootstrap_priv.h +++ b/launchd/src/bootstrap_priv.h @@ -22,21 +22,29 @@ #include #include +#include __BEGIN_DECLS #pragma GCC visibility push(default) -#define BOOTSTRAP_PER_PID_SERVICE 1 << 0 -#define BOOTSTRAP_ALLOW_LOOKUP 1 << 1 -#define BOOTSTRAP_DENY_JOB_CREATION 1 << 2 -#define BOOTSTRAP_PRIVILEGED_SERVER 1 << 3 -#define BOOTSTRAP_FORCE_LOCAL 1 << 4 +#define BOOTSTRAP_PER_PID_SERVICE (1 << 0) +#define BOOTSTRAP_ALLOW_LOOKUP (1 << 1) +#define BOOTSTRAP_DENY_JOB_CREATION (1 << 2) +#define BOOTSTRAP_PRIVILEGED_SERVER (1 << 3) +#define BOOTSTRAP_FORCE_LOCAL (1 << 4) +#define BOOTSTRAP_SPECIFIC_INSTANCE (1 << 5) +#define BOOTSTRAP_STRICT_CHECKIN (1 << 6) +#define BOOTSTRAP_STRICT_LOOKUP (1 << 7) -#define BOOTSTRAP_PROPERTY_EXPLICITSUBSET 1 << 0 /* Created via bootstrap_subset(). */ -#define BOOTSTRAP_PROPERTY_IMPLICITSUBSET 1 << 1 /* Created via _vprocmgr_switch_to_session(). */ -#define BOOTSTRAP_PROPERTY_MOVEDSUBSET 1 << 2 /* Created via _vprocmgr_move_subset_to_user(). */ -#define BOOTSTRAP_PROPERTY_PERUSER 1 << 3 /* A per-user launchd's root bootstrap. */ +#define BOOTSTRAP_PROPERTY_EXPLICITSUBSET (1 << 0) /* Created via bootstrap_subset(). */ +#define BOOTSTRAP_PROPERTY_IMPLICITSUBSET (1 << 1) /* Created via _vprocmgr_switch_to_session(). */ +#define BOOTSTRAP_PROPERTY_MOVEDSUBSET (1 << 2) /* Created via _vprocmgr_move_subset_to_user(). */ +#define BOOTSTRAP_PROPERTY_PERUSER (1 << 3) /* A per-user launchd's root bootstrap. */ +#define BOOTSTRAP_PROPERTY_XPC_DOMAIN (1 << 4) /* An XPC domain. Duh. */ +#define BOOTSTRAP_PROPERTY_XPC_SINGLETON (1 << 5) /* A singleton XPC domain. */ + +void bootstrap_init(void); kern_return_t bootstrap_register2(mach_port_t bp, name_t service_name, mach_port_t sp, uint64_t flags); @@ -48,6 +56,12 @@ kern_return_t bootstrap_look_up_per_user(mach_port_t bp, const name_t service_na kern_return_t bootstrap_lookup_children(mach_port_t bp, mach_port_array_t *children, name_array_t *names, bootstrap_property_array_t *properties, mach_msg_type_number_t *n_children); +kern_return_t bootstrap_look_up3(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags); + +kern_return_t bootstrap_check_in3(mach_port_t bp, const name_t service_name, mach_port_t *sp, uuid_t instance_id, uint64_t flags); + +kern_return_t bootstrap_get_root(mach_port_t bp, mach_port_t *root); + #pragma GCC visibility pop __END_DECLS diff --git a/launchd/src/com.apple.SystemStarter.plist b/launchd/src/com.apple.SystemStarter.plist index ffac1a3..8ab51c7 100644 --- a/launchd/src/com.apple.SystemStarter.plist +++ b/launchd/src/com.apple.SystemStarter.plist @@ -1,11 +1,7 @@ - + - Label - com.apple.SystemStarter - Program - /sbin/SystemStarter KeepAlive PathState @@ -16,12 +12,14 @@ + Label + com.apple.SystemStarter + Program + /sbin/SystemStarter QueueDirectories /Library/StartupItems /System/Library/StartupItems - HopefullyExitsFirst - diff --git a/launchd/src/config.h b/launchd/src/config.h index 23b1706..9f46ab6 100644 --- a/launchd/src/config.h +++ b/launchd/src/config.h @@ -3,6 +3,5 @@ #include #define HAVE_QUARANTINE TARGET_HAVE_QUARANTINE #define HAVE_SANDBOX TARGET_HAVE_SANDBOX -#define HAVE_SECURITY !TARGET_HAVE_EMBEDDED_SECURITY #define HAVE_LIBAUDITD !TARGET_OS_EMBEDDED -#endif /* __CONFIG_H__ */ +#endif diff --git a/launchd/src/launch.h b/launchd/src/launch.h index d8ed302..61bf323 100644 --- a/launchd/src/launch.h +++ b/launchd/src/launch.h @@ -71,6 +71,8 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" #define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" #define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" +#define LAUNCH_JOBKEY_LIMITLOADTOHARDWARE "LimitLoadToHardware" +#define LAUNCH_JOBKEY_LIMITLOADFROMHARDWARE "LimitLoadFromHardware" #define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" #define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" #define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" @@ -111,6 +113,7 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" #define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" #define LAUNCH_JOBKEY_MACH_DRAINMESSAGESONCRASH "DrainMessagesOnCrash" +#define LAUNCH_JOBKEY_MACH_PINGEVENTUPDATES "PingEventUpdates" #define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" #define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" @@ -118,6 +121,9 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBACTIVE "OtherJobActive" #define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBENABLED "OtherJobEnabled" #define LAUNCH_JOBKEY_KEEPALIVE_AFTERINITIALDEMAND "AfterInitialDemand" +#define LAUNCH_JOBKEY_KEEPALIVE_CRASHED "Crashed" + +#define LAUNCH_JOBKEY_LAUNCHEVENTS "LaunchEvents" #define LAUNCH_JOBKEY_CAL_MINUTE "Minute" #define LAUNCH_JOBKEY_CAL_HOUR "Hour" diff --git a/launchd/src/launch_internal.h b/launchd/src/launch_internal.h index c0642f1..46c1725 100644 --- a/launchd/src/launch_internal.h +++ b/launchd/src/launch_internal.h @@ -24,6 +24,43 @@ #define LAUNCHD_DB_PREFIX "/var/db/launchd.db" +struct _launch_data { + uint64_t type; + union { + struct { + union { + launch_data_t *_array; + char *string; + void *opaque; + int64_t __junk; + }; + union { + uint64_t _array_cnt; + uint64_t string_len; + uint64_t opaque_size; + }; + }; + int64_t fd; + uint64_t mp; + uint64_t err; + int64_t number; + uint64_t boolean; /* We'd use 'bool' but this struct needs to be used under Rosetta, and sizeof(bool) is different between PowerPC and Intel */ + double float_num; + }; +}; + +typedef struct _launch *launch_t; + +launch_t launchd_fdopen(int, int); +int launchd_getfd(launch_t); +void launchd_close(launch_t, __typeof__(close) closefunc); + +launch_data_t launch_data_new_errno(int); +bool launch_data_set_errno(launch_data_t, int); + +int launchd_msg_send(launch_t, launch_data_t); +int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); + size_t launch_data_pack(launch_data_t d, void *where, size_t len, int *fd_where, size_t *fdslotsleft); launch_data_t launch_data_unpack(void *data, size_t data_size, int *fds, size_t fd_cnt, size_t *data_offset, size_t *fdoffset); diff --git a/launchd/src/launch_priv.h b/launchd/src/launch_priv.h index e19df70..1f5c156 100644 --- a/launchd/src/launch_priv.h +++ b/launchd/src/launch_priv.h @@ -58,12 +58,19 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_JETSAMPRIORITY "JetsamPriority" #define LAUNCH_JOBKEY_JETSAMMEMORYLIMIT "JetsamMemoryLimit" #define LAUNCH_JOBKEY_SECURITYSESSIONUUID "SecuritySessionUUID" +#define LAUNCH_JOBKEY_DISABLEASLR "DisableASLR" +#define LAUNCH_JOBKEY_XPCDOMAIN "XPCDomain" +#define LAUNCH_JOBKEY_POSIXSPAWNTYPE "POSIXSpawnType" #define LAUNCH_KEY_JETSAMLABEL "JetsamLabel" #define LAUNCH_KEY_JETSAMFRONTMOST "JetsamFrontmost" #define LAUNCH_KEY_JETSAMPRIORITY LAUNCH_JOBKEY_JETSAMPRIORITY #define LAUNCH_KEY_JETSAMMEMORYLIMIT LAUNCH_JOBKEY_JETSAMMEMORYLIMIT +#define LAUNCH_KEY_POSIXSPAWNTYPE_TALAPP "TALApp" +#define LAUNCH_KEY_POSIXSPAWNTYPE_WIDGET "Widget" +#define LAUNCH_KEY_POSIXSPAWNTYPE_IOSAPP "iOSApp" + #define LAUNCH_JOBKEY_EMBEDDEDPRIVILEGEDISPENSATION "EmbeddedPrivilegeDispensation" #define LAUNCH_JOBKEY_EMBEDDEDMAINTHREADPRIORITY "EmbeddedMainThreadPriority" @@ -72,6 +79,10 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC" #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference" #define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER "MachExceptionHandler" +#define LAUNCH_JOBKEY_MULTIPLEINSTANCES "MultipleInstances" +#define LAUNCH_JOBKEY_EVENTMONITOR "EventMonitor" +#define LAUNCH_JOBKEY_SHUTDOWNMONITOR "ShutdownMonitor" +#define LAUNCH_JOBKEY_BEGINTRANSACTIONATSHUTDOWN "BeginTransactionAtShutdown" #define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" #define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" @@ -79,17 +90,7 @@ __BEGIN_DECLS #define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" #define LAUNCH_JOBKEY_MACH_ENTERKERNELDEBUGGERONCLOSE "EnterKernelDebuggerOnClose" -typedef struct _launch *launch_t; - -launch_t launchd_fdopen(int, int); -int launchd_getfd(launch_t); -void launchd_close(launch_t, __typeof__(close) closefunc); - -launch_data_t launch_data_new_errno(int); -bool launch_data_set_errno(launch_data_t, int); - -int launchd_msg_send(launch_t, launch_data_t); -int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); +#define LAUNCH_ENV_INSTANCEID "LaunchInstanceID" /* For LoginWindow. * @@ -107,20 +108,13 @@ pid_t create_and_switch_to_per_session_launchd(const char * /* loginname */, int */ void load_launchd_jobs_at_loginwindow_prompt(int flags, ...); - -/* batch jobs will be implicity re-enabled when the last application who - * disabled them exits. - * - * This API is really a hack to work around the lack of real-time APIs - * at the VFS layer. - */ -void launchd_batch_enable(bool); -bool launchd_batch_query(void); - /* For CoreProcesses */ -#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 +#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 +#define SPAWN_VIA_LAUNCHD_TALAPP 0x0002 +#define SPAWN_VIA_LAUNCHD_WIDGET 0x0004 +#define SPAWN_VIA_LAUNCHD_DISABLE_ASLR 0x0008 struct spawn_via_launchd_attr { uint64_t spawn_flags; @@ -136,18 +130,19 @@ struct spawn_via_launchd_attr { const uint64_t * spawn_seatbelt_flags; }; -#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 2) +#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 3) pid_t _spawn_via_launchd( const char *label, const char *const *argv, const struct spawn_via_launchd_attr *spawn_attrs, int struct_version); +int launch_wait(mach_port_t port); + kern_return_t mpm_wait(mach_port_t ajob, int *wstatus); kern_return_t mpm_uncork_fork(mach_port_t ajob); - __END_DECLS #pragma GCC visibility pop diff --git a/launchd/src/launchctl.c b/launchd/src/launchctl.c index fd1381e..3b86dcc 100644 --- a/launchd/src/launchctl.c +++ b/launchd/src/launchctl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2005-2010 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * @@ -18,7 +18,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -static const char *const __rcs_file_version__ = "$Revision: 23930 $"; +static const char *const __rcs_file_version__ = "$Revision: 24957 $"; #include "config.h" #include "launch.h" @@ -34,10 +34,6 @@ static const char *const __rcs_file_version__ = "$Revision: 23930 $"; #include #include #include -#if HAVE_SECURITY -#include -#include -#endif #include #include #include @@ -65,6 +61,7 @@ static const char *const __rcs_file_version__ = "$Revision: 23930 $"; #include #include #include +#include #include #include #include @@ -83,6 +80,7 @@ static const char *const __rcs_file_version__ = "$Revision: 23930 $"; #include #include #include +#include #if HAVE_LIBAUDITD #include @@ -95,6 +93,7 @@ extern char **environ; #define LAUNCH_SECDIR _PATH_TMP "launch-XXXXXX" +#define LAUNCH_ENV_KEEPCONTEXT "LaunchKeepContext" #define MACHINIT_JOBKEY_ONDEMAND "OnDemand" #define MACHINIT_JOBKEY_SERVICENAME "ServiceName" @@ -108,7 +107,6 @@ extern char **environ; #define CFTypeCheck(cf, type) (CFGetTypeID(cf) == type ## GetTypeID()) struct load_unload_state { - launch_data_t pass0; launch_data_t pass1; launch_data_t pass2; char *session_type; @@ -137,13 +135,10 @@ static int _fd(int); static int demux_cmd(int argc, char *const argv[]); static launch_data_t do_rendezvous_magic(const struct addrinfo *res, const char *serv); static void submit_job_pass(launch_data_t jobs); -static void submit_mach_jobs(launch_data_t jobs); -static void let_go_of_mach_jobs(launch_data_t jobs); static void do_mgroup_join(int fd, int family, int socktype, int protocol, const char *mgroup); static mach_port_t str2bsport(const char *s); static void print_jobs(launch_data_t j, const char *key, void *context); static void print_obj(launch_data_t obj, const char *key, void *context); -static bool is_legacy_mach_job(launch_data_t obj); static bool delay_to_second_pass(launch_data_t o); static void delay_to_second_pass2(launch_data_t o, const char *key, void *context); static bool str2lim(const char *buf, rlim_t *res); @@ -215,6 +210,7 @@ static int bstree_cmd(int argc __attribute__((unused)), char * const argv[] __at static int managerpid_cmd(int argc __attribute__((unused)), char * const argv[] __attribute__((unused))); static int manageruid_cmd(int argc __attribute__((unused)), char * const argv[] __attribute__((unused))); static int managername_cmd(int argc __attribute__((unused)), char * const argv[] __attribute__((unused))); +static int asuser_cmd(int argc, char * const argv[]); static int exit_cmd(int argc, char *const argv[]) __attribute__((noreturn)); static int help_cmd(int argc, char *const argv[]); @@ -251,6 +247,7 @@ static const struct { { "managerpid", managerpid_cmd, "Print the PID of the launchd managing this Mach bootstrap." }, { "manageruid", manageruid_cmd, "Print the UID of the launchd managing this Mach bootstrap." }, { "managername", managername_cmd, "Print the name of this Mach bootstrap." }, + { "asuser", asuser_cmd, "Execute a subcommand in the given user's context." }, { "exit", exit_cmd, "Exit the interactive invocation of launchctl" }, { "quit", exit_cmd, "Quit the interactive invocation of launchctl" }, { "help", help_cmd, "This help output" }, @@ -265,6 +262,7 @@ static bool rootuser_context; static bool bootstrapping_system; static bool bootstrapping_peruser; static bool g_verbose_boot = false; +static bool g_startup_debugging = false; static bool g_job_overrides_db_has_changed = false; static CFMutableDictionaryRef g_job_overrides_db = NULL; @@ -298,8 +296,8 @@ main(int argc, char *const argv[]) verbose = true; break; case 'u': - if( argc > 1 ) { - if( strncmp(argv[1], "root", sizeof("root")) == 0 ) { + if (argc > 1) { + if (strncmp(argv[1], "root", sizeof("root")) == 0) { rootuser_context = true; } else { fprintf(stderr, "Unknown user: %s\n", argv[1]); @@ -307,7 +305,7 @@ main(int argc, char *const argv[]) } argc--, argv++; } else { - fprintf(stderr, "-u option requires an argument. Currently, only \"root\" is supported.\n"); + fprintf(stderr, "-u option requires an argument.\n"); } break; case '1': @@ -324,30 +322,30 @@ main(int argc, char *const argv[]) /* Running in the context of the root user's per-user launchd is only supported ... well * in the root user's per-user context. I know it's confusing. I'm genuinely sorry. */ - if( rootuser_context ) { + if (rootuser_context) { int64_t manager_uid = -1, manager_pid = -1; - if( vproc_swap_integer(NULL, VPROC_GSK_MGR_UID, NULL, &manager_uid) == NULL ) { - if( vproc_swap_integer(NULL, VPROC_GSK_MGR_PID, NULL, &manager_pid) == NULL ) { - if( manager_uid || manager_pid == 1 ) { + if (vproc_swap_integer(NULL, VPROC_GSK_MGR_UID, NULL, &manager_uid) == NULL) { + if (vproc_swap_integer(NULL, VPROC_GSK_MGR_PID, NULL, &manager_pid) == NULL) { + if (manager_uid || manager_pid == 1) { fprintf(stderr, "Running in the root user's per-user context is not supported outside of the root user's bootstrap.\n"); exit(EXIT_FAILURE); } } } - } else if( !(system_context || rootuser_context) ) { + } else if (!(system_context || rootuser_context)) { /* Running in the system context is implied when we're running as root and not running as a bootstrapper. */ - system_context = ( !is_managed && getuid() == 0 ); + system_context = (!is_managed && getuid() == 0); } - if( system_context ) { - if( getuid() == 0 ) { + if (system_context) { + if (getuid() == 0) { setup_system_context(); } else { fprintf(stderr, "You must be root to run in the system context.\n"); exit(EXIT_FAILURE); } - } else if( rootuser_context ) { - if( getuid() != 0 ) { + } else if (rootuser_context) { + if (getuid() != 0) { fprintf(stderr, "You must be root to run in the root user context.\n"); exit(EXIT_FAILURE); } @@ -453,7 +451,7 @@ CFPropertyListRef CFPropertyListCreateFromFile(CFURLRef plistURL) CFReadStreamRef plistReadStream = CFReadStreamCreateWithFile(NULL, plistURL); CFErrorRef streamErr = NULL; - if( !CFReadStreamOpen(plistReadStream) ) { + if (!CFReadStreamOpen(plistReadStream)) { streamErr = CFReadStreamCopyError(plistReadStream); CFStringRef errString = CFErrorCopyDescription(streamErr); @@ -464,11 +462,11 @@ CFPropertyListRef CFPropertyListCreateFromFile(CFURLRef plistURL) } CFPropertyListRef plist = NULL; - if( plistReadStream ) { + if (plistReadStream) { CFStringRef errString = NULL; CFPropertyListFormat plistFormat = 0; plist = CFPropertyListCreateFromStream(NULL, plistReadStream, 0, kCFPropertyListImmutable, &plistFormat, &errString); - if( !plist ) { + if (!plist) { CFShow(errString); CFRelease(errString); } @@ -480,7 +478,7 @@ CFPropertyListRef CFPropertyListCreateFromFile(CFURLRef plistURL) return plist; } -#define CFReleaseIfNotNULL(cf) if( cf ) CFRelease(cf); +#define CFReleaseIfNotNULL(cf) if (cf) CFRelease(cf); void read_environment_dot_plist(void) { @@ -494,55 +492,55 @@ read_environment_dot_plist(void) snprintf(plist_path_str, sizeof(plist_path_str), "%s/.MacOSX/environment.plist", getenv("HOME")); struct stat sb; - if( stat(plist_path_str, &sb) == -1 ) { + if (stat(plist_path_str, &sb) == -1) { goto out; } plistPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), plist_path_str); - if( !assumes(plistPath != NULL) ) { + if (!assumes(plistPath != NULL)) { goto out; } plistURL = CFURLCreateWithFileSystemPath(NULL, plistPath, kCFURLPOSIXPathStyle, false); - if( !assumes(plistURL != NULL) ) { + if (!assumes(plistURL != NULL)) { goto out; } envPlist = (CFDictionaryRef)CFPropertyListCreateFromFile(plistURL); - if( !assumes(envPlist != NULL) ) { + if (!assumes(envPlist != NULL)) { goto out; } launch_env_dict = CF2launch_data(envPlist); - if( !assumes(launch_env_dict != NULL) ) { + if (!assumes(launch_env_dict != NULL)) { goto out; } req = launch_data_alloc(LAUNCH_DATA_DICTIONARY); - if( !assumes(req != NULL) ) { + if (!assumes(req != NULL)) { goto out; } launch_data_dict_insert(req, launch_env_dict, LAUNCH_KEY_SETUSERENVIRONMENT); resp = launch_msg(req); - if( !assumes(resp != NULL) ) { + if (!assumes(resp != NULL)) { goto out; } - if( !assumes(launch_data_get_type(resp) == LAUNCH_DATA_ERRNO) ) { + if (!assumes(launch_data_get_type(resp) == LAUNCH_DATA_ERRNO)) { goto out; } - assumes(launch_data_get_errno(resp) == 0); + (void)assumes(launch_data_get_errno(resp) == 0); out: CFReleaseIfNotNULL(plistPath); CFReleaseIfNotNULL(plistURL); CFReleaseIfNotNULL(envPlist); - if( req ) { + if (req) { launch_data_free(req); } - if( resp ) { + if (resp) { launch_data_free(resp); } } @@ -664,24 +662,24 @@ getenv_and_export_cmd(int argc, char *const argv[]) int wait4debugger_cmd(int argc, char * const argv[]) { - if( argc != 3 ) { + if (argc != 3) { fprintf(stderr, "%s usage: debug