Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chromeos / process_proxy / process_proxy.cc
index 5aa373f..b1021f4 100644 (file)
 
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/process/kill.h"
 #include "base/process/launch.h"
 #include "base/threading/thread.h"
 #include "chromeos/process_proxy/process_output_watcher.h"
+#include "third_party/cros_system_api/switches/chrome_switches.h"
 
 namespace {
 
@@ -42,7 +43,7 @@ ProcessProxy::ProcessProxy(): process_launched_(false),
   // Set pipes to initial, invalid value so we can easily know if a pipe was
   // opened by us.
   ClearAllFdPairs();
-};
+}
 
 bool ProcessProxy::Open(const std::string& command, pid_t* pid) {
   if (process_launched_)
@@ -159,10 +160,8 @@ bool ProcessProxy::Write(const std::string& text) {
 
   // We don't want to write '\0' to the pipe.
   size_t data_size = text.length() * sizeof(*text.c_str());
-  int bytes_written =
-      base::WriteFileDescriptor(pt_pair_[PT_MASTER_FD],
-                                text.c_str(), data_size);
-  return (bytes_written == static_cast<int>(data_size));
+  return base::WriteFileDescriptor(
+             pt_pair_[PT_MASTER_FD], text.c_str(), data_size);
 }
 
 bool ProcessProxy::OnTerminalResize(int width, int height) {
@@ -223,6 +222,10 @@ bool ProcessProxy::LaunchProcess(const std::string& command, int slave_fd,
   fds_mapping.push_back(std::make_pair(slave_fd, STDOUT_FILENO));
   fds_mapping.push_back(std::make_pair(slave_fd, STDERR_FILENO));
   base::LaunchOptions options;
+  // Do not set NO_NEW_PRIVS on processes if the system is in dev-mode. This
+  // permits sudo in the crosh shell when in developer mode.
+  options.allow_new_privs = base::CommandLine::ForCurrentProcess()->
+      HasSwitch(chromeos::switches::kSystemInDevMode);
   options.fds_to_remap = &fds_mapping;
   options.ctrl_terminal_fd = slave_fd;
   options.environ["TERM"] = "xterm";