diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-10-13 18:21:27 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-10-15 02:10:36 +0200 |
commit | 3e2eb4337bc06e2331b200b5805ed09244f92bf7 (patch) | |
tree | f6fdf320de5853a28ec8b3fca3e1c4b9f3ed3533 /dhcp.c | |
parent | 40abd447c80a01fbbfa5de70ad3c33bdc1380c06 (diff) | |
download | passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar.gz passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar.bz2 passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar.lz passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar.xz passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.tar.zst passt-3e2eb4337bc06e2331b200b5805ed09244f92bf7.zip |
conf: Bind inbound ports with CAP_NET_BIND_SERVICE before isolate_user()
Even if CAP_NET_BIND_SERVICE is granted, we'll lose the capability in
the target user namespace as we isolate the process, which means
we're unable to bind to low ports at that point.
Bind inbound ports, and only those, before isolate_user(). Keep the
handling of outbound ports (for pasta mode only) after the setup of
the namespace, because that's where we'll bind them.
To this end, initialise the netlink socket for the init namespace
before isolate_user() as well, as we actually need to know the
addresses of the upstream interface before binding ports, in case
they're not explicitly passed by the user.
As we now call nl_sock_init() twice, checking its return code from
conf() twice looks a bit heavy: make it exit(), instead, as we
can't do much if we don't have netlink sockets.
While at it:
- move the v4_only && v6_only options check just after the first
option processing loop, as this is more strictly related to
option parsing proper
- update the man page, explaining that CAP_NET_BIND_SERVICE is
*not* the preferred way to bind ports, because passt and pasta
can be abused to allow other processes to make effective usage
of it. Add a note about the recommended sysctl instead
- simplify nl_sock_init_do() now that it's called once for each
case
Reported-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'dhcp.c')
0 files changed, 0 insertions, 0 deletions