From: Maxime Henrion Date: Tue, 12 May 2026 14:21:40 +0000 (-0400) Subject: MEDIUM: startup: add automatic chroot feature X-Git-Tag: v3.4-dev13~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=641fe4f119597e06a1152b16799a06e950e2f9f3;p=thirdparty%2Fhaproxy.git MEDIUM: startup: add automatic chroot feature It is now possible to use "chroot auto" in the configuration. This lets haproxy create an anonymous (cleaned up after the process terminates) and read-only directory for chroot. This directory is created in /tmp; we might want to support creating it in a different directory in the future, either by respecting $TMPDIR or by allowing an optional directory after the "auto" keyword. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index bfed93698..97cd580ea 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2126,13 +2126,21 @@ ca-base directives. Absolute locations specified in "ca-file", "ca-verify-file" and "crl-file" prevail and ignore "ca-base". -chroot +chroot { | auto } Changes current directory to and performs a chroot() there before dropping privileges. This increases the security level in case an unknown vulnerability would be exploited, since it would make it very hard for the - attacker to exploit the system. This only works when the process is started - with superuser privileges. It is important to ensure that is both - empty and non-writable to anyone. + attacker to exploit the system. It is important to ensure that + is both empty and non-writable to anyone. When the process is started with + superuser privileges, the chroot() is performed directly. On Linux, when + started unprivileged, haproxy attempts to perform it from inside a new + user namespace created with unshare(CLONE_NEWUSER); if that mechanism is + unavailable the chroot() will fail with the usual error. + + As a special case, may be set to "auto", in which case haproxy + creates an anonymous temporary directory, unlinks it, and chroots into it. + The resulting jail has no name in the filesystem and is empty and read-only, + removing the need to prepare a dedicated jail directory. close-spread-time