]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: startup: do not execute chroot() when "/"
authorWilly Tarreau <w@1wt.eu>
Wed, 20 May 2026 09:05:17 +0000 (11:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 20 May 2026 09:46:43 +0000 (11:46 +0200)
We'll recommend to use "chroot /" to explicitly disable chroot, however
there might be configurations where it would cause problems to just issue
the syscall (typically some hardened containers), so let's make sure that
"chroot /" is a nop in this case.

src/haproxy.c

index 3a43187539edeaa7d4b7c4334490a4a37b3eb8c2..68ab5d5eeccedc83b81c43d021b6fda4a0e8de2b 100644 (file)
@@ -3351,7 +3351,7 @@ static int do_chroot(const char *prog, const char *path)
                DISGUISE(rmdir(tmpdir));
                if (!error)
                        error = chroot(".");
-       } else {
+       } else if (strcmp(path, "/") != 0) {
                error = chroot(path);
        }
        if (!error)