Index: base/file_util.h |
diff --git a/base/file_util.h b/base/file_util.h |
index 133854b5c7c66906cddea171dc15bf98d2a88678..2cc8caaf780e901898fc848ade18972161b79529 100644 |
--- a/base/file_util.h |
+++ b/base/file_util.h |
@@ -377,6 +377,32 @@ BASE_EXPORT bool GetCurrentDirectory(FilePath* path); |
// Sets the current working directory for the process. |
BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); |
+#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 VerifyPathControlledByUser(const FilePath& base, |
+ const FilePath& path, |
+ uid_t owner_uid, |
+ gid_t group_gid); |
+#endif // defined(OS_POSIX) |
+ |
+#if defined(OS_MACOSX) |
+// Is |path| writable only by a user with administrator privileges? |
+// This function uses Mac OS conventions. The super user is assumed to have |
+// uid 0, and the administrator group is assumed to be named "admin". |
+// Testing that |path|, and every parent directory including the root of |
+// the filesystem, are owned by the superuser, 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 VerifyPathControlledByAdmin(const FilePath& path); |
+#endif // defined(OS_MACOSX) |
+ |
// A class to handle auto-closing of FILE*'s. |
class ScopedFILEClose { |
public: |