]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: capabilities: enable support for Linux capabilities
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Aug 2023 08:24:26 +0000 (10:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Aug 2023 09:11:50 +0000 (11:11 +0200)
commitbd84387beb26591e4dd4b77ecf970a584244973b
tree7d2ae9a2e2a4784b09841b86a5eb85a25116b159
parent4d5f7d94b97aa0cc7153ab0b39b43c81f4024e51
MEDIUM: capabilities: enable support for Linux capabilities

For a while there has been the constraint of having to run as root for
transparent proxying, and we're starting to see some cases where QUIC is
not running in socket-per-connection mode due to the missing capability
that would be needed to bind a privileged port. It's not realistic to
ask all QUIC users on port 443 to run as root, so instead let's provide
a basic support for capabilities at least on linux. The ones currently
supported are cap_net_raw, cap_net_admin and cap_net_bind_service. The
mechanism was made OS-specific with a dedicated file because it really
is. It can be easily refined later for other OSes if needed.

A new keyword "setcaps" is added to the global section, to enumerate the
capabilities that must be kept when switching from root to non-root. This
is ignored in other situations though. HAProxy has to be built with
USE_LINUX_CAP=1 for this to be supported, which is enabled by default
for linux-glibc, linux-glibc-legacy and linux-musl.

A good way to test this is to start haproxy with such a config:

    global
        uid 1000
        setcap cap_net_bind_service

    frontend test
        mode http
        timeout client 3s
        bind quic4@:443 ssl crt rsa+dh2048.pem allow-0rtt

and run it under "sudo strace -e trace=bind,setuid", then connecting
there from an H3 client. The bind() syscall must succeed despite the
user id having been switched.
Makefile
doc/configuration.txt
include/haproxy/linuxcap.h [new file with mode: 0644]
src/haproxy.c
src/linuxcap.c [new file with mode: 0644]