<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[286624] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/286624">286624</a></dd>
<dt>Author</dt> <dd>nham@apple.com</dd>
<dt>Date</dt> <dd>2021-12-07 14:51:38 -0800 (Tue, 07 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>webpushd should run with regular user permissions
https://bugs.webkit.org/show_bug.cgi?id=233844

Reviewed by Brady Eidson.

Currently webpushd runs as root, which is unneessary. This patch makes it so that we run
with regular user permissions. This is done by specifying a UserName in the launchd plist on
iOS and by installing the plist to /System/Library/LaunchAgents on Mac. Since the plists now
differ based on platform, I changed the "Copy Daemon Plists" build phase in the WebKit
target to copy the appropriate plist to either /S/L/LaunchDaemons or /S/L/LaunchAgents.

Additionally, webpushd needs the `aps-connection-initiate` or
`com.apple.private.aps-connection-initiate` to receive pushes from apsd on iOS and Mac
respectively, so I gave the daemon those entitlements.

Finally, webpushd now registers for the `com.apple.aps.webkit.webpushd.incoming-push` Mach
service so that it can be launched on demand in response to a push. Right now we just
`bootstrap_check_in` to the service at launch time, but eventually we'll remove that and
use APSConnection to check in to the service instead. Since the `bootstrap_check_in`
call is temporary, I chose not to make a header file in wtf/spi and declared the prototype
in the implementation file instead.

* Configurations/webpushd.xcconfig:
* Scripts/process-entitlements.sh:
* WebKit.xcodeproj/project.pbxproj:
* webpushd/WebPushDaemonMain.mm:
(WebKit::WebPushDaemonMain):
* webpushd/com.apple.webkit.webpushd.ios.plist: Added.
* webpushd/com.apple.webkit.webpushd.mac.plist: Added.
* webpushd/com.apple.webkit.webpushd.plist: Removed.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitConfigurationswebpushdxcconfig">trunk/Source/WebKit/Configurations/webpushd.xcconfig</a></li>
<li><a href="#trunkSourceWebKitScriptsprocessentitlementssh">trunk/Source/WebKit/Scripts/process-entitlements.sh</a></li>
<li><a href="#trunkSourceWebKitWebKitxcodeprojprojectpbxproj">trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKitwebpushdWebPushDaemonMainmm">trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitwebpushdcomapplewebkitwebpushdiosplist">trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.ios.plist</a></li>
<li><a href="#trunkSourceWebKitwebpushdcomapplewebkitwebpushdmacplist">trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.mac.plist</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitwebpushdcomapplewebkitwebpushdplist">trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.plist</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/ChangeLog       2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2021-12-07  Ben Nham  <nham@apple.com>
+
+        webpushd should run with regular user permissions
+        https://bugs.webkit.org/show_bug.cgi?id=233844
+
+        Reviewed by Brady Eidson.
+
+        Currently webpushd runs as root, which is unneessary. This patch makes it so that we run
+        with regular user permissions. This is done by specifying a UserName in the launchd plist on
+        iOS and by installing the plist to /System/Library/LaunchAgents on Mac. Since the plists now
+        differ based on platform, I changed the "Copy Daemon Plists" build phase in the WebKit
+        target to copy the appropriate plist to either /S/L/LaunchDaemons or /S/L/LaunchAgents.
+
+        Additionally, webpushd needs the `aps-connection-initiate` or
+        `com.apple.private.aps-connection-initiate` to receive pushes from apsd on iOS and Mac
+        respectively, so I gave the daemon those entitlements.
+
+        Finally, webpushd now registers for the `com.apple.aps.webkit.webpushd.incoming-push` Mach
+        service so that it can be launched on demand in response to a push. Right now we just
+        `bootstrap_check_in` to the service at launch time, but eventually we'll remove that and
+        use APSConnection to check in to the service instead. Since the `bootstrap_check_in`
+        call is temporary, I chose not to make a header file in wtf/spi and declared the prototype
+        in the implementation file instead.
+
+        * Configurations/webpushd.xcconfig:
+        * Scripts/process-entitlements.sh:
+        * WebKit.xcodeproj/project.pbxproj:
+        * webpushd/WebPushDaemonMain.mm:
+        (WebKit::WebPushDaemonMain):
+        * webpushd/com.apple.webkit.webpushd.ios.plist: Added.
+        * webpushd/com.apple.webkit.webpushd.mac.plist: Added.
+        * webpushd/com.apple.webkit.webpushd.plist: Removed.
+
</ins><span class="cx"> 2021-12-07  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: m_messagesBeingDispatched.isEmpty() on http/tests/resourceLoadStatistics/website-data-removal-for-site-with-user-interaction.html
</span></span></pre></div>
<a id="trunkSourceWebKitConfigurationswebpushdxcconfig"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Configurations/webpushd.xcconfig (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Configurations/webpushd.xcconfig     2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/Configurations/webpushd.xcconfig        2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -28,7 +28,16 @@
</span><span class="cx"> OTHER_LDFLAGS = -framework WebKit;
</span><span class="cx"> LIBRARY_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR);
</span><span class="cx"> 
</span><ins>+// 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.
+CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
+CODE_SIGN_INJECT_BASE_ENTITLEMENTS[sdk=*simulator] = YES;
+
+// For simulator builds, entitlements are added to a special __entitlements section on the binary rather than the signature.
+CODE_SIGN_ENTITLEMENTS[sdk=*simulator] = Resources/ios/XPCService-embedded-simulator.entitlements
+
</ins><span class="cx"> WK_PROCESSED_XCENT_FILE=$(TEMP_FILE_DIR)/$(FULL_PRODUCT_NAME).entitlements
</span><span class="cx"> 
</span><ins>+OTHER_CODE_SIGN_FLAGS = --entitlements $(WK_PROCESSED_XCENT_FILE);
+
</ins><span class="cx"> INSTALL_PATH[sdk=iphone*] = $(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/Daemons;
</span><span class="cx"> INSTALL_PATH[sdk=macosx*] = $(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/Versions/A/Daemons;
</span></span></pre></div>
<a id="trunkSourceWebKitScriptsprocessentitlementssh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Scripts/process-entitlements.sh (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Scripts/process-entitlements.sh      2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/Scripts/process-entitlements.sh 2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -216,6 +216,13 @@
</span><span class="cx">     fi
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function mac_process_webpushd_entitlements()
+{
+    # FIXME: Add a sandbox profile for webpushd.
+    echo "webpushd sandbox has not been implemented yet"
+    plistbuddy Add :com.apple.private.aps-connection-initiate bool YES
+}
+
</ins><span class="cx"> # ========================================
</span><span class="cx"> # macCatalyst entitlements
</span><span class="cx"> # ========================================
</span><span class="lines">@@ -504,6 +511,7 @@
</span><span class="cx"> {
</span><span class="cx">     # FIXME: Add a sandbox profile for webpushd and add it to the seatbelt-profiles array.
</span><span class="cx">     echo "webpushd sandbox has not been implemented yet"
</span><ins>+    plistbuddy Add :aps-connection-initiate bool YES
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function ios_family_process_network_entitlements()
</span><span class="lines">@@ -559,7 +567,8 @@
</span><span class="cx">     elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.Plugin.64 ]]; then mac_process_plugin_entitlements
</span><span class="cx">     elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.GPU ]]; then mac_process_gpu_entitlements
</span><span class="cx">     elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.WebAuthn ]]; then mac_process_webauthn_entitlements
</span><del>-    elif [[ "${PRODUCT_NAME}" != webpushd && "${PRODUCT_NAME}" != adattributiond ]]; then echo "Unsupported/unknown product: ${PRODUCT_NAME}"
</del><ins>+    elif [[ "${PRODUCT_NAME}" == webpushd ]]; then mac_process_webpushd_entitlements
+    elif [[ "${PRODUCT_NAME}" != adattributiond ]]; then echo "Unsupported/unknown product: ${PRODUCT_NAME}"
</ins><span class="cx">     fi
</span><span class="cx"> elif [[ "${WK_PLATFORM_NAME}" == maccatalyst || "${WK_PLATFORM_NAME}" == iosmac ]]
</span><span class="cx"> then
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj     2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj        2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -4895,7 +4895,6 @@
</span><span class="cx">          5CB9310626E839A90032B1C0 /* PrivateClickMeasurementManagerInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManagerInterface.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5CB9310726E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementXPCUtilities.h; sourceTree = "<group>"; };
</span><span class="cx">          5CB9310826E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementXPCUtilities.mm; sourceTree = "<group>"; };
</span><del>-               5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.plist; sourceTree = "<group>"; };
</del><span class="cx">           5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
</span><span class="cx">          5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          5CBE908F26D7FB62005A2E95 /* PrivateClickMeasurementDebugInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDebugInfo.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -6373,6 +6372,8 @@
</span><span class="cx">          E5CB07DA20E1678F0022C183 /* WKFormColorControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFormColorControl.h; path = ios/forms/WKFormColorControl.h; sourceTree = "<group>"; };
</span><span class="cx">          E5CB07DB20E1678F0022C183 /* WKFormColorControl.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFormColorControl.mm; path = ios/forms/WKFormColorControl.mm; sourceTree = "<group>"; };
</span><span class="cx">          E5DEFA6726F8F42600AB68DB /* PhotosUISPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotosUISPI.h; sourceTree = "<group>"; };
</span><ins>+               EB0D312D275AE13300863D8F /* com.apple.webkit.webpushd.mac.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.mac.plist; sourceTree = "<group>"; };
+               EB0D312E275AE13300863D8F /* com.apple.webkit.webpushd.ios.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.webpushd.ios.plist; sourceTree = "<group>"; };
</ins><span class="cx">           ECA680D31E6904B500731D20 /* ExtraPrivateSymbolsForTAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtraPrivateSymbolsForTAPI.h; sourceTree = "<group>"; };
</span><span class="cx">          ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; };
</span><span class="cx">          F036978715F4BF0500C3A80E /* WebColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorPicker.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -9952,7 +9953,8 @@
</span><span class="cx">                          517B5F63275A8D5C002DC22D /* webpushtool */,
</span><span class="cx">                          5160E954274B887100567388 /* AppBundleRequest.h */,
</span><span class="cx">                          5160E953274B887100567388 /* AppBundleRequest.mm */,
</span><del>-                               5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */,
</del><ins>+                                EB0D312E275AE13300863D8F /* com.apple.webkit.webpushd.ios.plist */,
+                               EB0D312D275AE13300863D8F /* com.apple.webkit.webpushd.mac.plist */,
</ins><span class="cx">                           51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */,
</span><span class="cx">                          51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */,
</span><span class="cx">                          5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */,
</span><span class="lines">@@ -14994,6 +14996,8 @@
</span><span class="cx">                  );
</span><span class="cx">                  inputPaths = (
</span><span class="cx">                          "$(SRCROOT)/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist",
</span><ins>+                               "$(SRCROOT)/webpushd/com.apple.webkit.webpushd.ios.plist",
+                               "$(SRCROOT)/webpushd/com.apple.webkit.webpushd.mac.plist",
</ins><span class="cx">                   );
</span><span class="cx">                  name = "Copy Daemon Plists";
</span><span class="cx">                  outputFileListPaths = (
</span><span class="lines">@@ -15000,10 +15004,12 @@
</span><span class="cx">                  );
</span><span class="cx">                  outputPaths = (
</span><span class="cx">                          "$(DSTROOT)/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist",
</span><ins>+                               "$(DSTROOT)/System/Library/LaunchDaemons/com.apple.webkit.webpushd.plist",
+                               "$(DSTROOT)/System/Library/LaunchAgents/com.apple.webkit.webpushd.plist",
</ins><span class="cx">                   );
</span><span class="cx">                  runOnlyForDeploymentPostprocessing = 1;
</span><span class="cx">                  shellPath = /bin/sh;
</span><del>-                       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}/Sy
 stem/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";
