aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-11-10 23:41:53 +0100
committerKim Alvefur <zash@zash.se>2012-11-10 23:41:53 +0100
commitacbda76a756d27c406591f0a8ca24e27f3c3f8b8 (patch)
tree1ea73ee56b60b1bba94748bc29985031b7d60c50
parent37ba438ad9c4cc135dea4043ae57be1d929a4569 (diff)
downloadprosody-acbda76a756d27c406591f0a8ca24e27f3c3f8b8.tar.gz
prosody-acbda76a756d27c406591f0a8ca24e27f3c3f8b8.zip
util.pposix: Prevent FDs 0, 1 and 2 from being assigned to connections
-rw-r--r--util-src/pposix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 191e276e..05303d99 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -89,6 +89,10 @@ static int lc_daemonize(lua_State *L)
close(0);
close(1);
close(2);
+ /* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */
+ open("/dev/null", O_RDONLY);
+ open("/dev/null", O_WRONLY);
+ open("/dev/null", O_WRONLY);
/* Final fork, use it wisely */
if(fork())