Commit c94025e4 authored by Leo Iannacone's avatar Leo Iannacone

added setuid and setgid options - dropping root privileges

parent 5d8de71b
...@@ -39,6 +39,20 @@ if (config.routes.preferences) ...@@ -39,6 +39,20 @@ if (config.routes.preferences)
// Listening // Listening
var server = app.listen(config.port, config.host, null, function(){ var server = app.listen(config.port, config.host, null, function(){
// set uid e gid - drop root privileges
try {
process.setuid(config.user);
process.setgid(config.user);
} catch (err) {
if (err.code == 'EPERM') {
console.error('Changing user id %s: permission denied. Running as %s.', config.user, process.getuid());
}
else {
console.error('Error changing user id.', err)
process.exit(1)
}
}
var Client = require('./lib/client.js') var Client = require('./lib/client.js')
var Broadcaster = require('./lib/broadcaster.js') var Broadcaster = require('./lib/broadcaster.js')
......
...@@ -2,6 +2,7 @@ var config = {} ...@@ -2,6 +2,7 @@ var config = {}
config.host = 'localhost' config.host = 'localhost'
config.port = 3000 config.port = 3000
config.user = 'www-data' // who will run server
config.debomatic = {} config.debomatic = {}
config.debomatic.path = '/srv/debomatic-amd64' config.debomatic.path = '/srv/debomatic-amd64'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment