Commit 2fe91380 authored by Walid Boudebouda's avatar Walid Boudebouda

VCC: Forbid the use of relative paths in +glob includes

These types of includes should be avoided since it would otherwise
be hard to predict the right behavior when matching glob patterns
in vcl_path directories.

Refs #4250
Closes #4249
parent f749531c
......@@ -67,3 +67,8 @@ client c1 {
expect resp.http.foo == foo
expect resp.http.bar == bar
} -run
varnish v1 -errvcl "+glob can only be used with absolute paths or relative paths starting with './'" {
include +glob "sub_*.vcl";
backend default none;
}
......@@ -258,7 +258,11 @@ The included file can be specified as follows:
Optionally, the ``include`` keyword can take a ``+glob`` flag to include all
files matching a glob pattern::
include +glob "example.org/*.vcl";
include +glob "/etc/varnish/example.org/*.vcl";
Note that the ``+glob`` option can only be used with absolute paths and
relative paths starting with './', which means that ``+glob`` includes cannot
be searched in ``vcl_path`` directories.
Import statement
----------------
......
......@@ -1831,7 +1831,8 @@ PARAM_STRING(
"VCL files in both the system configuration and shared "
"data directories to allow packages to drop their VCL "
"files in a standard location where relative includes "
"would work.",
"would work. Includes using +glob cannot be searched "
"in vcl_path.",
/* flags */ BUILD_OPTIONS,
/* dyn_min_reason */ NULL,
/* dyn_max_reason */ NULL,
......
......@@ -110,6 +110,13 @@ vcc_include_glob_file(struct vcc *tl, const struct source *src_sp,
unsigned u;
int i;
if (filename[0] != '/' && (filename[0] != '.' || filename[1] != '/')) {
VSB_cat(tl->sb,
"+glob can only be used with absolute paths or relative "
"paths starting with './'\n");
tl->err = 1;
return;
}
memset(g, 0, sizeof g);
i = glob(filename, 0, NULL, g);
switch (i) {
......
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