]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: startup: revisit the default chroot behavior
authorWilly Tarreau <w@1wt.eu>
Tue, 24 Nov 2026 13:58:57 +0000 (14:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 24 Nov 2026 14:24:56 +0000 (15:24 +0100)
commit064c7793bd0f56b0a45629cc1462b0a04b3147f2
tree384fe95a7384a920653423b73ae154c410e8e38f
parent3ed8b1aad5d28ddd66a9a5f2cabd359f2d7cbc94
BUG/MEDIUM: startup: revisit the default chroot behavior

A few users reported the following pattern at boot:

  geteuid()                               = 1000
  prctl(PR_CAPBSET_READ, CAP_SYS_CHROOT)  = 1
  mkdir("/tmp/haproxy.wbFFQW", 0700)      = 0
  chdir("/tmp/haproxy.wbFFQW")            = 0
  rmdir("/tmp/haproxy.wbFFQW")            = 0
  chroot(".")                             = -1 EPERM (Operation not permitted)
  geteuid()                               = 1000
  getegid()                               = 1000
  unshare(CLONE_NEWUSER)                  = 0
  chroot(".")                             = -1 EPERM (Operation not permitted)

I.e. everything looks like we'llb be able to chroot but we fail to. And
that's pretty annoying because it reports a warning after that, speaking
about starting as root while it is not the case.

A first approach would consist in relaxing the rules around "auto" but
that's not good because users writing "chroot auto" *want* a chroot to
be performed (and it's actually the safest one since it has no "." nor
"..").

This patch clarifies the situation by introducing a new "opportunistic"
mode, that noone needs to type since it's the default. In this mode, no
error is reported during the attempt to chroot. However on failure, if
the user was root, a warning is reported to indicate that it's strange,
and suggests to use chroot / instead if needed.

In this case the conditions producing the trace above will no longer
display any irritating message on a config without chroot directive,
but users of "chroot auto" will still be told what's wrong.

This only affects 3.5 so no backport is needed.
doc/configuration.txt
src/haproxy.c