Changeset 286624 in webkit
- Timestamp:
- Dec 7, 2021, 2:51:38 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 added
- 1 deleted
- 5 edited
-
ChangeLog (modified) (1 diff)
-
Configurations/webpushd.xcconfig (modified) (1 diff)
-
Scripts/process-entitlements.sh (modified) (3 diffs)
-
WebKit.xcodeproj/project.pbxproj (modified) (5 diffs)
-
webpushd/WebPushDaemonMain.mm (modified) (2 diffs)
-
webpushd/com.apple.webkit.webpushd.ios.plist (added)
-
webpushd/com.apple.webkit.webpushd.mac.plist (added)
-
webpushd/com.apple.webkit.webpushd.plist (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r286609 r286624 1 2021-12-07 Ben Nham <nham@apple.com> 2 3 webpushd should run with regular user permissions 4 https://bugs.webkit.org/show_bug.cgi?id=233844 5 6 Reviewed by Brady Eidson. 7 8 Currently webpushd runs as root, which is unneessary. This patch makes it so that we run 9 with regular user permissions. This is done by specifying a UserName in the launchd plist on 10 iOS and by installing the plist to /System/Library/LaunchAgents on Mac. Since the plists now 11 differ based on platform, I changed the "Copy Daemon Plists" build phase in the WebKit 12 target to copy the appropriate plist to either /S/L/LaunchDaemons or /S/L/LaunchAgents. 13 14 Additionally, webpushd needs the `aps-connection-initiate` or 15 `com.apple.private.aps-connection-initiate` to receive pushes from apsd on iOS and Mac 16 respectively, so I gave the daemon those entitlements. 17 18 Finally, webpushd now registers for the `com.apple.aps.webkit.webpushd.incoming-push` Mach 19 service so that it can be launched on demand in response to a push. Right now we just 20 `bootstrap_check_in` to the service at launch time, but eventually we'll remove that and 21 use APSConnection to check in to the service instead. Since the `bootstrap_check_in` 22 call is temporary, I chose not to make a header file in wtf/spi and declared the prototype 23 in the implementation file instead. 24 25 * Configurations/webpushd.xcconfig: 26 * Scripts/process-entitlements.sh: 27 * WebKit.xcodeproj/project.pbxproj: 28 * webpushd/WebPushDaemonMain.mm: 29 (WebKit::WebPushDaemonMain): 30 * webpushd/com.apple.webkit.webpushd.ios.plist: Added. 31 * webpushd/com.apple.webkit.webpushd.mac.plist: Added. 32 * webpushd/com.apple.webkit.webpushd.plist: Removed. 33 1 34 2021-12-07 Chris Dumez <cdumez@apple.com> 2 35 -
trunk/Source/WebKit/Configurations/webpushd.xcconfig
r286564 r286624 29 29 LIBRARY_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR); 30 30 31 // We want this to always be NO for non-simulator builds. If set to YES, Xcode will invoke codesign with an --entitlements parameter that points to the platform's BaseEntitlements.plist. This parameter would override any --entitlements parameter that we establish in WK_LIBRARY_VALIDATION_CODE_SIGN_FLAGS, causing our entitlements to be ignored. 32 CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; 33 CODE_SIGN_INJECT_BASE_ENTITLEMENTS[sdk=*simulator] = YES; 34 35 // For simulator builds, entitlements are added to a special __entitlements section on the binary rather than the signature. 36 CODE_SIGN_ENTITLEMENTS[sdk=*simulator] = Resources/ios/XPCService-embedded-simulator.entitlements 37 31 38 WK_PROCESSED_XCENT_FILE=$(TEMP_FILE_DIR)/$(FULL_PRODUCT_NAME).entitlements 39 40 OTHER_CODE_SIGN_FLAGS = --entitlements $(WK_PROCESSED_XCENT_FILE); 32 41 33 42 INSTALL_PATH[sdk=iphone*] = $(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/Daemons; -
trunk/Source/WebKit/Scripts/process-entitlements.sh
r286219 r286624 215 215 plistbuddy Add :com.apple.security.cs.disable-library-validation bool YES 216 216 fi 217 } 218 219 function mac_process_webpushd_entitlements() 220 { 221 # FIXME: Add a sandbox profile for webpushd. 222 echo "webpushd sandbox has not been implemented yet" 223 plistbuddy Add :com.apple.private.aps-connection-initiate bool YES 217 224 } 218 225 … … 505 512 # FIXME: Add a sandbox profile for webpushd and add it to the seatbelt-profiles array. 506 513 echo "webpushd sandbox has not been implemented yet" 514 plistbuddy Add :aps-connection-initiate bool YES 507 515 } 508 516 … … 560 568 elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.GPU ]]; then mac_process_gpu_entitlements 561 569 elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.WebAuthn ]]; then mac_process_webauthn_entitlements 562 elif [[ "${PRODUCT_NAME}" != webpushd && "${PRODUCT_NAME}" != adattributiond ]]; then echo "Unsupported/unknown product: ${PRODUCT_NAME}" 570 elif [[ "${PRODUCT_NAME}" == webpushd ]]; then mac_process_webpushd_entitlements 571 elif [[ "${PRODUCT_NAME}" != adattributiond ]]; then echo "Unsupported/unknown product: ${PRODUCT_NAME}" 563 572 fi 564 573 elif [[ "${WK_PLATFORM_NAME}" == maccatalyst || "${WK_PLATFORM_NAME}" == iosmac ]] -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r286601 r286624 4896 4896 5CB9310726E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementXPCUtilities.h; sourceTree = "<group>"; }; 4897 4897 5CB9310826E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementXPCUtilities.mm; sourceTree = "<group>"; }; 4898 5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.plist; sourceTree = "<group>"; };4899 4898 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; }; 4900 4899 5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; }; … … 6374 6373 E5CB07DB20E1678F0022C183 /* WKFormColorControl.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFormColorControl.mm; path = ios/forms/WKFormColorControl.mm; sourceTree = "<group>"; }; 6375 6374 E5DEFA6726F8F42600AB68DB /* PhotosUISPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotosUISPI.h; sourceTree = "<group>"; }; 6375 EB0D312D275AE13300863D8F /* com.apple.webkit.webpushd.mac.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.mac.plist; sourceTree = "<group>"; }; 6376 EB0D312E275AE13300863D8F /* com.apple.webkit.webpushd.ios.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.ios.plist; sourceTree = "<group>"; }; 6376 6377 ECA680D31E6904B500731D20 /* ExtraPrivateSymbolsForTAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtraPrivateSymbolsForTAPI.h; sourceTree = "<group>"; }; 6377 6378 ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; }; … … 9953 9954 5160E954274B887100567388 /* AppBundleRequest.h */, 9954 9955 5160E953274B887100567388 /* AppBundleRequest.mm */, 9955 5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */, 9956 EB0D312E275AE13300863D8F /* com.apple.webkit.webpushd.ios.plist */, 9957 EB0D312D275AE13300863D8F /* com.apple.webkit.webpushd.mac.plist */, 9956 9958 51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */, 9957 9959 51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */, … … 14995 14997 inputPaths = ( 14996 14998 "$(SRCROOT)/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist", 14999 "$(SRCROOT)/webpushd/com.apple.webkit.webpushd.ios.plist", 15000 "$(SRCROOT)/webpushd/com.apple.webkit.webpushd.mac.plist", 14997 15001 ); 14998 15002 name = "Copy Daemon Plists"; … … 15001 15005 outputPaths = ( 15002 15006 "$(DSTROOT)/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist", 15007 "$(DSTROOT)/System/Library/LaunchDaemons/com.apple.webkit.webpushd.plist", 15008 "$(DSTROOT)/System/Library/LaunchAgents/com.apple.webkit.webpushd.plist", 15003 15009 ); 15004 15010 runOnlyForDeploymentPostprocessing = 1; 15005 15011 shellPath = /bin/sh; 15006 shellScript = "if [[ \"${WK_PLATFORM_NAME}\" == iphoneos ]]; then\n ADATTRIBUTIOND_PLIST_SOURCE=\"${SRCROOT}/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist\"\n ADATTRIBUTIOND_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist\"\n echo \"copying adattributiond plist\"\n echo plutil -convert binary1 -o \"${ADATTRIBUTIOND_PLIST_DESTINATION}\" \"${ADATTRIBUTIOND_PLIST_SOURCE}\"\n plutil -convert binary1 -o \"${ADATTRIBUTIOND_PLIST_DESTINATION}\" \"${ADATTRIBUTIOND_PLIST_SOURCE}\"\nelse\n echo \"not copying adattributiond plist\"\nfi\n\nif [[ \"${WK_PLATFORM_NAME}\" == iphoneos || \"${WK_PLATFORM_NAME}\" == macosx ]]; then\n WEBPUSHD_PLIST_SOURCE=\"${SRCROOT}/webpushd/com.apple.webkit.webpushd.plist\"\n WEBPUSHD_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchDaemons/com.apple.webkit.webpushd.plist\"\n echo \"copying webpushd plist\"\n echo plutil -convert binary1 -o \"${WEBPUSHD_PLIST_DESTINATION}\" \"${WEBPUSHD_PLIST_SOURCE}\"\n plutil -convert binary1 -o \"${WEBPUSHD_PLIST_DESTINATION}\" \"${WEBPUSHD_PLIST_SOURCE}\"\nelse\n echo \"not copying webpushd plist\"\nfi\n";15012 shellScript = "if [[ \"${WK_PLATFORM_NAME}\" == iphoneos ]]; then\n ADATTRIBUTIOND_PLIST_SOURCE=\"${SRCROOT}/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist\"\n ADATTRIBUTIOND_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist\"\n echo \"copying adattributiond plist\"\n echo plutil -convert binary1 -o \"${ADATTRIBUTIOND_PLIST_DESTINATION}\" \"${ADATTRIBUTIOND_PLIST_SOURCE}\"\n plutil -convert binary1 -o \"${ADATTRIBUTIOND_PLIST_DESTINATION}\" \"${ADATTRIBUTIOND_PLIST_SOURCE}\"\nelse\n echo \"not copying adattributiond plist\"\nfi\n\nif [[ \"${WK_PLATFORM_NAME}\" == iphoneos || \"${WK_PLATFORM_NAME}\" == macosx ]]; then\n if [[ \"${WK_PLATFORM_NAME}\" == iphoneos ]]; then\n WEBPUSHD_PLIST_SOURCE=\"${SRCROOT}/webpushd/com.apple.webkit.webpushd.ios.plist\"\n WEBPUSHD_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchDaemons/com.apple.webkit.webpushd.plist\"\n else\n WEBPUSHD_PLIST_SOURCE=\"${SRCROOT}/webpushd/com.apple.webkit.webpushd.mac.plist\"\n WEBPUSHD_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchAgents/com.apple.webkit.webpushd.plist\"\n fi\n\n echo \"copying webpushd plist\"\n echo plutil -convert binary1 -o \"${WEBPUSHD_PLIST_DESTINATION}\" \"${WEBPUSHD_PLIST_SOURCE}\"\n plutil -convert binary1 -o \"${WEBPUSHD_PLIST_DESTINATION}\" \"${WEBPUSHD_PLIST_SOURCE}\"\nelse\n echo \"not copying webpushd plist\"\nfi\n"; 15007 15013 }; 15008 15014 E1AC2E2C20F7B95800B0897D /* Unlock Keychain */ = { -
trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm
r286564 r286624 36 36 #import <wtf/spi/darwin/XPCSPI.h> 37 37 38 #if USE(APPLE_INTERNAL_SDK) 39 #import <servers/bootstrap.h> 40 #else 41 #import <mach/std_types.h> 42 extern "C" { 43 extern kern_return_t bootstrap_check_in(mach_port_t bootstrapPort, const char *serviceName, mach_port_t*); 44 } 45 #endif 46 38 47 using WebKit::Daemon::EncodedMessage; 39 48 using WebPushD::Daemon; 49 50 static const char *incomingPushServiceName = "com.apple.aps.webkit.webpushd.incoming-push"; 40 51 41 52 namespace WebPushD { … … 74 85 @autoreleasepool { 75 86 WebKit::startListeningForMachServiceConnections(machServiceName, "com.apple.private.webkit.webpush", connectionAdded, connectionRemoved, connectionEventHandler); 87 88 // TODO: remove this once we actually start using APSConnection. 89 mach_port_t incomingMessagePort; 90 if (bootstrap_check_in(bootstrap_port, incomingPushServiceName, &incomingMessagePort) != KERN_SUCCESS) 91 NSLog(@"Couldn't register for incoming push launch port."); 92 76 93 WTF::initializeMainThread(); 77 94 }
Note:
See TracChangeset
for help on using the changeset viewer.