From 286626df575ae0359a45b7abab78da6fbaedfea8 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sun, 8 Jul 2012 17:49:43 -0700 Subject: [PATCH] rlgwebd.js: Unlink control socket at startup. Unlinking at shutdown doesn't work because at that time, the process is chroot'ed and unprivileged. --- rlgwebd.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rlgwebd.js b/rlgwebd.js index 1129af6..75c0bb6 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -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);