rlgwebd.js: Unlink control socket at startup.

Unlinking at shutdown doesn't work because at that time, the process is
chroot'ed and unprivileged.
This commit is contained in:
John "Elwin" Edwards 2012-07-08 17:49:43 -07:00
parent d0ea0471c0
commit 286626df57

View file

@ -992,7 +992,6 @@ function shutdown () {
httpServer.close();
httpServer.removeAllListeners('request');
ctlServer.close();
fs.unlink(ctlsocket);
tslog("Shutting down...");
process.exit();
}
@ -1027,6 +1026,11 @@ if (process.getuid() != 0) {
var httpServer; // declare here so shutdown() can find it
/* This could be nonblocking, but nothing else can start yet anyway. */
if (fs.existsSync(ctlsocket)) {
fs.unlinkSync(ctlsocket);
}
/* Open the control socket before chrooting where it can't be found */
var ctlServer = net.createServer(function (sock) {
sock.on('data', conHandler);