use real uid for killing processes instead of using euid (#206)
This commit is contained in:
parent
972228412a
commit
0da1cd5867
|
@ -16,7 +16,6 @@
|
||||||
"logplease": "^1.2.15",
|
"logplease": "^1.2.15",
|
||||||
"nocamel": "HexF/nocamel#patch-1",
|
"nocamel": "HexF/nocamel#patch-1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"ps-list": "^7.2.0",
|
|
||||||
"semver": "^7.3.4",
|
"semver": "^7.3.4",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"waitpid": "git+https://github.com/HexF/node-waitpid.git"
|
"waitpid": "git+https://github.com/HexF/node-waitpid.git"
|
||||||
|
@ -404,14 +403,6 @@
|
||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ps-list": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ps-list/-/ps-list-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-v4Bl6I3f2kJfr5o80ShABNHAokIgY+wFDTQfE+X3zWYgSGQOCBeYptLZUpoOALBqO5EawmDN/tjTldJesd0ujQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.7.0",
|
"version": "6.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||||
|
@ -873,11 +864,6 @@
|
||||||
"ipaddr.js": "1.9.1"
|
"ipaddr.js": "1.9.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ps-list": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ps-list/-/ps-list-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-v4Bl6I3f2kJfr5o80ShABNHAokIgY+wFDTQfE+X3zWYgSGQOCBeYptLZUpoOALBqO5EawmDN/tjTldJesd0ujQ=="
|
|
||||||
},
|
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "6.7.0",
|
"version": "6.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
"logplease": "^1.2.15",
|
"logplease": "^1.2.15",
|
||||||
"nocamel": "HexF/nocamel#patch-1",
|
"nocamel": "HexF/nocamel#patch-1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"ps-list": "^7.2.0",
|
|
||||||
"semver": "^7.3.4",
|
"semver": "^7.3.4",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"waitpid": "git+https://github.com/HexF/node-waitpid.git"
|
"waitpid": "git+https://github.com/HexF/node-waitpid.git"
|
||||||
|
|
|
@ -5,7 +5,6 @@ const path = require('path');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const globals = require('./globals');
|
const globals = require('./globals');
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises');
|
||||||
const ps_list = require('ps-list');
|
|
||||||
const wait_pid = require('waitpid');
|
const wait_pid = require('waitpid');
|
||||||
|
|
||||||
const job_states = {
|
const job_states = {
|
||||||
|
@ -194,8 +193,25 @@ class Job {
|
||||||
async cleanup_processes(){
|
async cleanup_processes(){
|
||||||
let processes = [1];
|
let processes = [1];
|
||||||
while(processes.length > 0){
|
while(processes.length > 0){
|
||||||
processes = await ps_list();
|
processes = await new Promise((resolve, reject) => cp.execFile('ps', ['awwxo', 'pid,ruid'], function(err, stdout) {
|
||||||
processes = processes.filter(proc => proc.uid == this.uid);
|
if(err === null){
|
||||||
|
const lines = stdout.split('\n').slice(1); //Remove header with slice
|
||||||
|
const procs = lines.map(line => {
|
||||||
|
const [pid, ruid] = line
|
||||||
|
.trim()
|
||||||
|
.split(/\s+/)
|
||||||
|
.map(n => parseInt(n));
|
||||||
|
|
||||||
|
return { pid, ruid }
|
||||||
|
})
|
||||||
|
resolve(procs)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
processes = processes.filter(proc => proc.ruid == this.uid);
|
||||||
|
|
||||||
for(const proc of processes){
|
for(const proc of processes){
|
||||||
// First stop the processes, but keep their resources allocated so they cant re-fork
|
// First stop the processes, but keep their resources allocated so they cant re-fork
|
||||||
|
|
Loading…
Reference in New Issue