Skip to content

Commit d4a92fb

Browse files
committed
param: Refuse read-only setting for aliases
The alternative could have been to mark both aliases and their original parameters as protected but there isn't always a one-to-one mapping between deprecated aliases and the parameters they point to. The old vcc_* boolean parameters turned into vcc_feature flags. Refs #4323
1 parent 54a5c0e commit d4a92fb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

bin/varnishd/mgt/mgt_param.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,9 @@ mcf_param_show_json(struct cli *cli, const char * const *av, void *priv)
536536
void
537537
MCF_ParamProtect(struct cli *cli, const char *args)
538538
{
539-
char **av;
539+
const struct parspec *orig;
540540
struct parspec *pp;
541+
char **av;
541542
int i;
542543

543544
av = VAV_Parse(args, NULL, ARGV_COMMA);
@@ -552,8 +553,17 @@ MCF_ParamProtect(struct cli *cli, const char *args)
552553
if (pp == NULL) {
553554
VCLI_Out(cli, "Unknown parameter %s", av[i]);
554555
VCLI_SetResult(cli, CLIS_PARAM);
555-
VAV_Free(av);
556-
return;
556+
break;
557+
}
558+
if (pp->func == tweak_alias) {
559+
orig = TRUST_ME(pp->priv);
560+
AN(orig);
561+
VCLI_Out(cli,
562+
"Cannot mark alias %s read only.\n"
563+
"Did you mean to mark %s read only?",
564+
pp->name, orig->name);
565+
VCLI_SetResult(cli, CLIS_PARAM);
566+
break;
557567
}
558568
pp->flags |= PROTECTED;
559569
}

bin/varnishtest/tests/r04323.vtc

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ varnish v1 -arg "-r vcc_feature"
44

55
varnish v1 -clierr 107 "param.set vcc_feature all"
66
varnish v1 -clierr 107 "param.set vcc_allow_inline_c on"
7+
8+
shell -err -expect "Cannot mark alias vcc_allow_inline_c read only" {
9+
varnishd -d -r vcc_allow_inline_c -n ${tmpdir}/vd
10+
}

0 commit comments

Comments
 (0)