Commit cd2cfbd5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make incomplete commands in -I cli_file a fatal error.

Fixes: 3995
parent 3110d6f4
......@@ -341,8 +341,11 @@ mgt_cli_cb_after(const struct cli *cli)
MGT_Complain(C_CLI, "CLI %s Wr %03u %s",
cli->ident, cli->result, VSB_data(cli->sb));
if (cli->priv == stderr &&
cli->result != CLIS_OK && *VSB_data(cli->cmd) != '-') {
if (cli->priv != stderr)
return;
if (cli->result == CLIS_TRUNCATED)
ARGV_ERR("-I file had incomplete CLI command at the end\n");
if (cli->result != CLIS_OK && *VSB_data(cli->cmd) != '-') {
ARGV_ERR("-I file CLI command failed (%d)\n%s\n",
cli->result, VSB_data(cli->sb));
}
......
......@@ -169,3 +169,23 @@ shell -err -expect {Cannot read -f file} {
}
# varnishd -spersistent is tested in p00000.vtc
# Test that incomplete CLI commands in -I causes failure
process p1 {
echo -n foobar > ${tmpdir}/_foobar
exec varnishd -n ${tmpdir}/v0 -d -a :0 -I ${tmpdir}/_foobar 2>&1
} -expect-exit 2 -start
process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
process p1 -screen-dump
process p1 -wait
process p1 {
echo 'foobar << blabla > ${tmpdir}/_foobar
exec varnishd -n ${tmpdir}/v0 -d -a :0 -I ${tmpdir}/_foobar 2>&1
} -expect-exit 2 -start
process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
process p1 -screen-dump
process p1 -wait
......@@ -522,6 +522,13 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC);
VTAILQ_REMOVE(&cs->fds, cfd, list);
if (cfd->cli->cmd != NULL) {
(void)VSB_finish(cfd->cli->cmd);
cfd->cli->result = CLIS_TRUNCATED;
if (cs->after != NULL)
cs->after(cfd->cli);
VSB_destroy(&cfd->cli->cmd);
}
cs->nfd--;
VSB_destroy(&cfd->cli->sb);
if (cfd->closefunc != NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment