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

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, 10 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 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() { 44 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() {
39 } 45 }
(...skipping 30 matching lines...) Expand all
70 IMEDriver::Register(); 76 IMEDriver::Register();
71 #endif 77 #endif
72 78
73 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 79 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
74 // On the Linux desktop, we want to prevent the user from logging in as root, 80 // On the Linux desktop, we want to prevent the user from logging in as root,
75 // so that we don't destroy the profile. Now that we have some minimal ui 81 // so that we don't destroy the profile. Now that we have some minimal ui
76 // initialized, check to see if we're running as root and bail if we are. 82 // initialized, check to see if we're running as root and bail if we are.
77 if (geteuid() != 0) 83 if (geteuid() != 0)
78 return; 84 return;
79 85
86 // Allow running inside an unprivileged user namespace. In that case, the
87 // root directory will be owned by an unmapped UID and GID.
Jorge Lucangeli Obes 2017/04/10 13:39:47 This is not true all the time, is it? It's only tr
Kevin Cernekee 2017/04/10 21:40:21 Done.
88 struct stat st;
89 if (stat("/", &st) == 0 && st.st_uid != 0)
Jorge Lucangeli Obes 2017/04/10 13:41:18 Does this need to be HANDLE_EINTR?
Kevin Cernekee 2017/04/10 21:40:21 I don't think it is strictly necessary, although I
90 return;
91
80 const base::CommandLine& command_line = 92 const base::CommandLine& command_line =
81 *base::CommandLine::ForCurrentProcess(); 93 *base::CommandLine::ForCurrentProcess();
82 if (command_line.HasSwitch(switches::kNoSandbox)) 94 if (command_line.HasSwitch(switches::kNoSandbox))
83 return; 95 return;
84 96
85 base::string16 title = l10n_util::GetStringFUTF16( 97 base::string16 title = l10n_util::GetStringFUTF16(
86 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 98 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
87 base::string16 message = l10n_util::GetStringFUTF16( 99 base::string16 message = l10n_util::GetStringFUTF16(
88 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 100 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
89 101
(...skipping 20 matching lines...) Expand all
110 // WMState is owned as a member, so don't have MusClient create it. 122 // WMState is owned as a member, so don't have MusClient create it.
111 const bool create_wm_state = false; 123 const bool create_wm_state = false;
112 mus_client_ = base::MakeUnique<views::MusClient>( 124 mus_client_ = base::MakeUnique<views::MusClient>(
113 connection->GetConnector(), service_manager::Identity(), 125 connection->GetConnector(), service_manager::Identity(),
114 content::BrowserThread::GetTaskRunnerForThread( 126 content::BrowserThread::GetTaskRunnerForThread(
115 content::BrowserThread::IO), 127 content::BrowserThread::IO),
116 create_wm_state); 128 create_wm_state);
117 } 129 }
118 #endif // defined(USE_AURA) 130 #endif // defined(USE_AURA)
119 } 131 }
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