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

Side by Side Diff: chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc

Issue 2707763002: Fix unprivileged user namespace regression (Closed)
Patch Set: incorporate code review feedback Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | 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) 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 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" 5 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h"
6 6
7 #include <utility>
8
7 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" 10 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
9 #include "chrome/browser/ui/views/chrome_views_delegate.h" 11 #include "chrome/browser/ui/views/chrome_views_delegate.h"
10 #include "chrome/browser/ui/views/ime_driver/ime_driver_mus.h" 12 #include "chrome/browser/ui/views/ime_driver/ime_driver_mus.h"
11 #include "components/constrained_window/constrained_window_views.h" 13 #include "components/constrained_window/constrained_window_views.h"
12 14
13 #if defined(USE_AURA) 15 #if defined(USE_AURA)
14 #include "base/run_loop.h" 16 #include "base/run_loop.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 #include "content/public/common/service_manager_connection.h" 18 #include "content/public/common/service_manager_connection.h"
17 #include "services/service_manager/public/cpp/connector.h" 19 #include "services/service_manager/public/cpp/connector.h"
18 #include "services/service_manager/runner/common/client_util.h" 20 #include "services/service_manager/runner/common/client_util.h"
19 #include "services/ui/public/cpp/gpu/gpu.h" // nogncheck 21 #include "services/ui/public/cpp/gpu/gpu.h" // nogncheck
20 #include "services/ui/public/cpp/input_devices/input_device_client.h" 22 #include "services/ui/public/cpp/input_devices/input_device_client.h"
21 #include "services/ui/public/interfaces/constants.mojom.h" 23 #include "services/ui/public/interfaces/constants.mojom.h"
22 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom. h" 24 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom. h"
23 #include "ui/display/screen.h" 25 #include "ui/display/screen.h"
24 #include "ui/views/mus/mus_client.h" 26 #include "ui/views/mus/mus_client.h"
25 #include "ui/views/widget/desktop_aura/desktop_screen.h" 27 #include "ui/views/widget/desktop_aura/desktop_screen.h"
26 #include "ui/wm/core/wm_state.h" 28 #include "ui/wm/core/wm_state.h"
27 #endif // defined(USE_AURA) 29 #endif // defined(USE_AURA)
28 30
29 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 31 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
32 #include <sys/stat.h>
33 #include <sys/types.h>
34 #include <unistd.h>
35
30 #include "base/command_line.h" 36 #include "base/command_line.h"
31 #include "chrome/browser/ui/simple_message_box.h" 37 #include "chrome/browser/ui/simple_message_box.h"
32 #include "chrome/grit/chromium_strings.h" 38 #include "chrome/grit/chromium_strings.h"
33 #include "chrome/grit/generated_resources.h" 39 #include "chrome/grit/generated_resources.h"
34 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
35 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
36 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) 42 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
37 43
38 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
39 #include "chrome/browser/chromeos/ash_config.h" 45 #include "chrome/browser/chromeos/ash_config.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 IMEDriver::Register(); 95 IMEDriver::Register();
90 #endif 96 #endif
91 97
92 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 98 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
93 // On the Linux desktop, we want to prevent the user from logging in as root, 99 // On the Linux desktop, we want to prevent the user from logging in as root,
94 // so that we don't destroy the profile. Now that we have some minimal ui 100 // so that we don't destroy the profile. Now that we have some minimal ui
95 // initialized, check to see if we're running as root and bail if we are. 101 // initialized, check to see if we're running as root and bail if we are.
96 if (geteuid() != 0) 102 if (geteuid() != 0)
97 return; 103 return;
98 104
105 // Allow running inside an unprivileged user namespace. In that case, the
106 // root directory will be owned by an unmapped UID and GID (although this
107 // may not be the case if a chroot is also being used).
108 struct stat st;
109 if (stat("/", &st) == 0 && st.st_uid != 0)
110 return;
111
99 const base::CommandLine& command_line = 112 const base::CommandLine& command_line =
100 *base::CommandLine::ForCurrentProcess(); 113 *base::CommandLine::ForCurrentProcess();
101 if (command_line.HasSwitch(switches::kNoSandbox)) 114 if (command_line.HasSwitch(switches::kNoSandbox))
102 return; 115 return;
103 116
104 base::string16 title = l10n_util::GetStringFUTF16( 117 base::string16 title = l10n_util::GetStringFUTF16(
105 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 118 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
106 base::string16 message = l10n_util::GetStringFUTF16( 119 base::string16 message = l10n_util::GetStringFUTF16(
107 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 120 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
108 121
(...skipping 26 matching lines...) Expand all
135 148
136 // WMState is owned as a member, so don't have MusClient create it. 149 // WMState is owned as a member, so don't have MusClient create it.
137 const bool create_wm_state = false; 150 const bool create_wm_state = false;
138 mus_client_ = base::MakeUnique<views::MusClient>( 151 mus_client_ = base::MakeUnique<views::MusClient>(
139 connection->GetConnector(), service_manager::Identity(), 152 connection->GetConnector(), service_manager::Identity(),
140 content::BrowserThread::GetTaskRunnerForThread( 153 content::BrowserThread::GetTaskRunnerForThread(
141 content::BrowserThread::IO), 154 content::BrowserThread::IO),
142 create_wm_state); 155 create_wm_state);
143 #endif // defined(USE_AURA) 156 #endif // defined(USE_AURA)
144 } 157 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698