[master] 6b933111a Dup(2) stderr before calling VCLS on -I argument.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Sep 26 19:43:05 UTC 2018
commit 6b933111a4e0267ed06307a6d3d3e0660e6dafca
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Sep 26 19:40:05 2018 +0000
Dup(2) stderr before calling VCLS on -I argument.
Fixes: #2782
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 7a427d5bf..d03ff2106 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -278,6 +278,8 @@ mgt_launch_child(struct cli *cli)
/* Open pipe for mgt->child CLI */
AZ(pipe(cp));
heritage.cli_in = cp[0];
+ assert(cp[0] > STDERR_FILENO); // See #2782
+ assert(cp[1] > STDERR_FILENO);
MCH_Fd_Inherit(heritage.cli_in, "cli_in");
child_cli_out = cp[1];
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index aada3ce2c..237fb0f7f 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -861,7 +861,8 @@ main(int argc, char * const *argv)
if (I_fd >= 0) {
fprintf(stderr, "BEGIN of -I file processing\n");
- mgt_cli_setup(I_fd, 2, 1, "-I file", mgt_I_close, stderr);
+ /* We must dup stderr, because VCLS closes the output fd */
+ mgt_cli_setup(I_fd, dup(2), 1, "-I file", mgt_I_close, stderr);
while (I_fd >= 0) {
o = VEV_Once(mgt_evb);
if (o != 1)
More information about the varnish-commit
mailing list