Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Expand use of sourceApplicationAuditData
https://bugs.webkit.org/show_bug.cgi?id=192995
<rdar://problem/46627875>

Reviewed by Brady Eidson.

Source/WebKit:

sourceApplicationAuditData has been used for a long time on iOS, but it's needed on more platforms.
I also made it return an Optional instead of a bool and returning by reference. Ahhh. So much nicer.

* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::sourceApplicationAuditData const):
* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::getAuditToken):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::sourceApplicationAuditData const):

Source/WTF:

* wtf/Platform.h:



Canonical link: https://commits.webkit.org/207556@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239524 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed Dec 21, 2018
1 parent 9b3549c commit 397389e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 15 deletions.
10 changes: 10 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,13 @@
2018-12-21 Alex Christensen <achristensen@webkit.org>

Expand use of sourceApplicationAuditData
https://bugs.webkit.org/show_bug.cgi?id=192995
<rdar://problem/46627875>

Reviewed by Brady Eidson.

* wtf/Platform.h:

2018-12-21 Alex Christensen <achristensen@webkit.org>

Revert r239503.
Expand Down
4 changes: 4 additions & 0 deletions Source/WTF/wtf/Platform.h
Expand Up @@ -1359,6 +1359,10 @@
#define HAVE_RSA_PSS 1
#endif

#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || PLATFORM(IOS_FAMILY)
#define USE_SOURCE_APPLICATION_AUDIT_DATA 1
#endif

#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS) || PLATFORM(IOSMAC)
#define HAVE_URL_FORMATTING 1
#endif
Expand Down
21 changes: 21 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,24 @@
2018-12-21 Alex Christensen <achristensen@webkit.org>

Expand use of sourceApplicationAuditData
https://bugs.webkit.org/show_bug.cgi?id=192995
<rdar://problem/46627875>

Reviewed by Brady Eidson.

sourceApplicationAuditData has been used for a long time on iOS, but it's needed on more platforms.
I also made it return an Optional instead of a bool and returning by reference. Ahhh. So much nicer.

* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::sourceApplicationAuditData const):
* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::getAuditToken):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::sourceApplicationAuditData const):

2018-12-21 Jiewen Tan <jiewen_tan@apple.com>

[Mac] Layout Test http/wpt/webauthn/public-key-credential-create-success-hid.https.html and http/wpt/webauthn/public-key-credential-get-success-hid.https.html are flaky
Expand Down
10 changes: 6 additions & 4 deletions Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Expand Up @@ -133,12 +133,14 @@ static void initializeNetworkSettings()

RetainPtr<CFDataRef> NetworkProcess::sourceApplicationAuditData() const
{
#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOSMAC)
audit_token_t auditToken;
#if USE(SOURCE_APPLICATION_AUDIT_DATA)
ASSERT(parentProcessConnection());
if (!parentProcessConnection() || !parentProcessConnection()->getAuditToken(auditToken))
if (!parentProcessConnection())
return nullptr;
return adoptCF(CFDataCreate(nullptr, (const UInt8*)&auditToken, sizeof(auditToken)));
Optional<audit_token_t> auditToken = parentProcessConnection()->getAuditToken();
if (!auditToken)
return nullptr;
return adoptCF(CFDataCreate(nullptr, (const UInt8*)&*auditToken, sizeof(*auditToken)));
#else
return nullptr;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Platform/IPC/Connection.h
Expand Up @@ -137,7 +137,7 @@ class Connection : public ThreadSafeRefCounted<Connection, WTF::DestructionThrea
};
static bool identifierIsValid(Identifier identifier) { return MACH_PORT_VALID(identifier.port); }
xpc_connection_t xpcConnection() const { return m_xpcConnection.get(); }
bool getAuditToken(audit_token_t&);
Optional<audit_token_t> getAuditToken();
pid_t remoteProcessID() const;
#elif OS(WINDOWS)
typedef HANDLE Identifier;
Expand Down
7 changes: 4 additions & 3 deletions Source/WebKit/Platform/IPC/mac/ConnectionMac.mm
Expand Up @@ -603,13 +603,14 @@ void watchdogTimerFired()
return Identifier(m_isServer ? m_receivePort : m_sendPort, m_xpcConnection);
}

bool Connection::getAuditToken(audit_token_t& auditToken)
Optional<audit_token_t> Connection::getAuditToken()
{
if (!m_xpcConnection)
return false;
return WTF::nullopt;

audit_token_t auditToken;
xpc_connection_get_audit_token(m_xpcConnection.get(), &auditToken);
return true;
return WTFMove(auditToken);
}

bool Connection::kill()
Expand Down
5 changes: 2 additions & 3 deletions Source/WebKit/WebProcess/WebProcess.cpp
Expand Up @@ -401,9 +401,8 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
#endif

#if ENABLE(REMOTE_INSPECTOR) && PLATFORM(COCOA)
audit_token_t auditToken;
if (parentProcessConnection()->getAuditToken(auditToken)) {
RetainPtr<CFDataRef> auditData = adoptCF(CFDataCreate(nullptr, (const UInt8*)&auditToken, sizeof(auditToken)));
if (Optional<audit_token_t> auditToken = parentProcessConnection()->getAuditToken()) {
RetainPtr<CFDataRef> auditData = adoptCF(CFDataCreate(nullptr, (const UInt8*)&*auditToken, sizeof(*auditToken)));
Inspector::RemoteInspector::singleton().setParentProcessInformation(WebCore::presentingApplicationPID(), auditData);
}
#endif
Expand Down
10 changes: 6 additions & 4 deletions Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
Expand Up @@ -417,12 +417,14 @@ static void registerWithAccessibility()

RetainPtr<CFDataRef> WebProcess::sourceApplicationAuditData() const
{
#if PLATFORM(IOS_FAMILY)
audit_token_t auditToken;
#if USE(SOURCE_APPLICATION_AUDIT_DATA)
ASSERT(parentProcessConnection());
if (!parentProcessConnection() || !parentProcessConnection()->getAuditToken(auditToken))
if (!parentProcessConnection())
return nullptr;
Optional<audit_token_t> auditToken = parentProcessConnection()->getAuditToken();
if (!auditToken)
return nullptr;
return adoptCF(CFDataCreate(nullptr, (const UInt8*)&auditToken, sizeof(auditToken)));
return adoptCF(CFDataCreate(nullptr, (const UInt8*)&*auditToken, sizeof(*auditToken)));
#else
return nullptr;
#endif
Expand Down

0 comments on commit 397389e

Please sign in to comment.