[3.0] ca5859d Report dlerror if dlopen fails

Tollef Fog Heen tfheen at varnish-cache.org
Wed Aug 17 11:26:37 CEST 2011

commit ca5859d1557cd41854a340285237dd7c64ff9284
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Fri Aug 5 09:14:23 2011 +0200

    Report dlerror if dlopen fails
    dlopen typically only fails here if the child process does not have
    access to the build directory and the user runs varnishtest as root
    (meaning the child setuids to nobody).  Report the dlerror and give a
    hopefully helpful hint to help diagnose the error.
    Fixes: #959

diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c
index 9844413..4a4d230 100644
--- a/bin/varnishd/cache_vrt_vmod.c
+++ b/bin/varnishd/cache_vrt_vmod.c
@@ -83,7 +83,11 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const char *path)
 		REPLACE(v->path, path);
 		v->hdl = dlopen(v->path, RTLD_NOW | RTLD_LOCAL);
-		AN(v->hdl);
+		if (! v->hdl) {
+			char buf[1024];
+			sprintf(buf, "dlopen failed (child process lacks permission?): %.512s", dlerror());
+			VAS_Fail(__func__, __FILE__, __LINE__, buf, 0, 0);
+		}
 		x = dlsym(v->hdl, "Vmod_Name");

More information about the varnish-commit mailing list