Commit 6d49b18f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vcc: Restrict PRIV_TOP arguments to client tasks

Refs #3498
parent 5bf609bd
...@@ -55,6 +55,22 @@ server s1 { ...@@ -55,6 +55,22 @@ server s1 {
txresp txresp
} -start } -start
varnish v1 -errvcl "Not available in subroutine 'vcl_backend_fetch'" {
import debug;
backend be none;
sub vcl_backend_fetch {
debug.test_priv_top("only works on client side");
}
}
varnish v1 -errvcl "Not available in subroutine 'vcl_init'" {
import debug;
backend be none;
sub vcl_init {
debug.test_priv_top("only works on client side");
}
}
varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend { varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend {
import debug; import debug;
...@@ -81,22 +97,9 @@ varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend { ...@@ -81,22 +97,9 @@ varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend {
set req.http.o2 = o2.test_priv_top(""); set req.http.o2 = o2.test_priv_top("");
} }
# XXX because PRIV_TOP arguments get initialized in the
# function preamble, the mere presence of a vmod call with a
# PRIV_TOP argument in a SUB will trigger the failure if that
# sub is called at all.
#
# So to test #3498, we need to fence test_priv_top into its
# own sub
sub callingmewill503 {
debug.test_priv_top("only works on client side");
}
sub vcl_backend_fetch { sub vcl_backend_fetch {
if (bereq.url == "/fail") { if (bereq.url == "/fail") {
call callingmewill503; # dynamic priv not checked at compile time
}
if (bereq.url == "/failo") {
o2.test_priv_top("only works on client side"); o2.test_priv_top("only works on client side");
} }
} }
...@@ -123,17 +126,8 @@ client c1 { ...@@ -123,17 +126,8 @@ client c1 {
varnish v1 -expect client_req == 2 varnish v1 -expect client_req == 2
client c1 {
txreq -url /fail
rxresp
expect resp.status == 503
} -start
client c2 { client c2 {
txreq -url /failo txreq -url /fail
rxresp rxresp
expect resp.status == 503 expect resp.status == 503
} -start } -run
client c1 -wait
client c2 -wait
...@@ -341,7 +341,7 @@ sym_expr_t vcc_Eval_Handle; ...@@ -341,7 +341,7 @@ sym_expr_t vcc_Eval_Handle;
sym_expr_t vcc_Eval_SymFunc; sym_expr_t vcc_Eval_SymFunc;
sym_expr_t vcc_Eval_TypeMethod; sym_expr_t vcc_Eval_TypeMethod;
void vcc_Eval_Func(struct vcc *, const struct vjsn_val *, void vcc_Eval_Func(struct vcc *, const struct vjsn_val *,
const char *, const struct symbol *); const char *, struct symbol *);
void VCC_GlobalSymbol(struct symbol *, vcc_type_t fmt, const char *pfx); void VCC_GlobalSymbol(struct symbol *, vcc_type_t fmt, const char *pfx);
struct symbol *VCC_HandleSymbol(struct vcc *, vcc_type_t , const char *); struct symbol *VCC_HandleSymbol(struct vcc *, vcc_type_t , const char *);
void VCC_SymName(struct vsb *, const struct symbol *); void VCC_SymName(struct vsb *, const struct symbol *);
......
...@@ -351,7 +351,7 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, struct token *t, ...@@ -351,7 +351,7 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, struct token *t,
*/ */
static struct expr * static struct expr *
vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym) vcc_priv_arg(struct vcc *tl, const char *p, struct symbol *sym)
{ {
char buf[64]; char buf[64];
struct inifin *ifp; struct inifin *ifp;
...@@ -377,6 +377,7 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym) ...@@ -377,6 +377,7 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
marklist = &tl->curproc->priv_tasks; marklist = &tl->curproc->priv_tasks;
} else if (!strcmp(p, "PRIV_TOP")) { } else if (!strcmp(p, "PRIV_TOP")) {
f = "top"; f = "top";
sym->r_methods &= VCL_MET_TASK_C;
marklist = &tl->curproc->priv_tops; marklist = &tl->curproc->priv_tops;
} else { } else {
WRONG("Wrong PRIV_ type"); WRONG("Wrong PRIV_ type");
...@@ -641,7 +642,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, ...@@ -641,7 +642,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv,
void void
vcc_Eval_Func(struct vcc *tl, const struct vjsn_val *spec, vcc_Eval_Func(struct vcc *tl, const struct vjsn_val *spec,
const char *extra, const struct symbol *sym) const char *extra, struct symbol *sym)
{ {
struct expr *e = NULL; struct expr *e = 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