summaryrefslogtreecommitdiffstats
path: root/src/shell.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-12 18:54:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-12 18:54:16 +0200
commitd468ffff4564ac0d6fb1b13d886ee72785d329ef (patch)
tree52b54fc5f1e020b928c01228d1be413dd3aa8e74 /src/shell.c
parent78de22fd21b348fc00dde6fa0bfec73abb8fd651 (diff)
downloadfastd-d468ffff4564ac0d6fb1b13d886ee72785d329ef.tar
fastd-d468ffff4564ac0d6fb1b13d886ee72785d329ef.zip
Add pre-up and post-down handlers
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c15
1 files changed, 14 insertions, 1 deletions
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);