</del><ins>+                        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.webpu
 shd.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";
</ins><span class="cx">           };
</span><span class="cx">          E1AC2E2C20F7B95800B0897D /* Unlock Keychain */ = {
</span><span class="cx">                  isa = PBXShellScriptBuildPhase;
</span></span></pre></div>
<a id="trunkSourceWebKitwebpushdWebPushDaemonMainmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm        2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm   2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -35,9 +35,20 @@
</span><span class="cx"> #import <wtf/MainThread.h>
</span><span class="cx"> #import <wtf/spi/darwin/XPCSPI.h>
</span><span class="cx"> 
</span><ins>+#if USE(APPLE_INTERNAL_SDK)
+#import <servers/bootstrap.h>
+#else
+#import <mach/std_types.h>
+extern "C" {
+extern kern_return_t bootstrap_check_in(mach_port_t bootstrapPort, const char *serviceName, mach_port_t*);
+}
+#endif
+
</ins><span class="cx"> using WebKit::Daemon::EncodedMessage;
</span><span class="cx"> using WebPushD::Daemon;
</span><span class="cx"> 
</span><ins>+static const char *incomingPushServiceName = "com.apple.aps.webkit.webpushd.incoming-push";
+
</ins><span class="cx"> namespace WebPushD {
</span><span class="cx"> 
</span><span class="cx"> static void connectionEventHandler(xpc_object_t request)
</span><span class="lines">@@ -73,6 +84,12 @@
</span><span class="cx"> 
</span><span class="cx">     @autoreleasepool {
</span><span class="cx">         WebKit::startListeningForMachServiceConnections(machServiceName, "com.apple.private.webkit.webpush", connectionAdded, connectionRemoved, connectionEventHandler);
</span><ins>+
+        // TODO: remove this once we actually start using APSConnection.
+        mach_port_t incomingMessagePort;
+        if (bootstrap_check_in(bootstrap_port, incomingPushServiceName, &incomingMessagePort) != KERN_SUCCESS)
+            NSLog(@"Couldn't register for incoming push launch port.");
+        
</ins><span class="cx">         WTF::initializeMainThread();
</span><span class="cx">     }
</span><span class="cx">     CFRunLoopRun();
</span></span></pre></div>
<a id="trunkSourceWebKitwebpushdcomapplewebkitwebpushdiosplist"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.ios.plist (0 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.ios.plist                         (rev 0)
+++ trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.ios.plist    2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<?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>EnablePressuredExit</key>
+       <true/>
+       <key>EnableTransactions</key>
+       <true/>
+       <key>Label</key>
+       <string>com.apple.webkit.webpushd</string>
+       <key>MachServices</key>
+       <dict>
+               <key>com.apple.webkit.webpushd.service</key>
+               <true/>
+               <key>com.apple.aps.webkit.webpushd.incoming-push</key>
+               <true/>
+       </dict>
+       <key>ProcessType</key>
+       <string>Adaptive</string>
+       <key>ProgramArguments</key>
+       <array>
+               <string>/System/Library/Frameworks/WebKit.framework/Daemons/webpushd</string>
+               <string>--machServiceName</string>
+               <string>com.apple.webkit.webpushd.service</string>
+       </array>
+       <key>StandardErrorPath</key>
+       <string>/dev/null</string>
+       <key>UserName</key>
+       <string>mobile</string>
+</dict>
+</plist>
</ins></span></pre></div>
<a id="trunkSourceWebKitwebpushdcomapplewebkitwebpushdmacplist"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.mac.plist (0 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.mac.plist                         (rev 0)
+++ trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.mac.plist    2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+<?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>EnablePressuredExit</key>
+       <true/>
+       <key>EnableTransactions</key>
+       <true/>
+       <key>Label</key>
+       <string>com.apple.webkit.webpushd</string>
+       <key>MachServices</key>
+       <dict>
+               <key>com.apple.webkit.webpushd.service</key>
+               <true/>
+               <key>com.apple.aps.webkit.webpushd.incoming-push</key>
+               <true/>
+       </dict>
+       <key>ProcessType</key>
+       <string>Adaptive</string>
+       <key>ProgramArguments</key>
+       <array>
+               <string>/System/Library/Frameworks/WebKit.framework/Daemons/webpushd</string>
+               <string>--machServiceName</string>
+               <string>com.apple.webkit.webpushd.service</string>
+       </array>
+       <key>StandardErrorPath</key>
+       <string>/dev/null</string>
+</dict>
+</plist>
</ins></span></pre></div>
<a id="trunkSourceWebKitwebpushdcomapplewebkitwebpushdplist"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.plist (286623 => 286624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.plist     2021-12-07 22:31:12 UTC (rev 286623)
+++ trunk/Source/WebKit/webpushd/com.apple.webkit.webpushd.plist        2021-12-07 22:51:38 UTC (rev 286624)
</span><span class="lines">@@ -1,29 +0,0 @@
</span><del>-<?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>EnablePressuredExit</key>
-        <true/>
-        <key>EnableTransactions</key>
-        <true/>
-        <key>Label</key>
-        <string>com.apple.webkit.webpushd</string>
-        <key>MachServices</key>
-        <dict>
-                <key>com.apple.webkit.webpushd.service</key>
-                <true/>
-        </dict>
-        <key>ProcessType</key>
-        <string>Adaptive</string>
-        <key>ProgramArguments</key>
-        <array>
-                <string>/System/Library/Frameworks/WebKit.framework/Daemons/webpushd</string>
-                <string>--machServiceName</string>
-                <string>com.apple.webkit.webpushd.service</string>
-                <string>--storageLocation</string>
-                <string>/var/mobile/Library/com.apple.webkit.webpushd/Version1</string>
-        </array>
-        <key>StandardErrorPath</key>
-        <string>/dev/null</string>
-</dict>
-</plist>
</del><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>