RESOLVED FIXED Bug 233295
More webpushd architecture work
https://bugs.webkit.org/show_bug.cgi?id=233295
Summary More webpushd architecture work
Brady Eidson
Reported 2021-11-17 16:52:49 PST
More webpushd architecture work
Attachments
EWS v1 (35.99 KB, patch)
2021-11-17 16:54 PST, Brady Eidson
ews-feeder: commit-queue-
EWS v2 (39.83 KB, patch)
2021-11-17 18:10 PST, Brady Eidson
ews-feeder: commit-queue-
EWS v3 (40.03 KB, patch)
2021-11-17 19:06 PST, Brady Eidson
ews-feeder: commit-queue-
EWS v4 (40.05 KB, patch)
2021-11-17 19:43 PST, Brady Eidson
no flags
EWS v5 (40.13 KB, patch)
2021-11-17 23:07 PST, Brady Eidson
achristensen: review-
ews-feeder: commit-queue-
Updated for review feedback, still building locally to explore Mac API test failure (40.20 KB, patch)
2021-11-18 16:55 PST, Brady Eidson
achristensen: review+
More for EWS while I explore Mac API thingy (41.82 KB, patch)
2021-11-18 21:26 PST, Brady Eidson
no flags
PFL v1 (42.87 KB, patch)
2021-11-19 01:17 PST, Brady Eidson
ews-feeder: commit-queue-
PFL v2 (42.68 KB, patch)
2021-11-19 11:08 PST, Brady Eidson
no flags
PFL v3 (42.68 KB, patch)
2021-11-19 12:26 PST, Brady Eidson
no flags
Brady Eidson
Comment 1 2021-11-17 16:54:48 PST
Created attachment 444609 [details] EWS v1 Besides missing ChangeLogs, I know this'll need more work. Need EWS to tell me how much more.
Brady Eidson
Comment 2 2021-11-17 18:10:25 PST
Brady Eidson
Comment 3 2021-11-17 19:06:17 PST
Brady Eidson
Comment 4 2021-11-17 19:43:32 PST
Brady Eidson
Comment 5 2021-11-17 23:07:36 PST
Brady Eidson
Comment 6 2021-11-18 08:49:06 PST
Going to mark for review even while I work on resolving the api-mac failure
Alex Christensen
Comment 7 2021-11-18 11:51:33 PST
Comment on attachment 444641 [details] EWS v5 View in context: https://bugs.webkit.org/attachment.cgi?id=444641&action=review > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp:45 > + auto cfData = m_networkSession.networkProcess().sourceApplicationAuditData(); You can probably do this from sourceApplicationAuditToken to be slightly more efficient. > Source/WebKit/Shared/Cocoa/CodeSigning.mm:78 > + auto pair = codeSigningIdentifierAndPlatformBinaryStatus(token); This doesn't need to call SecTaskGetCodeSignStatus. > Source/WebKit/webpushd/PushClientConnection.mm:42 > +void ClientConnection::setAuditTokenData(const Vector<uint8_t>& tokenData) This is a little strange. Isn't xpc_connection_get_audit_token enough? > Source/WebKit/webpushd/PushClientConnection.mm:72 > + m_hostHasPushEntitlement = WTF::hasEntitlement(*m_hostAppAuditToken, "com.apple.private.webkit.webpush"); This is typically done at the time a connection is being received, then terminating the connection if it doesn't have an entitlement. That way you avoid bugs where you forgot to check the entitlement. If you have a connection, then it is entitled. > Source/WebKit/webpushd/WebPushDaemon.h:56 > + void echoTwice(ClientConnection*, const String&, CompletionHandler<void(const String&)>&& replySender); We can probably remove this at some point. > Source/WebKit/webpushd/WebPushDaemon.h:77 > + HashMap<xpc_connection_t, std::unique_ptr<ClientConnection>> m_connectionMap; It's a little strange that the connection is both in the key and the value.
Brady Eidson
Comment 8 2021-11-18 13:59:20 PST
(In reply to Alex Christensen from comment #7) > Comment on attachment 444641 [details] > EWS v5 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=444641&action=review > > > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp:45 > > + auto cfData = m_networkSession.networkProcess().sourceApplicationAuditData(); > > You can probably do this from sourceApplicationAuditToken to be slightly > more efficient. Yes. > > > Source/WebKit/Shared/Cocoa/CodeSigning.mm:78 > > + auto pair = codeSigningIdentifierAndPlatformBinaryStatus(token); > > This doesn't need to call SecTaskGetCodeSignStatus. I was trying to reuse the existing abstractions, but will open it up a bit more. > > > Source/WebKit/webpushd/PushClientConnection.mm:42 > > +void ClientConnection::setAuditTokenData(const Vector<uint8_t>& tokenData) > > This is a little strange. Isn't xpc_connection_get_audit_token enough? xpc_connection_get_audit_token gets the audit token of the remote process. For example, in webpushd, it gets the audit token of com.apple.WebKit.Networking We need the remote-remote audit token. E.g. if com.apple.WebKit.Networking is running on behalf of Safari, we need Safari's audit token. This would've been made much clearer if I named these methods more precisely. > > > Source/WebKit/webpushd/PushClientConnection.mm:72 > > + m_hostHasPushEntitlement = WTF::hasEntitlement(*m_hostAppAuditToken, "com.apple.private.webkit.webpush"); > > This is typically done at the time a connection is being received, then > terminating the connection if it doesn't have an entitlement. That way you > avoid bugs where you forgot to check the entitlement. If you have a > connection, then it is entitled. Once again, see above: This isn't the remote connection... this is the host app *of* the remote connection. So it cannot be done at connection time. > > > Source/WebKit/webpushd/WebPushDaemon.h:56 > > + void echoTwice(ClientConnection*, const String&, CompletionHandler<void(const String&)>&& replySender); > > We can probably remove this at some point. Sure. Will do separately. > > > Source/WebKit/webpushd/WebPushDaemon.h:77 > > + HashMap<xpc_connection_t, std::unique_ptr<ClientConnection>> m_connectionMap; > > It's a little strange that the connection is both in the key and the value. I have no alternative suggestions though.
Brady Eidson
Comment 9 2021-11-18 16:55:30 PST
Created attachment 444760 [details] Updated for review feedback, still building locally to explore Mac API test failure
Alex Christensen
Comment 10 2021-11-18 17:15:32 PST
In DaemonConnectionSet I made the map a map from the connection to a collection of metadata that doesn't contain another reference to the connection. That's my alternative suggestion
Brady Eidson
Comment 11 2021-11-18 17:47:40 PST
(In reply to Alex Christensen from comment #10) > In DaemonConnectionSet I made the map a map from the connection to a > collection of metadata that doesn't contain another reference to the > connection. That's my alternative suggestion I'm not clear on how that's better - It's still a map of xpc_connection_t to information about those connections. For future reference: ClientConnection WILL have more data and behaviors than just what this patch introduces, very soon. It will be supremely useful for things like "This xpc connection dropped - Find it's resulting WebPushD::ClientConnection object and have it clean up outstanding activities"
Brady Eidson
Comment 12 2021-11-18 17:48:36 PST
I figured out the Mac API test issue, but need to finish a full Mac build to resolve. Will do soon. This patch still reviewable.
Alex Christensen
Comment 13 2021-11-18 17:54:16 PST
Comment on attachment 444760 [details] Updated for review feedback, still building locally to explore Mac API test failure View in context: https://bugs.webkit.org/attachment.cgi?id=444760&action=review > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp:39 > NetworkNotificationManager::NetworkNotificationManager(NetworkSession& networkSession, const String& webPushMachServiceName) nit: mach service names can be a CString because they are always ASCII. > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp:53 > + sendMessage<WebPushD::MessageType::SetHostAppAuditToken>(auditTokenData); Sending the first message will start the daemon if it hasn't been started, so we probably want to lazily send this to prevent unnecessary daemon starting. > Source/WebKit/webpushd/PushClientConnection.h:44 > + String hostAppCodeSigningIdentifier(); nit: can this return a const String& ?
Brady Eidson
Comment 14 2021-11-18 21:26:49 PST
Created attachment 444780 [details] More for EWS while I explore Mac API thingy
Brady Eidson
Comment 15 2021-11-18 22:56:38 PST
Can't reproduce the mac-api test failure locally. My suspicion is internal vs non-internal SDK. (related to entitlements or audit tokens somehow) Building on a public SDK now.
Brady Eidson
Comment 16 2021-11-19 01:17:37 PST
Created attachment 444787 [details] PFL v1 The Mac-api-test failure was because the source application audit token wasn't making its way through. This was because USE_SOURCE_APPLICATION_AUDIT_DATA was true for Mac only in the internal SDK... but it seems to work great in the public SDK as well. Enabling that and giving it a test run.
Brady Eidson
Comment 17 2021-11-19 09:06:17 PST
(In reply to Brady Eidson from comment #16) > Created attachment 444787 [details] > PFL v1 > > The Mac-api-test failure was because the source application audit token > wasn't making its way through. > This was because USE_SOURCE_APPLICATION_AUDIT_DATA was true for Mac only in > the internal SDK... but it seems to work great in the public SDK as well. > > Enabling that and giving it a test run. And it's obvious that we're not ready for all the related fallout from that. Doing something more limited.
Brady Eidson
Comment 18 2021-11-19 11:08:05 PST
Brady Eidson
Comment 19 2021-11-19 12:26:00 PST
EWS
Comment 20 2021-11-19 13:43:24 PST
Committed r286075 (244462@main): <https://commits.webkit.org/244462@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 444844 [details].
Radar WebKit Bug Importer
Comment 21 2021-11-19 13:44:26 PST
Note You need to log in before you can comment on or make changes to this bug.