#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 {
// 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_)
// 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) {
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";