config file for the webserver, allow drop of root priv.
This commit is contained in:
parent
c716c1154f
commit
d5674c13e3
4 changed files with 14 additions and 12 deletions
8
config.js
Normal file
8
config.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// webserver configuration
|
||||||
|
|
||||||
|
// listen port
|
||||||
|
exports.port = 80;
|
||||||
|
|
||||||
|
// uid and gid to drop root priv.
|
||||||
|
exports.uid = 'light';
|
||||||
|
exports.gid = 'users';
|
4
dmx.js
4
dmx.js
|
@ -1,4 +1,5 @@
|
||||||
var events = require('events')
|
var events = require('events')
|
||||||
|
, config = require('./config.js')
|
||||||
, web = require('./web.js')
|
, web = require('./web.js')
|
||||||
, setup = require('./setup.js').setup
|
, setup = require('./setup.js').setup
|
||||||
, devices = require('./devices.js').devices
|
, devices = require('./devices.js').devices
|
||||||
|
@ -7,6 +8,7 @@ var events = require('events')
|
||||||
|
|
||||||
var dmx = new events.EventEmitter();
|
var dmx = new events.EventEmitter();
|
||||||
|
|
||||||
|
dmx.config = config;
|
||||||
dmx.setup = setup;
|
dmx.setup = setup;
|
||||||
dmx.devices = devices;
|
dmx.devices = devices;
|
||||||
dmx.drivers = {};
|
dmx.drivers = {};
|
||||||
|
@ -22,4 +24,4 @@ for(var universe in setup.universes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
web.init(dmx);
|
web.init(dmx);
|
||||||
|
|
8
setup.js
8
setup.js
|
@ -1,11 +1,3 @@
|
||||||
// listen port
|
|
||||||
exports.port = 80;
|
|
||||||
|
|
||||||
// uid and gid to drop root priv.
|
|
||||||
exports.uid = 'light';
|
|
||||||
exports.gid = 'users';
|
|
||||||
|
|
||||||
// setup devices
|
|
||||||
exports.setup = {
|
exports.setup = {
|
||||||
presets: [
|
presets: [
|
||||||
{
|
{
|
||||||
|
|
6
web.js
6
web.js
|
@ -49,10 +49,10 @@ exports.init = function(dmx) {
|
||||||
|
|
||||||
|
|
||||||
var app = http.createServer(handler)
|
var app = http.createServer(handler)
|
||||||
app.listen(setup.port, '::', null, function() {
|
app.listen(dmx.config.port, '::', null, function() {
|
||||||
try {
|
try {
|
||||||
process.setuid(setup.uid);
|
process.setgid(dmx.config.gid);
|
||||||
process.setgid(setup.gid);
|
process.setuid(dmx.config.uid);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Reference in a new issue