summaryrefslogtreecommitdiffstats
path: root/src/shell.c
diff options
context:
space:
mode:
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);