diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-09 05:58:34 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-09 05:58:34 +0000 |
commit | 8e9e6455523393bf8b6a94046515e93e90f21c20 (patch) | |
tree | 168511bf7273a7d702066f9c82a3df4594a6767c /remoting/host | |
parent | 2e2917c9acc57a1c71399fc4d0b46cd109ad7837 (diff) | |
download | chromium_src-8e9e6455523393bf8b6a94046515e93e90f21c20.zip chromium_src-8e9e6455523393bf8b6a94046515e93e90f21c20.tar.gz chromium_src-8e9e6455523393bf8b6a94046515e93e90f21c20.tar.bz2 |
Improve gksudo prompt when enabling chromoting host.
1. gksudo prompt timeout has been increased to 5 minutes,
2. gksudo is killed when the timeout expires,
3. gksudo is launched with -D instead of -m.
BUG=155920,167791
Review URL: https://chromiumcodereview.appspot.com/12207086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/setup/daemon_controller_linux.cc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/remoting/host/setup/daemon_controller_linux.cc b/remoting/host/setup/daemon_controller_linux.cc index 598b1db..5c19981 100644 --- a/remoting/host/setup/daemon_controller_linux.cc +++ b/remoting/host/setup/daemon_controller_linux.cc @@ -37,8 +37,8 @@ const char kDaemonScript[] = // Timeout for running daemon script. const int64 kDaemonTimeoutMs = 5000; -// Timeout for commands that require password prompt- 1 minute; -const int64 kSudoTimeoutMs = 60000; +// Timeout for commands that require password prompt - 5 minutes. +const int64 kSudoTimeoutSeconds = 5 * 60; std::string GetMd5(const std::string& value) { base::MD5Context ctx; @@ -101,6 +101,8 @@ static bool RunHostScriptWithTimeout( const std::vector<std::string>& args, base::TimeDelta timeout, int* exit_code) { + DCHECK(exit_code); + // As long as we're relying on running an external binary from the // PATH, don't do it as root. if (getuid() == 0) { @@ -115,17 +117,17 @@ static bool RunHostScriptWithTimeout( command_line.AppendArg(args[i]); } base::ProcessHandle process_handle; - bool result = base::LaunchProcess(command_line, - base::LaunchOptions(), - &process_handle); - if (result) { - if (exit_code) { - result = base::WaitForExitCodeWithTimeout( - process_handle, exit_code, timeout); - } - base::CloseProcessHandle(process_handle); + if (!base::LaunchProcess(command_line, base::LaunchOptions(), + &process_handle)) { + return false; } - return result; + + if (!base::WaitForExitCodeWithTimeout(process_handle, exit_code, timeout)) { + base::KillProcess(process_handle, 0, false); + return false; + } + + return true; } static bool RunHostScript(const std::vector<std::string>& args, @@ -236,7 +238,7 @@ void DaemonControllerLinux::DoSetConfigAndStart( args.push_back("--add-user"); int exit_code; if (!RunHostScriptWithTimeout( - args, base::TimeDelta::FromMilliseconds(kSudoTimeoutMs), + args, base::TimeDelta::FromSeconds(kSudoTimeoutSeconds), &exit_code) || exit_code != 0) { LOG(ERROR) << "Failed to add user to chrome-remote-desktop group."; |