WebKit Bugzilla
Attachment 360514 Details for
Bug 193988
: [Cocoa][EME] Modern EME uses a different path for SecureStop data than Legacy EME
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193988-20190129154400.patch (text/plain), 10.65 KB, created by
Jer Noble
on 2019-01-29 15:44:01 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2019-01-29 15:44:01 PST
Size:
10.65 KB
patch
obsolete
>Subversion Revision: 240673 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2b783109d2aab79e8f8fe17383603d65caba1f3a..02766754c23159669264a0d7b2dd1df9184c1b19 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2019-01-29 Jer Noble <jer.noble@apple.com> >+ >+ [Cocoa][EME] Modern EME uses a different path for SecureStop data than Legacy EME >+ https://bugs.webkit.org/show_bug.cgi?id=193988 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Modern EME is writing SecureStop data as a file at the same path as the >+ directory used by Legacy EME; meaning, when Modern EME attempts to write >+ to that file, it will fail because a directory exists at the same path. >+ >+ Add a migration step to take care of those instances where Modern EME Secure >+ Stop data was already written to disk, and move that previously written data >+ to the correct file path. >+ >+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h: >+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: >+ (WebCore::CDMInstanceFairPlayStreamingAVFObjC::initializeWithConfiguration): >+ (WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory): >+ (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense): >+ (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::loadSession): >+ (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData): >+ (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSession): >+ > 2019-01-29 Jer Noble <jer.noble@apple.com> > > [Cocoa][EME] persistent-usage-record data not issued after MediaKeySession.remove() >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >index d7a1900f10526937a7dfe24f6aa40124e288a1e1..61ffc5205bd2ad42ebc86c327f5594bb6c7d1174 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >@@ -66,7 +66,7 @@ public: > > const String& keySystem() const final; > >- NSURL *storageDirectory() const { return m_storageDirectory.get(); } >+ NSURL *storageURL() const { return m_storageURL.get(); } > bool persistentStateAllowed() const { return m_persistentStateAllowed; } > SharedBuffer* serverCertificate() const { return m_serverCertificate.get(); } > >@@ -76,7 +76,7 @@ public: > private: > RefPtr<SharedBuffer> m_serverCertificate; > bool m_persistentStateAllowed { true }; >- RetainPtr<NSURL> m_storageDirectory; >+ RetainPtr<NSURL> m_storageURL; > Vector<WeakPtr<CDMInstanceSessionFairPlayStreamingAVFObjC>> m_sessions; > }; > >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >index c050520b35594d98251470449f9f00fc1260372e..7e91c4c40d51b0c49454981959db973210216e76 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >@@ -38,6 +38,7 @@ > #import <objc/runtime.h> > #import <pal/spi/mac/AVFoundationSPI.h> > #import <wtf/Algorithms.h> >+#import <wtf/FileSystem.h> > #import <wtf/SoftLinking.h> > #import <wtf/text/StringHash.h> > >@@ -170,7 +171,7 @@ CDMInstance::SuccessValue CDMInstanceFairPlayStreamingAVFObjC::initializeWithCon > if (configuration.persistentState != CDMRequirement::Required && (configuration.sessionTypes.contains(CDMSessionType::PersistentUsageRecord) || configuration.sessionTypes.contains(CDMSessionType::PersistentLicense))) > return Failed; > >- if (configuration.persistentState == CDMRequirement::Required && !m_storageDirectory) >+ if (configuration.persistentState == CDMRequirement::Required && !m_storageURL) > return Failed; > > if (configuration.sessionTypes.contains(CDMSessionType::PersistentLicense) && !supportsPersistentKeys()) >@@ -202,10 +203,30 @@ CDMInstance::SuccessValue CDMInstanceFairPlayStreamingAVFObjC::setServerCertific > > CDMInstance::SuccessValue CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory(const String& storageDirectory) > { >- if (storageDirectory.isEmpty()) >- m_storageDirectory = nil; >- else >- m_storageDirectory = adoptNS([[NSURL alloc] initFileURLWithPath:storageDirectory isDirectory:YES]); >+ if (storageDirectory.isEmpty()) { >+ m_storageURL = nil; >+ return Succeeded; >+ } >+ >+ auto storagePath = FileSystem::pathByAppendingComponent(storageDirectory, "SecureStop.plist"); >+ >+ if (!FileSystem::fileExists(storageDirectory)) { >+ if (!FileSystem::makeAllDirectories(storageDirectory)) >+ return Failed; >+ } else if (!FileSystem::fileIsDirectory(storageDirectory, FileSystem::ShouldFollowSymbolicLinks::Yes)) { >+ auto tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys"); >+ if (!tempDirectory) >+ return Failed; >+ >+ auto tempStoragePath = FileSystem::pathByAppendingComponent(tempDirectory, FileSystem::pathGetFileName(storagePath)); >+ if (!FileSystem::moveFile(storageDirectory, tempStoragePath)) >+ return Failed; >+ >+ if (!FileSystem::moveFile(tempDirectory, storageDirectory)) >+ return Failed; >+ } >+ >+ m_storageURL = adoptNS([[NSURL alloc] initFileURLWithPath:storagePath isDirectory:NO]); > return Succeeded; > } > >@@ -341,15 +362,15 @@ void CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense(const String&, Li > [expiredSessions addObject:session.get()]; > > auto* certificate = m_instance->serverCertificate(); >- auto* storageDirectory = m_instance->storageDirectory(); >+ auto* storageURL = m_instance->storageURL(); > >- if (!certificate || !storageDirectory) { >+ if (!certificate || !storageURL) { > callback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); > return; > } > > RetainPtr<NSData> appIdentifier = certificate->createNSData(); >- [getAVContentKeySessionClass() removePendingExpiredSessionReports:expiredSessions.get() withAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageDirectory]; >+ [getAVContentKeySessionClass() removePendingExpiredSessionReports:expiredSessions.get() withAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageURL]; > callback(false, { }, WTF::nullopt, WTF::nullopt, Succeeded); > return; > } >@@ -389,8 +410,8 @@ void CDMInstanceSessionFairPlayStreamingAVFObjC::loadSession(LicenseType license > { > UNUSED_PARAM(origin); > if (licenseType == LicenseType::PersistentUsageRecord) { >- auto* storageDirectory = m_instance->storageDirectory(); >- if (!m_instance->persistentStateAllowed() || storageDirectory) { >+ auto* storageURL = m_instance->storageURL(); >+ if (!m_instance->persistentStateAllowed() || storageURL) { > callback(WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed, SessionLoadFailure::MismatchedSessionType); > return; > } >@@ -402,7 +423,7 @@ void CDMInstanceSessionFairPlayStreamingAVFObjC::loadSession(LicenseType license > > RetainPtr<NSData> appIdentifier = certificate->createNSData(); > KeyStatusVector changedKeys; >- for (NSData* expiredSessionData in [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageDirectory]) { >+ for (NSData* expiredSessionData in [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageURL]) { > NSDictionary *expiredSession = [NSPropertyListSerialization propertyListWithData:expiredSessionData options:kCFPropertyListImmutable format:nullptr error:nullptr]; > NSString *playbackSessionIdValue = (NSString *)[expiredSession objectForKey:PlaybackSessionIdKey]; > if (![playbackSessionIdValue isKindOfClass:[NSString class]]) >@@ -450,10 +471,10 @@ void CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData(const String& > [m_session expire]; > > if (licenseType == LicenseType::PersistentUsageRecord) { >- auto* storageDirectory = m_instance->storageDirectory(); >+ auto* storageURL = m_instance->storageURL(); > auto* certificate = m_instance->serverCertificate(); > >- if (!m_instance->persistentStateAllowed() || !storageDirectory || !certificate) { >+ if (!m_instance->persistentStateAllowed() || !storageURL || !certificate) { > callback({ }, WTF::nullopt, Failed); > return; > } >@@ -461,7 +482,7 @@ void CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData(const String& > RetainPtr<NSData> appIdentifier = certificate->createNSData(); > RetainPtr<NSMutableArray> expiredSessionsArray = adoptNS([[NSMutableArray alloc] init]); > KeyStatusVector changedKeys; >- for (NSData* expiredSessionData in [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageDirectory]) { >+ for (NSData* expiredSessionData in [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:appIdentifier.get() storageDirectoryAtURL:storageURL]) { > NSDictionary *expiredSession = [NSPropertyListSerialization propertyListWithData:expiredSessionData options:kCFPropertyListImmutable format:nullptr error:nullptr]; > NSString *playbackSessionIdValue = (NSString *)[expiredSession objectForKey:PlaybackSessionIdKey]; > if (![playbackSessionIdValue isKindOfClass:[NSString class]]) >@@ -689,11 +710,11 @@ AVContentKeySession* CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSession() > if (m_session) > return m_session.get(); > >- auto* storageDirectory = m_instance->storageDirectory(); >- if (!m_instance->persistentStateAllowed() || !storageDirectory) >+ auto storageURL = m_instance->storageURL(); >+ if (!m_instance->persistentStateAllowed() || !storageURL) > m_session = [getAVContentKeySessionClass() contentKeySessionWithKeySystem:getAVContentKeySystemFairPlayStreaming()]; > else >- m_session = [getAVContentKeySessionClass() contentKeySessionWithKeySystem:getAVContentKeySystemFairPlayStreaming() storageDirectoryAtURL:storageDirectory]; >+ m_session = [getAVContentKeySessionClass() contentKeySessionWithKeySystem:getAVContentKeySystemFairPlayStreaming() storageDirectoryAtURL:storageURL]; > > if (!m_session) > return nullptr;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193988
: 360514