From 6312e230fb237ec63b54e5aa73e4d55bc8e93057 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Thu, 27 Nov 2003 05:45:43 +0000 Subject: [PATCH] . Implement chroot. --- trunk/darkhttpd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/trunk/darkhttpd.c b/trunk/darkhttpd.c index f81c4fe..61b44ba 100644 --- a/trunk/darkhttpd.c +++ b/trunk/darkhttpd.c @@ -17,7 +17,7 @@ * x If-Modified-Since. * x Test If-Mod-Since with IE, Phoenix, lynx, links, Opera * x Keep-alive connections. - * . Chroot + * x Chroot * x Set{uid|gid}. * . Port to Win32. * x Detect Content-Type from a list of content types. @@ -2083,6 +2083,12 @@ int main(int argc, char *argv[]) err(1, "signal(SIGQUIT)"); /* security */ + if (want_chroot) + { + if (chroot(wwwroot) == -1) err(1, "chroot(\"%s\")", wwwroot); + debugf("chrooted to `%s'\n", wwwroot); + wwwroot[0] = '\0'; /* empty string */ + } if (drop_gid != INVALID_GID) { if (setgid(drop_gid) == -1) err(1, "setgid(%d)", drop_gid);