Bug 1230857 - Ensure GMPService has sufficient file permissions to delete GMPs. r?gerald draft
authorChris Pearce <cpearce@mozilla.com>
Thu, 14 Jan 2016 15:11:04 +1300
changeset 321622 c7a274b5751043bb3c6303290a41b8420f9d7141
parent 320813 e790bba372f14241addda469a4bdb7ab00786ab3
child 321623 94f267c7b4707a2190270cd7313118d008dc05da
push id9420
push usercpearce@mozilla.com
push dateThu, 14 Jan 2016 03:48:57 +0000
reviewersgerald
bugs1230857
milestone46.0a1
Bug 1230857 - Ensure GMPService has sufficient file permissions to delete GMPs. r?gerald Without this, existing installs of the Adobe x64 Windows GMP from the zip file where the GMP files are read-only will not be able to be installed.
dom/media/gmp/GMPServiceParent.cpp
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -1056,16 +1056,23 @@ GeckoMediaPluginServiceParent::RemoveOnG
     MutexAutoUnlock unlock(mMutex);
     for (auto& gmp : deadPlugins) {
       gmp->AbortAsyncShutdown();
       gmp->CloseActive(true);
     }
   }
 
   if (aDeleteFromDisk && !inUse) {
+    // Ensure the GMP dir and all files in it are writable, so we have
+    // permission to delete them.
+    directory->SetPermissions(0700);
+    DirectoryEnumerator iter(directory, DirectoryEnumerator::FilesAndDirs);
+    for (nsCOMPtr<nsIFile> dirEntry; (dirEntry = iter.Next()) != nullptr;) {
+      dirEntry->SetPermissions(0700);
+    }
     if (NS_SUCCEEDED(directory->Remove(true))) {
       mPluginsWaitingForDeletion.RemoveElement(aDirectory);
       NS_DispatchToMainThread(new NotifyObserversTask("gmp-directory-deleted",
                                                       nsString(aDirectory)),
                               NS_DISPATCH_NORMAL);
     }
   }
 }