]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: tools: make str2sa_range() check for the sockpair's FD usability
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 08:14:16 +0000 (10:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 20:08:08 +0000 (22:08 +0200)
commita215be282d4467a01c962b10bf4132101794557c
treea59d9163bc9cb0b61c1d71ecbc2494ffc43ec06d
parent804f11fdf8ae3d55a1dd39599e6ae12000a42f46
MEDIUM: tools: make str2sa_range() check for the sockpair's FD usability

Just like for inherited sockets, we want to make sure that FDs that are
mentioned in "sockpair@" are actually usable. Right now this test is
performed by the callers, but not everywhere. Typically, the following
config will fail if fd #5 is not bound:

  frontend
      bind sockpair@5

But this one will pass if fd #6 is not bound:

  backend
      server s1 sockpair@6

Now both will return an error in such a case:
   - 'bind' : cannot use file descriptor '5' : Bad file descriptor.
   - 'server s1' : cannot use file descriptor '6' : Bad file descriptor.

As such the test in str2listener() is not needed anymore (and it was
wrong by the way, as it used to test for the socket by overwriting the
local address with a new address that's made of the FD encoded on 16
bits and happens to still be at the same place, but that strictly
depends on whatever the kernel wants to put there).
src/cfgparse.c
src/tools.c