From 7874fefc6e55dcb25c011936c9673cc92a8cc456 Mon Sep 17 00:00:00 2001 From: Daniel Kopecek Date: Wed, 10 Aug 2016 15:27:07 +0200 Subject: [PATCH] Set SHELL environment variable in tlog-rec Set the SHELL environment variable to the actual shell. Otherwise programs trying to spawn the user's shell would start tlog-rec instead. Resolves: #48 --- src/tlog-rec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tlog-rec.c b/src/tlog-rec.c index aa1aeb6f..4205ed4d 100644 --- a/src/tlog-rec.c +++ b/src/tlog-rec.c @@ -894,6 +894,17 @@ tap_setup(struct tap *ptap, struct json_object *conf, /* Execute the shell in the child */ if (tap.pid == 0) { + /* + * Set the SHELL environment variable to the actual shell. Otherwise + * programs trying to spawn the user's shell would start tlog-rec + * instead. + */ + if (setenv("SHELL", path, /*overwrite=*/1) != 0) { + grc = TLOG_GRC_ERRNO; + fprintf(stderr, "Failed to set SHELL environment variable: %s\n", + tlog_grc_strerror(grc)); + goto cleanup; + } execv(path, argv); grc = TLOG_GRC_ERRNO; fprintf(stderr, "Failed executing %s: %s",