Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: base/file_util.h

Issue 8318011: Update write checks for external extension file on mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Without odd newlines this time. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | base/file_util_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 11
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 #if defined(OS_WIN) 14 #if defined(OS_WIN)
15 #include <windows.h> 15 #include <windows.h>
16 #elif defined(OS_POSIX) 16 #elif defined(OS_POSIX)
17 #include <sys/stat.h> 17 #include <sys/stat.h>
18 #include <unistd.h> 18 #include <unistd.h>
19 #endif 19 #endif
20 20
21 #include <stdio.h> 21 #include <stdio.h>
22 22
23 #include <set>
23 #include <stack> 24 #include <stack>
24 #include <string> 25 #include <string>
25 #include <vector> 26 #include <vector>
26 27
27 #include "base/base_export.h" 28 #include "base/base_export.h"
28 #include "base/basictypes.h" 29 #include "base/basictypes.h"
29 #include "base/file_path.h" 30 #include "base/file_path.h"
30 #include "base/memory/scoped_ptr.h" 31 #include "base/memory/scoped_ptr.h"
31 #include "base/platform_file.h" 32 #include "base/platform_file.h"
32 #include "base/string16.h" 33 #include "base/string16.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); 372 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size);
372 #endif 373 #endif
373 374
374 // Gets the current working directory for the process. 375 // Gets the current working directory for the process.
375 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); 376 BASE_EXPORT bool GetCurrentDirectory(FilePath* path);
376 377
377 // Sets the current working directory for the process. 378 // Sets the current working directory for the process.
378 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); 379 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path);
379 380
380 #if defined(OS_POSIX) 381 #if defined(OS_POSIX)
381 // Test that |path| can only be changed by a specific user and group. 382 // Test that |path| can only be changed by a given user and members of
383 // a given set of groups.
382 // Specifically, test that all parts of |path| under (and including) |base|: 384 // Specifically, test that all parts of |path| under (and including) |base|:
383 // * Exist. 385 // * Exist.
384 // * Are owned by a specific user and group. 386 // * Are owned by a specific user.
385 // * Are not writable by all users. 387 // * Are not writable by all users.
388 // * Are owned by a memeber of a given set of groups, or are not writable by
389 // their group.
386 // * Are not symbolic links. 390 // * Are not symbolic links.
387 // This is useful for checking that a config file is administrator-controlled. 391 // This is useful for checking that a config file is administrator-controlled.
388 // |base| must contain |path|. 392 // |base| must contain |path|.
389 BASE_EXPORT bool VerifyPathControlledByUser(const FilePath& base, 393 BASE_EXPORT bool VerifyPathControlledByUser(const FilePath& base,
390 const FilePath& path, 394 const FilePath& path,
391 uid_t owner_uid, 395 uid_t owner_uid,
392 gid_t group_gid); 396 const std::set<gid_t>& group_gids);
393 #endif // defined(OS_POSIX) 397 #endif // defined(OS_POSIX)
394 398
395 #if defined(OS_MACOSX) 399 #if defined(OS_MACOSX)
396 // Is |path| writable only by a user with administrator privileges? 400 // Is |path| writable only by a user with administrator privileges?
397 // This function uses Mac OS conventions. The super user is assumed to have 401 // This function uses Mac OS conventions. The super user is assumed to have
398 // uid 0, and the administrator group is assumed to be named "admin". 402 // uid 0, and the administrator group is assumed to be named "admin".
399 // Testing that |path|, and every parent directory including the root of 403 // Testing that |path|, and every parent directory including the root of
400 // the filesystem, are owned by the superuser, controlled by the group 404 // the filesystem, are owned by the superuser, controlled by the group
401 // "admin", are not writable by all users, and contain no symbolic links. 405 // "admin", are not writable by all users, and contain no symbolic links.
402 // Will return false if |path| does not exist. 406 // Will return false if |path| does not exist.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); 628 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
625 #endif 629 #endif
626 630
627 } // namespace file_util 631 } // namespace file_util
628 632
629 // Deprecated functions have been moved to this separate header file, 633 // Deprecated functions have been moved to this separate header file,
630 // which must be included last after all the above definitions. 634 // which must be included last after all the above definitions.
631 #include "base/file_util_deprecated.h" 635 #include "base/file_util_deprecated.h"
632 636
633 #endif // BASE_FILE_UTIL_H_ 637 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | base/file_util_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698