From d468ffff4564ac0d6fb1b13d886ee72785d329ef Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 12 Aug 2013 18:54:16 +0200 Subject: Add pre-up and post-down handlers --- src/shell.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/shell.c') diff --git a/src/shell.c b/src/shell.c index aa6dccf..1139276 100644 --- a/src/shell.c +++ b/src/shell.c @@ -43,7 +43,20 @@ bool fastd_shell_exec(fastd_context_t *ctx, const char *command, const char *dir snprintf(buf, sizeof(buf), "%u", (unsigned)getpid()); setenv("FASTD_PID", buf, 1); - setenv("INTERFACE", ctx->ifname, 1); + if (ctx->ifname) { + setenv("INTERFACE", ctx->ifname, 1); + } + else if (ctx->conf->ifname) { + char ifname[IF_NAMESIZE]; + + strncpy(ifname, ctx->conf->ifname, sizeof(ifname)-1); + ifname[sizeof(ifname)-1] = 0; + + setenv("INTERFACE", ifname, 1); + } + else { + unsetenv("INTERFACE"); + } snprintf(buf, sizeof(buf), "%u", ctx->conf->mtu); setenv("INTERFACE_MTU", buf, 1); -- cgit v1.2.3