summaryrefslogtreecommitdiffstats
path: root/base/file_util_unittest.cc
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-26 17:18:43 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-26 17:18:43 +0000
commit30fcaa494a7c2fd728821d603816d19f764857f6 (patch)
treec677bedaf9423635cf9e1f77d6e37c6f41b44d6d /base/file_util_unittest.cc
parent364d4fdc988b0706551acb574c1bdb1df800b6a1 (diff)
downloadchromium_src-30fcaa494a7c2fd728821d603816d19f764857f6.zip
chromium_src-30fcaa494a7c2fd728821d603816d19f764857f6.tar.gz
chromium_src-30fcaa494a7c2fd728821d603816d19f764857f6.tar.bz2
Get gid of created folders from stat()ing the folders, not from getgid().
BUG=97876 TEST=VerifyPathControlledByUserTest.* Review URL: http://codereview.chromium.org/8037014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_unittest.cc')
-rw-r--r--base/file_util_unittest.cc43
1 files changed, 9 insertions, 34 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 48ee211..b76938e 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1863,9 +1863,12 @@ class VerifyPathControlledByUserTest : public FileUtilTest {
text_file_ = sub_dir_.AppendASCII("file.txt");
CreateTextFile(text_file_, L"This text file has some text in it.");
- // Our user and group id.
- uid_ = getuid();
- gid_ = getgid();
+ // Get the user and group files are created with from |base_dir_|.
+ struct stat stat_buf;
+ ASSERT_EQ(0, stat(base_dir_.value().c_str(), &stat_buf));
+ uid_ = stat_buf.st_uid;
+ gid_ = stat_buf.st_gid;
+ ASSERT_EQ(uid_, getuid()); // This process should be the owner.
// To ensure that umask settings do not cause the initial state
// of permissions to be different from what we expect, explicitly
@@ -1892,14 +1895,7 @@ class VerifyPathControlledByUserTest : public FileUtilTest {
gid_t gid_;
};
-#if defined(OS_MACOSX)
-// http://crbug.com/97876
-#define MAYBE_BadPaths FAILS_BadPaths
-#else
-#define MAYBE_BadPaths BadPaths
-#endif
-
-TEST_F(VerifyPathControlledByUserTest, MAYBE_BadPaths) {
+TEST_F(VerifyPathControlledByUserTest, BadPaths) {
// File does not exist.
FilePath does_not_exist = base_dir_.AppendASCII("does")
.AppendASCII("not")
@@ -1923,13 +1919,6 @@ TEST_F(VerifyPathControlledByUserTest, MAYBE_BadPaths) {
file_util::VerifyPathControlledByUser(base_dir_, sub_dir_, uid_, gid_));
}
-#if defined(OS_MACOSX)
-// http://crbug.com/97876
-#define MAYBE_Symlinks FAILS_Symlinks
-#else
-#define MAYBE_Symlinks Symlinks
-#endif
-
TEST_F(VerifyPathControlledByUserTest, Symlinks) {
// Symlinks in the path should cause failure.
@@ -1965,14 +1954,7 @@ TEST_F(VerifyPathControlledByUserTest, Symlinks) {
file_path_with_link, file_path_with_link, uid_, gid_));
}
-#if defined(OS_MACOSX)
-// http://crbug.com/97876
-#define MAYBE_OwnershipChecks FAILS_OwnershipChecks
-#else
-#define MAYBE_OwnershipChecks OwnershipChecks
-#endif
-
-TEST_F(VerifyPathControlledByUserTest, MAYBE_OwnershipChecks) {
+TEST_F(VerifyPathControlledByUserTest, OwnershipChecks) {
// Get a uid that is not the uid of files we create.
uid_t bad_uid = uid_ + 1;
@@ -2018,14 +2000,7 @@ TEST_F(VerifyPathControlledByUserTest, MAYBE_OwnershipChecks) {
sub_dir_, text_file_, uid_, bad_gid));
}
-#if defined(OS_MACOSX)
-// http://crbug.com/97876
-#define MAYBE_WriteBitChecks FAILS_WriteBitChecks
-#else
-#define MAYBE_WriteBitChecks WriteBitChecks
-#endif
-
-TEST_F(VerifyPathControlledByUserTest, MAYBE_WriteBitChecks) {
+TEST_F(VerifyPathControlledByUserTest, WriteBitChecks) {
// Make all files and directories non-world-writable.
ASSERT_NO_FATAL_FAILURE(
ChangePosixFilePermissions(base_dir_, 0u, S_IWOTH));