Chromium Code Reviews| 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. |
|
Evan Martin
2011/08/30 17:26:38
Does it matter that you check the group, when you
Sam Kerner (Chrome)
2011/09/16 18:12:59
I considered not checking group membership if the
|
| +// * 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. |
|
Evan Martin
2011/08/30 17:26:38
What is "admin" here? It is not true that my root
Sam Kerner (Chrome)
2011/09/16 18:12:59
Updated to make it clear that this function is mac
|
| +// 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, |