drop root privileges in node.js
This commit is contained in:
parent
95323c5ce1
commit
c716c1154f
2 changed files with 17 additions and 1 deletions
8
setup.js
8
setup.js
|
@ -1,3 +1,11 @@
|
|||
// listen port
|
||||
exports.port = 80;
|
||||
|
||||
// uid and gid to drop root priv.
|
||||
exports.uid = 'light';
|
||||
exports.gid = 'users';
|
||||
|
||||
// setup devices
|
||||
exports.setup = {
|
||||
presets: [
|
||||
{
|
||||
|
|
10
web.js
10
web.js
|
@ -49,7 +49,15 @@ exports.init = function(dmx) {
|
|||
|
||||
|
||||
var app = http.createServer(handler)
|
||||
app.listen(8080, '::');
|
||||
app.listen(setup.port, '::', null, function() {
|
||||
try {
|
||||
process.setuid(setup.uid);
|
||||
process.setgid(setup.gid);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
io.listen(app).sockets.on('connection', function (socket) {
|
||||
socket.emit('init', {'devices': dmx.devices, 'setup': dmx.setup});
|
||||
|
|
Loading…
Reference in a new issue