From: Willy Tarreau Date: Mon, 15 Oct 2007 16:57:08 +0000 (+0200) Subject: [MEDIUM] fixed call to chroot() during startup X-Git-Tag: v1.3.13~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f223cc0b5c847c40060cc764cc49ac0088903a9f;p=thirdparty%2Fhaproxy.git [MEDIUM] fixed call to chroot() during startup It wasn't very wise to chroot() early during the startup. Also, the exit() was missing if the chroot() failed. --- diff --git a/src/haproxy.c b/src/haproxy.c index 7b7a691305..4e819a326f 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -870,16 +870,6 @@ int main(int argc, char **argv) pidfile = fdopen(pidfd, "w"); } - /* chroot if needed */ - if (global.chroot != NULL) { - if (chroot(global.chroot) == -1) { - Alert("[%s.main()] Cannot chroot(%s).\n", argv[0], global.chroot); - if (nb_oldpids) - tell_old_pids(SIGTTIN); - } - chdir("/"); - } - /* ulimits */ if (!global.rlimit_nofile) global.rlimit_nofile = global.maxsock; @@ -940,6 +930,17 @@ int main(int argc, char **argv) exit(1); } + /* chroot if needed */ + if (global.chroot != NULL) { + if (chroot(global.chroot) == -1) { + Alert("[%s.main()] Cannot chroot(%s).\n", argv[0], global.chroot); + if (nb_oldpids) + tell_old_pids(SIGTTIN); + exit(1); + } + chdir("/"); + } + if (nb_oldpids) tell_old_pids(oldpids_sig);