[master] a1b74f7 Allow ACLs to be unreferenced when vcc_err_unref=off.

Poul-Henning Kamp phk at FreeBSD.org
Mon May 19 08:47:00 CEST 2014


commit a1b74f7b57d8a95abbbc0fa74217a09f8f06a39f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 19 06:45:44 2014 +0000

    Allow ACLs to be unreferenced when vcc_err_unref=off.
    
    Add a reference from the init function to any non-anonymous match_acl_*()
    functions to ensure the compiler does not barf.
    
    Fixes	#1504

diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc
new file mode 100644
index 0000000..0277c65
--- /dev/null
+++ b/bin/varnishtest/tests/r01504.vtc
@@ -0,0 +1,10 @@
+varnishtest "unreferenced acls"
+
+varnish v1 -arg "-p vcc_err_unref=off" -vcl {
+	backend s1 {
+		.host = "${bad_ip}";
+	}
+	acl foo {
+		"127.0.0.1";
+	}
+}
diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index 1ab670a..997ae3c 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -343,13 +343,14 @@ vcc_acl_entry(struct vcc *tl)
  */
 
 static void
-vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
+vcc_acl_emit(struct vcc *tl, const char *acln, int anon)
 {
 	struct acl_e *ae;
 	int depth, l, m, i;
 	unsigned at[VRT_ACL_MAXADDR + 1];
 	const char *oc;
 	struct token *t;
+	struct inifin *ifp;
 
 	Fh(tl, 0, "\nstatic int\n");
 	Fh(tl, 0,
@@ -364,6 +365,11 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
 	Fh(tl, 0, "\t\tVRT_acl_log(ctx, \"NO_FAM %s\");\n", acln);
 	Fh(tl, 0, "\t\treturn(0);\n");
 	Fh(tl, 0, "\t}\n\n");
+	if (!tl->err_unref && !anon ) {
+		ifp = New_IniFin(tl);
+		VSB_printf(ifp->ini,
+			"\tif (0) match_acl_named_%s(0, 0);\n", acln);
+	}
 	depth = -1;
 	oc = 0;
 	at[0] = 256;



More information about the varnish-commit mailing list