Commit 4d0710d4 authored by Geoff Simmons's avatar Geoff Simmons

Pass the varnishd worker environment to the invoked process.

parent f89ff340
......@@ -25,6 +25,7 @@ AC_PROG_CPP
AC_PATH_PROG([CAT], [cat], [])
AC_PATH_PROG([TR], [tr], [])
AC_PATH_PROG([SED], [sed], [])
AC_PATH_PROG([ENV], [env], [])
AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
......
......@@ -30,7 +30,7 @@ AM_TESTS_ENVIRONMENT = \
TEST_EXTENSIONS = .vtc
VTC_LOG_COMPILER = varnishtest -v
AM_VTC_LOG_FLAGS = -Dvmod_pipe="$(VMOD_PIPE)" -Dcat="$(CAT)" -Dtr="$(TR)" \
-Dsed="$(SED)"
-Dsed="$(SED)" -Denv="$(ENV)"
TESTS = @VMOD_TESTS@
# To test an individual VTC test named test.vtc:
......
# looks like -*- vcl -*-
varnishtest "environment variables in the invoked process"
server s1 {
rxreq
txresp -body {foo bar baz quux}
} -start
varnish v1 -vcl+backend {
import ${vmod_pipe};
sub vcl_init {
new env = pipe.vdp("${env}");
env.arg("-v");
}
sub vcl_deliver {
set resp.filters = "env";
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.bodylen > 0
} -run
......@@ -47,6 +47,8 @@
#include "vcc_if.h"
extern char **environ;
#define VFAIL(ctx, type, fmt, ...) \
VRT_fail((ctx), type " pipe failure: " fmt, __VA_ARGS__)
......@@ -231,8 +233,6 @@ vdp_init(struct req *req, void **priv)
}
if (state->chldpid == 0) {
char *envp[] = { NULL };
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
......@@ -247,7 +247,7 @@ vdp_init(struct req *req, void **priv)
exit(EXIT_FAILURE);
errno = 0;
if (execve(obj->path, argv, envp) == -1) {
if (execve(obj->path, argv, environ) == -1) {
VSLb(req->vsl, SLT_Error, "vdfp_pipe: vdp %s: cannot "
"exec %s: %s", obj->name, obj->path,
vstrerror(errno));
......
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