Index: base/file_util.h |
diff --git a/base/file_util.h b/base/file_util.h |
index cd7fa9fafcbe68865e578b3c173adb84419e34e7..4a53fbf392f344c25ba0bfde51bfe43f7ab57427 100644 |
--- a/base/file_util.h |
+++ b/base/file_util.h |
@@ -659,6 +659,28 @@ enum FileSystemType { |
BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
#endif |
+#if defined(OS_POSIX) |
+// Test that |path| can only be changed by a specific user and group. |
+// Specifically, test that all parts of |path| under (and including) |base|: |
+// * Exist. |
+// * Are owned by a specific user and group. |
+// * Are not writable by all users. |
+// * Are not symbolic links. |
+// This is useful for checking that a config file is administrator-controlled. |
+// |base| must contain |path|. |
+BASE_EXPORT bool IsPathControlledByUser(const FilePath& base, |
+ const FilePath& path, |
+ uid_t owner_uid, |
+ gid_t group_gid); |
+ |
+// Is |path| writable only by a user with administrator privileges? |
+// Check this by testing that |path|, and every parent directory including |
+// the root of the filesystem, are owned by root, controlled by the group |
+// "admin", are not writable by all users, and contain no symbolic links. |
+// Will return false if |path| does not exist. |
+BASE_EXPORT bool IsPathControlledByAdmin(const FilePath& path); |
+#endif // defined(OS_POSIX) |
+ |
} // namespace file_util |
// Deprecated functions have been moved to this separate header file, |