summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-01-13 11:39:50 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-13 11:39:50 -0800
commit0b77bcc1e3f1198bd705c0efc11d6a8be0a3b9b4 (patch)
tree4df58f018c712550473d26557886d8ef453cfda0
parent9d46b47dc0b7cd67c7573299ec7f1e677e4b58f0 (diff)
parent200de028bfb928c1a488fa48bcbe72400d9e1202 (diff)
downloadexternal_webkit-0b77bcc1e3f1198bd705c0efc11d6a8be0a3b9b4.zip
external_webkit-0b77bcc1e3f1198bd705c0efc11d6a8be0a3b9b4.tar.gz
external_webkit-0b77bcc1e3f1198bd705c0efc11d6a8be0a3b9b4.tar.bz2
am 200de028: DO NOT MERGE - Fixes webicon permissions
* commit '200de028bfb928c1a488fa48bcbe72400d9e1202': DO NOT MERGE - Fixes webicon permissions
-rw-r--r--WebKit/android/jni/WebIconDatabase.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp
index 840d161..b56b91e 100644
--- a/WebKit/android/jni/WebIconDatabase.cpp
+++ b/WebKit/android/jni/WebIconDatabase.cpp
@@ -28,6 +28,8 @@
#include "config.h"
#include "WebIconDatabase.h"
+#include "CString.h"
+#include "FileSystem.h"
#include "GraphicsJNI.h"
#include "IconDatabase.h"
#include "Image.h"
@@ -138,10 +140,27 @@ static void Open(JNIEnv* env, jobject obj, jstring path)
iconDb->setClient(gIconDatabaseClient);
LOG_ASSERT(path, "No path given to nativeOpen");
WebCore::String pathStr = to_string(env, path);
- LOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
- bool res = iconDb->open(pathStr);
- if (!res)
- LOGE("Open failed!");
+ WebCore::CString fullPath = WebCore::pathByAppendingComponent(pathStr,
+ WebCore::IconDatabase::defaultDatabaseFilename()).utf8();
+ mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+ bool didSetPermissions = false;
+ if (access(fullPath.data(), F_OK) == 0) {
+ if (chmod(fullPath.data(), mode) == 0)
+ didSetPermissions = true;
+ } else {
+ int fd = open(fullPath.data(), O_CREAT, mode);
+ if (fd >= 0) {
+ close(fd);
+ didSetPermissions = true;
+ }
+ }
+ if (didSetPermissions) {
+ LOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
+ bool res = iconDb->open(pathStr);
+ if (!res)
+ LOGE("Open failed!");
+ } else
+ LOGE("Failed to set permissions on '%s'", fullPath.data());
}
static void Close(JNIEnv* env, jobject obj)