BUG/MEDIUM: resolvers: make "show resolvers" properly yield
authorWilly Tarreau <w@1wt.eu>
Thu, 5 May 2022 14:00:45 +0000 (16:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 May 2022 16:13:35 +0000 (18:13 +0200)
commit4e047e7d0e2c1d11c0c9d8621060c080fc017d46
treeff167e3f2573f823e7d8eefe1ecc9d13016bad1e
parent89e236f246fa7d643a1cbe5c50fec708faa52f0f
BUG/MEDIUM: resolvers: make "show resolvers" properly yield

The "show resolvers" command is bogus, it tries to implement a yielding
mechanism except that if it yields it restarts from the beginning, until
it manages to fill the buffer with only line breaks, and faces error -2
that lets it reach the final state and exit.

The risk is low since it requires about 50 name servers to reach that
state, but it's not impossible, especially when using multiple sections.

In addition, the extraneous line breaks, if sent over an interactive
connection, will desynchronize the commands and make the client believe
the end was reached after the first nameserver. This cannot be fixed
separately because that would turn this bug into an infinite loop since
it's the line feed that manages to fill the buffer and stop it.

The fix consists in saving the current resolvers section into ctx.cli.p1
and the current nameserver into ctx.cli.p2.

This should be backported, but that code moved a lot since it was
introduced and has always been bogus. It looks like it has mostly
stabilized in 2.4 with commit c943799c86 so the fix might be backportable
to 2.4 without too much effort.
src/resolvers.c