Fix early error check skipping password prompt
This commit is contained in:
parent
b69a62ef3d
commit
1698b73841
1 changed files with 5 additions and 5 deletions
10
index.js
10
index.js
|
@ -29,17 +29,17 @@ Sudo.Mac = function(command, end, count) {
|
||||||
// Run sudo in non-interactive mode (-n).
|
// Run sudo in non-interactive mode (-n).
|
||||||
Node.child.exec('sudo -n ' + command,
|
Node.child.exec('sudo -n ' + command,
|
||||||
function(error, stdout, stderr) {
|
function(error, stdout, stderr) {
|
||||||
if (error) return end(error);
|
if (/sudo: a password is required/i.test(stderr)) {
|
||||||
if (stderr !== 'sudo: a password is required\n') {
|
|
||||||
if (/^sudo:/i.test(stderr)) return end(stderr);
|
|
||||||
end(error, stdout, stderr);
|
|
||||||
} else {
|
|
||||||
Sudo.Mac.prompt(
|
Sudo.Mac.prompt(
|
||||||
function(error) {
|
function(error) {
|
||||||
if (error) return end(error);
|
if (error) return end(error);
|
||||||
Sudo.Mac(command, end, ++count); // Cannot use ++ suffix here.
|
Sudo.Mac(command, end, ++count); // Cannot use ++ suffix here.
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} else if (!error && /^sudo:/i.test(stderr)) {
|
||||||
|
end('Unexpected stderr from sudo command without corresponding error: ' + stderr);
|
||||||
|
} else {
|
||||||
|
end(error, stdout, stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue