Skip to content

Commit

Permalink
Update HOME environment variable when specifying running user with "-…
Browse files Browse the repository at this point in the history
…-username $USER"
  • Loading branch information
hmgle committed Jun 1, 2024
1 parent 8f330d3 commit cccc91c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions graftcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cidr_trie_t *WHITELACKLIST_IP = NULL;

static uid_t run_uid;
static gid_t run_gid;
static char *run_home;

static int exit_code = 0;

Expand Down Expand Up @@ -329,6 +330,8 @@ void do_child(struct graftcp_conf *conf, int argc, char **argv)
perror("setreuid");
exit(errno);
}
if (setenv("HOME", run_home, 1) < 0)
perror("setenv");
}

pid = getpid();
Expand Down Expand Up @@ -666,6 +669,7 @@ int client_main(int argc, char **argv)
}
run_gid = pent->pw_gid;
run_uid = pent->pw_uid;
run_home = strdup(pent->pw_dir);
}

init(&conf, argc - optind, argv + optind);
Expand Down

0 comments on commit cccc91c

Please sign in to comment.