diff options
author | Steve Block <steveblock@google.com> | 2010-12-21 14:18:10 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-12-21 14:18:10 +0000 |
commit | 0684b22531120aae169e5fc03e25e898991e0fd6 (patch) | |
tree | 2f827cf1224cb944f4a0335c414856a8d5153043 | |
parent | 15c397de884b833e41ae7fecd67e47ce89913267 (diff) | |
download | external_webkit-0684b22531120aae169e5fc03e25e898991e0fd6.zip external_webkit-0684b22531120aae169e5fc03e25e898991e0fd6.tar.gz external_webkit-0684b22531120aae169e5fc03e25e898991e0fd6.tar.bz2 |
Set 660 permissions on Appcache database
Bug: 3244281
Change-Id: I5c90f44c4e8c3cd7d1ae2652e5d9f864a69b5dfe
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index d293942..c971493 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -36,6 +36,7 @@ #include "Database.h" #include "Document.h" #include "EditorClientAndroid.h" +#include "FileSystem.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" @@ -60,6 +61,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", @@ -418,13 +421,20 @@ public: s->setOfflineWebApplicationCacheEnabled(flag); str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath); if (str) { - WTF::String path = jstringToWtfString(env, str); - if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) { - WebCore::cacheStorage().setCacheDirectory(path); + String path = jstringToWtfString(env, str); + if (path.length() && cacheStorage().cacheDirectory().isNull()) { + 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->GetLongField(obj, gFieldIds->mAppCacheMaxSize); - WebCore::cacheStorage().setMaximumSize(maxsize); + cacheStorage().setMaximumSize(maxsize); #endif flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically); @@ -470,7 +480,7 @@ public: // 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, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } @@ -500,7 +510,7 @@ public: // permissions. The filename must match that in // GeolocationPositionCache.cpp. String filename = 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); } |