summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 15:13:57 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 15:13:57 +0000
commit01e2a1fabe5a6d0065f535a9de4bdd98f0640906 (patch)
tree2050dd5669e2907324d13002cb261ffa15c8d1f9 /base/file_util_posix.cc
parent4979b09a75936283a62772b7078de381d60061fc (diff)
downloadchromium_src-01e2a1fabe5a6d0065f535a9de4bdd98f0640906.zip
chromium_src-01e2a1fabe5a6d0065f535a9de4bdd98f0640906.tar.gz
chromium_src-01e2a1fabe5a6d0065f535a9de4bdd98f0640906.tar.bz2
Use realpath() to find the path to the extension unpack dir on posix systems.
Extensions are unpacked by a sandboxed utility process. The sandbox forbids file access outside the directory the extension will be unpacked in. If the path to that directory contains a symbolic link, then unpacking will fail because following the link will cause file system access outside the sandbox path. Use realpath() to get a symlink free path to the directory where the extension will be unpacked. A similar issue exists on windows, with junctions instead of symlinks. This will be fixed in another change. BUG=13044,35198 TEST=FileUtilTest.RealPath Review URL: http://codereview.chromium.org/2001013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r--base/file_util_posix.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index d9cbe09..9db41fe 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -14,6 +14,7 @@
#include <string.h>
#include <sys/errno.h>
#include <sys/mman.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -735,6 +736,15 @@ bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
return find_info.stat.st_mtime >= cutoff_time.ToTimeT();
}
+bool RealPath(const FilePath& path, FilePath* real_path) {
+ FilePath::CharType buf[PATH_MAX];
+ if (!realpath(path.value().c_str(), buf))
+ return false;
+
+ *real_path = FilePath(buf);
+ return true;
+}
+
#if !defined(OS_MACOSX)
bool GetTempDir(FilePath* path) {
const char* tmp = getenv("TMPDIR");