OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
6 // filesystem. | 6 // filesystem. |
7 | 7 |
8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 FILE_SYSTEM_CGROUP, // cgroup control. | 652 FILE_SYSTEM_CGROUP, // cgroup control. |
653 FILE_SYSTEM_OTHER, // any other value. | 653 FILE_SYSTEM_OTHER, // any other value. |
654 FILE_SYSTEM_TYPE_COUNT | 654 FILE_SYSTEM_TYPE_COUNT |
655 }; | 655 }; |
656 | 656 |
657 // Attempts determine the FileSystemType for |path|. | 657 // Attempts determine the FileSystemType for |path|. |
658 // Returns false if |path| doesn't exist. | 658 // Returns false if |path| doesn't exist. |
659 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 659 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
660 #endif | 660 #endif |
661 | 661 |
| 662 #if defined(OS_POSIX) |
| 663 // Test that |path| can only be changed by a specific user and group. |
| 664 // Specifically, test that all parts of |path| under (and including) |base|: |
| 665 // * Exist. |
| 666 // * Are owned by a specific user and group. |
| 667 // * Are not writable by all users. |
| 668 // * Are not symbolic links. |
| 669 // This is useful for checking that a config file is administrator-controlled. |
| 670 // |base| must contain |path|. |
| 671 BASE_EXPORT bool IsPathControlledByUser(const FilePath& base, |
| 672 const FilePath& path, |
| 673 uid_t owner_uid, |
| 674 gid_t group_gid); |
| 675 |
| 676 // Is |path| writable only by a user with administrator privileges? |
| 677 // Check this by testing that |path|, and every parent directory including |
| 678 // the root of the filesystem, are owned by root, controlled by the group |
| 679 // "admin", are not writable by all users, and contain no symbolic links. |
| 680 // Will return false if |path| does not exist. |
| 681 BASE_EXPORT bool IsPathControlledByAdmin(const FilePath& path); |
| 682 #endif // defined(OS_POSIX) |
| 683 |
662 } // namespace file_util | 684 } // namespace file_util |
663 | 685 |
664 // Deprecated functions have been moved to this separate header file, | 686 // Deprecated functions have been moved to this separate header file, |
665 // which must be included last after all the above definitions. | 687 // which must be included last after all the above definitions. |
666 #include "base/file_util_deprecated.h" | 688 #include "base/file_util_deprecated.h" |
667 | 689 |
668 #endif // BASE_FILE_UTIL_H_ | 690 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |