You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to raise a concern about this function, it may not be valid.
Consider what happens when you feed it with the process string '/usr/bin/sudo /sbin/dhcpcd'
function kill(process, callback) {
var all = process.split(" ");
var process = all[0];
var command = 'kill `pgrep -f "^' + process + '"` || true';
logger("killing: " + command);
return thus.exec(command, callback);
}
Splitting on spaces sets process to the string /usr/bin/sudo. It seems there is at least a small chance of killing the wrong sudo call. What is wanted is to kill the dhcpcd process.
To be more sure of hitting the target, I think something like this is needed
function kill(process, callback) {
target = process.replace(/^[^\s]*\/sudo\s+/,''); // remove prefixed sudo invocation
var all = target.split(" ");
target = all[0]; // separate command from arguments
var command = 'kill `pgrep -f "^' + target + '"` || true';
logger("killing: " + command);
return thus.exec(command, callback);
}
There's a further issue; both ethernet and wireless interfaces may have a dhcpcd process listening to them. At present the former appears in the process table as the command dhcpcd eth0, not /sbin/dhcpcd eth0, so it won't get shot down; but this is more by good luck than good management. I'm not sure how to resolve that one, possibly requiring the process argument to be a suitable regex and not splitting up the string.
The text was updated successfully, but these errors were encountered:
I want to raise a concern about this function, it may not be valid.
Consider what happens when you feed it with the process string '/usr/bin/sudo /sbin/dhcpcd'
Splitting on spaces sets
process
to the string/usr/bin/sudo
. It seems there is at least a small chance of killing the wrong sudo call. What is wanted is to kill thedhcpcd
process.To be more sure of hitting the target, I think something like this is needed
There's a further issue; both ethernet and wireless interfaces may have a
dhcpcd
process listening to them. At present the former appears in the process table as the commanddhcpcd eth0
, not/sbin/dhcpcd eth0
, so it won't get shot down; but this is more by good luck than good management. I'm not sure how to resolve that one, possibly requiring theprocess
argument to be a suitable regex and not splitting up the string.The text was updated successfully, but these errors were encountered: