CyTube/lib/setuid.js
bush6 ca0f0c4086 set uid timeout
Allow the timeout to be changed allowing more time before dropping root
privledges
2015-02-24 08:08:43 +10:00

16 lines
613 B
JavaScript

var Config = require("./config");
if (Config.get("setuid.enabled")) {
setTimeout(function() {
try {
console.log('Old User ID: ' + process.getuid() + ', Old Group ID: ' + process.getgid());
process.setgid(Config.get("setuid.group"));
process.setuid(Config.get("setuid.user"));
console.log('New User ID: ' + process.getuid() + ', New Group ID: ' + process.getgid());
} catch (err) {
console.log('Cowardly refusing to keep the process alive as root.');
process.exit(1);
}
}, (Config.get("setuid.timeout")));
};