Title: [170313] trunk/Source/WebKit2
- Revision
- 170313
- Author
- oli...@apple.com
- Date
- 2014-06-23 13:19:35 -0700 (Mon, 23 Jun 2014)
Log Message
Ensure that we always use symlink free paths when specifying cache directories
https://bugs.webkit.org/show_bug.cgi?id=134206
Reviewed by Anders Carlsson.
Sandboxing will deny symlink based paths, so we use realpath to create extensions.
This leaves us in the position of an extension using a visually different path
from other parts of the process code. This patch simply makes sure that we always
use the realpath for cache directories, so making debugging easier and also ensuring
that we don't ever accidentally try to use a path with symlinks that will thus get
denied.
* Shared/SandboxExtension.h:
(WebKit::stringByResolvingSymlinksInPath):
* Shared/mac/SandboxExtensionMac.mm:
(WebKit::stringByResolvingSymlinksInPath):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::ensureNetworkProcess):
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformDefaultApplicationCacheDirectory):
(WebKit::WebContext::platformDefaultDiskCacheDirectory):
(WebKit::WebContext::platformDefaultWebSQLDatabaseDirectory):
(WebKit::WebContext::platformDefaultIconDatabasePath):
(WebKit::WebContext::platformDefaultLocalStorageDirectory):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (170312 => 170313)
--- trunk/Source/WebKit2/ChangeLog 2014-06-23 19:58:19 UTC (rev 170312)
+++ trunk/Source/WebKit2/ChangeLog 2014-06-23 20:19:35 UTC (rev 170313)
@@ -1,3 +1,30 @@
+2014-06-23 Oliver Hunt <oli...@apple.com>
+
+ Ensure that we always use symlink free paths when specifying cache directories
+ https://bugs.webkit.org/show_bug.cgi?id=134206
+
+ Reviewed by Anders Carlsson.
+
+ Sandboxing will deny symlink based paths, so we use realpath to create extensions.
+ This leaves us in the position of an extension using a visually different path
+ from other parts of the process code. This patch simply makes sure that we always
+ use the realpath for cache directories, so making debugging easier and also ensuring
+ that we don't ever accidentally try to use a path with symlinks that will thus get
+ denied.
+
+ * Shared/SandboxExtension.h:
+ (WebKit::stringByResolvingSymlinksInPath):
+ * Shared/mac/SandboxExtensionMac.mm:
+ (WebKit::stringByResolvingSymlinksInPath):
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::ensureNetworkProcess):
+ * UIProcess/mac/WebContextMac.mm:
+ (WebKit::WebContext::platformDefaultApplicationCacheDirectory):
+ (WebKit::WebContext::platformDefaultDiskCacheDirectory):
+ (WebKit::WebContext::platformDefaultWebSQLDatabaseDirectory):
+ (WebKit::WebContext::platformDefaultIconDatabasePath):
+ (WebKit::WebContext::platformDefaultLocalStorageDirectory):
+
2014-06-23 Roger Fong <roger_f...@apple.com>
Unregister notification observer registered in r170156.
Modified: trunk/Source/WebKit2/Shared/SandboxExtension.h (170312 => 170313)
--- trunk/Source/WebKit2/Shared/SandboxExtension.h 2014-06-23 19:58:19 UTC (rev 170312)
+++ trunk/Source/WebKit2/Shared/SandboxExtension.h 2014-06-23 20:19:35 UTC (rev 170313)
@@ -132,6 +132,9 @@
inline bool SandboxExtension::consume() { return true; }
inline bool SandboxExtension::consumePermanently() { return true; }
inline bool SandboxExtension::consumePermanently(const Handle&) { return true; }
+inline String stringByResolvingSymlinksInPath(const String& path) { return path; }
+#else
+String stringByResolvingSymlinksInPath(const String& path);
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm (170312 => 170313)
--- trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2014-06-23 19:58:19 UTC (rev 170312)
+++ trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2014-06-23 20:19:35 UTC (rev 170313)
@@ -207,6 +207,11 @@
return resolvedPath;
}
+String stringByResolvingSymlinksInPath(const String& path)
+{
+ return String::fromUTF8(resolveSymlinksInPath(path.utf8()));
+}
+
void SandboxExtension::createHandle(const String& path, Type type, Handle& handle)
{
ASSERT(!handle.m_sandboxExtension);
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (170312 => 170313)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2014-06-23 19:58:19 UTC (rev 170312)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2014-06-23 20:19:35 UTC (rev 170313)
@@ -406,7 +406,7 @@
parameters.cacheModel = m_cacheModel;
- parameters.diskCacheDirectory = diskCacheDirectory();
+ parameters.diskCacheDirectory = stringByResolvingSymlinksInPath(diskCacheDirectory());
if (!parameters.diskCacheDirectory.isEmpty())
SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle);
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (170312 => 170313)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2014-06-23 19:58:19 UTC (rev 170312)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2014-06-23 20:19:35 UTC (rev 170313)
@@ -164,7 +164,8 @@
NSString *cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
#endif
- return [cacheDir stringByAppendingPathComponent:appName];
+ NSString* cachePath = [cacheDir stringByAppendingPathComponent:appName];
+ return stringByResolvingSymlinksInPath([cachePath stringByStandardizingPath]);
}
void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
@@ -263,8 +264,7 @@
RetainPtr<NSString> cachePath = adoptNS((NSString *)WKCopyFoundationCacheDirectory());
if (!cachePath)
cachePath = @"~/Library/Caches/com.apple.WebKit.WebProcess";
-
- return [cachePath stringByStandardizingPath];
+ return stringByResolvingSymlinksInPath([cachePath stringByStandardizingPath]);
}
String WebContext::platformDefaultCookieStorageDirectory() const
@@ -278,7 +278,7 @@
NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebDatabaseDirectoryDefaultsKey];
if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
databasesDirectory = @"~/Library/WebKit/Databases";
- return [databasesDirectory stringByStandardizingPath];
+ return stringByResolvingSymlinksInPath([databasesDirectory stringByStandardizingPath]);
}
String WebContext::platformDefaultIndexedDBDatabaseDirectory()
@@ -296,7 +296,7 @@
NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebIconDatabaseDirectoryDefaultsKey];
if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
databasesDirectory = @"~/Library/Icons/WebpageIcons.db";
- return [databasesDirectory stringByStandardizingPath];
+ return stringByResolvingSymlinksInPath([databasesDirectory stringByStandardizingPath]);
}
String WebContext::platformDefaultLocalStorageDirectory()
@@ -304,7 +304,7 @@
NSString *localStorageDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebStorageDirectoryDefaultsKey];
if (!localStorageDirectory || ![localStorageDirectory isKindOfClass:[NSString class]])
localStorageDirectory = @"~/Library/WebKit/LocalStorage";
- return [localStorageDirectory stringByStandardizingPath];
+ return stringByResolvingSymlinksInPath([localStorageDirectory stringByStandardizingPath]);
}
bool WebContext::omitPDFSupport()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes