diff options
| author | Steve Block <steveblock@google.com> | 2010-12-21 14:18:10 +0000 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-01-12 20:10:07 -0800 |
| commit | ffbb7741a62dd5c598ac92875ddac101bbc665c9 (patch) | |
| tree | dff4829f8ca13f2d55443cea757ca87a21b46450 | |
| parent | 200de028bfb928c1a488fa48bcbe72400d9e1202 (diff) | |
| download | external_webkit-ffbb7741a62dd5c598ac92875ddac101bbc665c9.zip external_webkit-ffbb7741a62dd5c598ac92875ddac101bbc665c9.tar.gz external_webkit-ffbb7741a62dd5c598ac92875ddac101bbc665c9.tar.bz2 | |
DO NOT MERGE - Set 660 permissions on Appcache database
Bug: 3244281, 3258386
cherry pick
Change-Id: If4a90a68df50b8b977f7fb3be668132ce839f81f
| -rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 2136f67..62a9cc8 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -33,6 +33,8 @@ #include "DatabaseTracker.h" #include "DocLoader.h" #include "Document.h" +#include "EditorClientAndroid.h" +#include "FileSystem.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" @@ -54,6 +56,8 @@ namespace android { +static const int permissionFlags660 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; + struct FieldIds { FieldIds(JNIEnv* env, jclass clazz) { mLayoutAlgorithm = env->GetFieldID(clazz, "mLayoutAlgorithm", @@ -334,6 +338,13 @@ public: WebCore::String path = to_string(env, str); if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) { WebCore::cacheStorage().setCacheDirectory(path); + // This database is created on the first load. If the file + // doesn't exist, we create it and set its permissions. The + // filename must match that in ApplicationCacheStorage.cpp. + String filename = pathByAppendingComponent(path, "ApplicationCache.db"); + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); + if (fd >= 0) + close(fd); } } jlong maxsize = env->GetIntField(obj, gFieldIds->mAppCacheMaxSize); @@ -362,8 +373,18 @@ public: if (flag) { // If the user has set the database path, sync it to the DatabaseTracker. str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); - if (str) - WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str)); + if (str) { + String path = to_string(env, str); + WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(path); + // This database is created when the first HTML5 Database object is + // instantiated. If the file doesn't exist, we create it and set its + // permissions. The filename must match that in + // DatabaseTracker.cpp. + String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "Databases.db"); + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); + if (fd >= 0) + close(fd); + } } #endif #if ENABLE(DOM_STORAGE) @@ -391,7 +412,7 @@ public: // GeolocationPositionCache.cpp. WebCore::String filename = WebCore::SQLiteFileSystem::appendDatabaseFileNameToPath( path, "CachedGeoposition.db"); - int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } |
