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

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.h

Issue 1976403002: Fix logic for checking chrome-sandbox setuid binary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rickyz feedback Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ 5 #ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
6 #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ 6 #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
7 7
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/command_line.h"
14 #include "base/files/scoped_file.h"
13 #include "base/process/process_handle.h" 15 #include "base/process/process_handle.h"
14 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
15 #include "content/public/browser/zygote_host_linux.h" 17 #include "content/public/browser/zygote_host_linux.h"
16 18
17 namespace base { 19 namespace base {
18 template<typename Type> 20 template<typename Type>
19 struct DefaultSingletonTraits; 21 struct DefaultSingletonTraits;
20 } // namespace base 22 } // namespace base
21 23
22 namespace content { 24 namespace content {
23 25
24 class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost { 26 class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
25 public: 27 public:
26 // Returns the singleton instance. 28 // Returns the singleton instance.
27 static ZygoteHostImpl* GetInstance(); 29 static ZygoteHostImpl* GetInstance();
28 30
29 void Init(const std::string& sandbox_cmd); 31 void Init(const base::CommandLine& cmd_line);
30
31 // Retrieves the sandbox command passed into Init();
32 const std::string& SandboxCommand() const;
33
34 // Tells the ZygoteHost the PIDs of all the zygotes.
35 void AddZygotePid(pid_t pid);
36 32
37 // Returns whether or not this pid is the pid of a zygote. 33 // Returns whether or not this pid is the pid of a zygote.
38 bool IsZygotePid(pid_t pid) override; 34 bool IsZygotePid(pid_t pid) override;
39 35
40 bool ShouldUseNamespaceSandbox();
41
42 void SetRendererSandboxStatus(int status); 36 void SetRendererSandboxStatus(int status);
43 int GetRendererSandboxStatus() const override; 37 int GetRendererSandboxStatus() const override;
38
39 pid_t LaunchZygote(base::CommandLine* cmd_line, base::ScopedFD* control_fd);
44 void AdjustRendererOOMScore(base::ProcessHandle process_handle, 40 void AdjustRendererOOMScore(base::ProcessHandle process_handle,
45 int score) override; 41 int score) override;
46 42
47 private: 43 private:
48 friend struct base::DefaultSingletonTraits<ZygoteHostImpl>; 44 friend struct base::DefaultSingletonTraits<ZygoteHostImpl>;
49 45
50 ZygoteHostImpl(); 46 ZygoteHostImpl();
51 ~ZygoteHostImpl() override; 47 ~ZygoteHostImpl() override;
52 48
49 // Tells the ZygoteHost the PIDs of all the zygotes.
50 void AddZygotePid(pid_t pid);
51
53 int renderer_sandbox_status_; 52 int renderer_sandbox_status_;
54 bool should_use_namespace_sandbox_; 53
54 bool use_namespace_sandbox_;
55 bool use_suid_sandbox_;
55 bool use_suid_sandbox_for_adj_oom_score_; 56 bool use_suid_sandbox_for_adj_oom_score_;
56 std::string sandbox_binary_; 57 std::string sandbox_binary_;
58
57 // This lock protects the |zygote_pids_| set. 59 // This lock protects the |zygote_pids_| set.
58 base::Lock zygote_pids_lock_; 60 base::Lock zygote_pids_lock_;
59 // This is a set of PIDs representing all the running zygotes. 61 // This is a set of PIDs representing all the running zygotes.
60 std::set<pid_t> zygote_pids_; 62 std::set<pid_t> zygote_pids_;
61 }; 63 };
62 64
63 } // namespace content 65 } // namespace content
64 66
65 #endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ 67 #endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
OLDNEW
« no previous file with comments | « content/browser/zygote_host/zygote_communication_linux.cc ('k') | content/browser/zygote_host/zygote_host_impl_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698