Commit 085c6a9f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Make varnishd -f honor the vcl_path

parent afb5c068
......@@ -73,6 +73,9 @@ static char Cn_arg[] = "/tmp/varnishd_C_XXXXXXX";
static struct vpf_fh *pfh1 = NULL;
static struct vpf_fh *pfh2 = NULL;
static struct vfil_path *vcl_path = NULL;
VTAILQ_HEAD(,f_arg) f_args = VTAILQ_HEAD_INITIALIZER(f_args);
int optreset; // Some has it, some doesn't. Cheaper than auto*
/*--------------------------------------------------------------------*/
......@@ -442,6 +445,27 @@ struct f_arg {
VTAILQ_ENTRY(f_arg) list;
};
static void
mgt_f_read(const char *fn)
{
struct f_arg *fa;
char *f, *fnp;
ALLOC_OBJ(fa, F_ARG_MAGIC);
AN(fa);
REPLACE(fa->farg, fn);
VFIL_setpath(&vcl_path, mgt_vcl_path);
if (VFIL_searchpath(vcl_path, NULL, &f, fn, &fnp) || f == NULL) {
ARGV_ERR("Cannot read -f file '%s' (%s)\n",
fnp != NULL ? fnp : fn, strerror(errno));
free(fnp);
}
free(fa->farg);
fa->farg = fnp;
fa->src = f;
VTAILQ_INSERT_TAIL(&f_args, fa, list);
}
static const char opt_spec[] = "a:b:Cdf:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:";
int
......@@ -473,7 +497,6 @@ main(int argc, char * const *argv)
struct vev *e;
struct f_arg *fa;
struct vsb *vsb;
VTAILQ_HEAD(,f_arg) f_args = VTAILQ_HEAD_INITIALIZER(f_args);
pid_t pid;
setbuf(stdout, NULL);
......@@ -626,14 +649,7 @@ main(int argc, char * const *argv)
novcl = 1;
break;
}
ALLOC_OBJ(fa, F_ARG_MAGIC);
AN(fa);
REPLACE(fa->farg, optarg);
fa->src = VFIL_readfile(NULL, fa->farg, NULL);
if (fa->src == NULL)
ARGV_ERR("Cannot read -f file (%s): %s\n",
fa->farg, strerror(errno));
VTAILQ_INSERT_TAIL(&f_args, fa, list);
mgt_f_read(optarg);
break;
case 'h':
h_arg = optarg;
......
varnishtest "honor vcl_path with varnishd -f"
shell {
cat >unlikely_file_name.vcl <<-EOF
vcl 4.0;
backend be {
.host = "${bad_backend}";
}
EOF
}
shell -err -expect "Cannot read -f file 'unlikely_file_name.vcl'" {
varnishd -F -a :0 -n ${tmpdir}/tmp -f unlikely_file_name.vcl
}
varnish v1 -arg "-p vcl_path=${tmpdir} -f unlikely_file_name.vcl" -start
# Even when loaded from a relative path, show an absolute one
varnish v1 -cliexpect "VCL.SHOW .+ ${tmpdir}/unlikely_file_name.vcl" "vcl.show -v boot"
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