Skip to content

Commit

Permalink
Set SHELL environment variable in tlog-rec
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Daniel Kopecek committed Aug 10, 2016
1 parent d81e921 commit 7874fef
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/tlog-rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7874fef

Please sign in to comment.