Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
cd2cfbd5
Commit
cd2cfbd5
authored
Oct 11, 2023
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make incomplete commands in -I cli_file a fatal error.
Fixes: 3995
parent
3110d6f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
mgt_cli.c
bin/varnishd/mgt/mgt_cli.c
+5
-2
u00000.vtc
bin/varnishtest/tests/u00000.vtc
+20
-0
vcli_serve.c
lib/libvarnish/vcli_serve.c
+7
-0
No files found.
bin/varnishd/mgt/mgt_cli.c
View file @
cd2cfbd5
...
...
@@ -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
));
}
...
...
bin/varnishtest/tests/u00000.vtc
View file @
cd2cfbd5
...
...
@@ -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
lib/libvarnish/vcli_serve.c
View file @
cd2cfbd5
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment