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

Side by Side Diff: system_utils.h

Issue 3493012: Security patches: RestartJob ignores pid, argv[0]; kill runs as child UID (Closed) Base URL: http://git.chromium.org/git/login_manager.git
Patch Set: added comments, using -1 as suid in setresuid() calls Created 10 years, 3 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 | « session_manager_unittest.cc ('k') | system_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef LOGIN_MANAGER_SYSTEM_UTILS_H_ 5 #ifndef LOGIN_MANAGER_SYSTEM_UTILS_H_
6 #define LOGIN_MANAGER_SYSTEM_UTILS_H_ 6 #define LOGIN_MANAGER_SYSTEM_UTILS_H_
7 7
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <base/basictypes.h> 10 #include <base/basictypes.h>
11 11
12 class FilePath; 12 class FilePath;
13 13
14 namespace login_manager { 14 namespace login_manager {
15 class SystemUtils { 15 class SystemUtils {
16 public: 16 public:
17 SystemUtils(); 17 SystemUtils();
18 virtual ~SystemUtils(); 18 virtual ~SystemUtils();
19 19
20 virtual int kill(pid_t pid, int signal); 20 // Sends |signal| to |pid|, with uid and euid set to |owner|.
21 // NOTE: Your saved UID is kept unchanged. If you expect to drop and regain
22 // root privs, MAKE SURE YOUR suid == 0.
23 virtual int kill(pid_t pid, uid_t owner, int signal);
21 24
22 // Returns: true if child specified by |child_spec| exited, 25 // Returns: true if child specified by |child_spec| exited,
23 // false if we time out. 26 // false if we time out.
24 virtual bool ChildIsGone(pid_t child_spec, int timeout); 27 virtual bool ChildIsGone(pid_t child_spec, int timeout);
25 28
26 virtual bool EnsureAndReturnSafeFileSize(const FilePath& file, 29 virtual bool EnsureAndReturnSafeFileSize(const FilePath& file,
27 int32* file_size_32); 30 int32* file_size_32);
28 31
29 virtual bool EnsureAndReturnSafeSize(int64 size_64, int32* size_32); 32 virtual bool EnsureAndReturnSafeSize(int64 size_64, int32* size_32);
30 33
31 // Atomically writes the given buffer into the file, overwriting any 34 // Atomically writes the given buffer into the file, overwriting any
32 // data that was previously there. Returns the number of bytes 35 // data that was previously there. Returns the number of bytes
33 // written, or -1 on error. 36 // written, or -1 on error.
34 virtual bool AtomicFileWrite(const FilePath& filename, 37 virtual bool AtomicFileWrite(const FilePath& filename,
35 const char* data, 38 const char* data,
36 int size); 39 int size);
37 40
38 private: 41 private:
39 DISALLOW_COPY_AND_ASSIGN(SystemUtils); 42 DISALLOW_COPY_AND_ASSIGN(SystemUtils);
40 }; 43 };
41 } // namespace login_manager 44 } // namespace login_manager
42 45
43 #endif // LOGIN_MANAGER_SYSTEM_UTILS_H_ 46 #endif // LOGIN_MANAGER_SYSTEM_UTILS_H_
OLDNEW
« no previous file with comments | « session_manager_unittest.cc ('k') | system_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698