Remove support for gksudo (gksudo breaks when used concurrently)

This commit is contained in:
Joran Dirk Greef 2016-06-04 13:17:14 +02:00
parent 69f6576045
commit 1e11485bf4
2 changed files with 28 additions and 10 deletions

View file

@ -113,13 +113,7 @@ function Linux(instance, end) {
if (error) return end(error);
var command = [];
command.push('"' + EscapeDoubleQuotes(binary) + '"');
if (/gksudo/i.test(binary)) {
command.push('--preserve-env');
command.push('--sudo-mode');
var description = EscapeDoubleQuotes(instance.options.name);
command.push('--description="' + description + '"');
command.push('--');
} else if (/kdesudo/i.test(binary)) {
if (/kdesudo/i.test(binary)) {
command.push('--');
} else if (/pkexec/i.test(binary)) {
command.push('--disable-internal-agent');
@ -140,11 +134,12 @@ function Linux(instance, end) {
function LinuxBinary(instance, end) {
var index = 0;
// We prefer gksudo over pkexec since it enables a better prompt:
var paths = ['/usr/bin/gksudo', '/usr/bin/pkexec', '/usr/bin/kdesudo'];
// We used to prefer gksudo over pkexec since it enabled a better prompt.
// However, gksudo cannot run multiple commands concurrently.
var paths = ['/usr/bin/pkexec', '/usr/bin/kdesudo'];
function test() {
if (index === paths.length) {
return end(new Error('Unable to find gksudo, pkexec or kdesudo.'));
return end(new Error('Unable to find pkexec or kdesudo.'));
}
var path = paths[index++];
Node.fs.stat(path,

23
test-concurrent.js Normal file
View file

@ -0,0 +1,23 @@
var sudo = require('./');
var exec = require('child_process').exec;
function kill(end) {
exec('sudo -k', end);
}
kill(
function() {
var options = {
name: 'Sudo Prompt'
};
sudo.exec('sleep 10 && echo world', options,
function(error, stdout, stderr) {
console.log(error, stdout, stderr);
}
);
sudo.exec('echo hello', options,
function(error, stdout, stderr) {
console.log(error, stdout, stderr);
}
);
}
);