summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 23:38:14 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-20 23:38:14 +0000
commit6584f0b198f115a133a8cfd62c8e778a36e386ca (patch)
treec88f8927e3abab9cebdc2f29b95d38088042b2a3 /chrome/browser
parente1b58df5167ebd4374ee36ec57ee77d4f2e68595 (diff)
downloadchromium_src-6584f0b198f115a133a8cfd62c8e778a36e386ca.zip
chromium_src-6584f0b198f115a133a8cfd62c8e778a36e386ca.tar.gz
chromium_src-6584f0b198f115a133a8cfd62c8e778a36e386ca.tar.bz2
Make standard input /dev/null when running xdg-settings to set the default browser.
BUG=17219 TEST=run chrome from a terminal in KDE and use the "set as default browser" feature when ~/.kde/share/config/profilerc is owned by root; chrome should not freeze Review URL: http://codereview.chromium.org/155796 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/shell_integration_linux.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index b970208..2d2cb05 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -4,7 +4,11 @@
#include "chrome/browser/shell_integration.h"
+#include <fcntl.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <vector>
@@ -28,12 +32,26 @@ bool ShellIntegration::SetAsDefaultBrowser() {
argv.push_back("default-web-browser");
argv.push_back(DESKTOP_APP_NAME);
- int success_code;
+ // xdg-settings internally runs xdg-mime, which uses mv to move newly-created
+ // files on top of originals after making changes to them. In the event that
+ // the original files are owned by another user (e.g. root, which can happen
+ // if they are updated within sudo), mv will prompt the user to confirm if
+ // standard input is a terminal (otherwise it just does it). So make sure it's
+ // not, to avoid locking everything up waiting for mv.
+ int devnull = open("/dev/null", O_RDONLY);
+ if (devnull < 0)
+ return false;
+ base::file_handle_mapping_vector no_stdin;
+ no_stdin.push_back(std::make_pair(devnull, STDIN_FILENO));
+
base::ProcessHandle handle;
- base::file_handle_mapping_vector no_files;
- if (!base::LaunchApp(argv, no_files, false, &handle))
+ if (!base::LaunchApp(argv, no_stdin, false, &handle)) {
+ close(devnull);
return false;
+ }
+ close(devnull);
+ int success_code;
base::WaitForExitCode(handle, &success_code);
return success_code == EXIT_SUCCESS;
}