Skip to content

Commit 4ce810c

Browse files
authored
Merge pull request #481 from vazub/pathfix
Remove redundant global path var and fix memory corruption
2 parents 17c6791 + 184c079 commit 4ce810c

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

src/conf.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ static uev_t etcw;
121121

122122
static TAILQ_HEAD(, conf_change) conf_change_list = TAILQ_HEAD_INITIALIZER(conf_change_list);
123123

124-
static char *path;
125-
static char *shell;
126-
127124
static int parse_conf(char *file, int is_rcsd);
128125
static void drop_changes(void);
129126

@@ -377,8 +374,6 @@ void conf_parse_cmdline(int argc, char *argv[])
377374
fstab = strdup(ptr);
378375
finit_conf = strdup(FINIT_CONF);
379376
finit_rcsd = strdup(FINIT_RCSD);
380-
path = getenv("PATH");
381-
shell = getenv("SHELL");
382377

383378
for (int i = 1; i < argc; i++)
384379
parse_arg(argv[i]);
@@ -404,13 +399,9 @@ void conf_reset_env(void)
404399
free(node);
405400
}
406401

407-
if (path)
408-
setenv("PATH", path, 1);
409-
else
402+
if (!getenv("PATH"))
410403
setenv("PATH", _PATH_STDPATH, 1);
411-
if (shell)
412-
setenv("SHELL", shell, 1);
413-
else
404+
if (!getenv("SHELL"))
414405
setenv("SHELL", _PATH_BSHELL, 1);
415406
setenv("LOGNAME", "root", 1);
416407
setenv("USER", "root", 1);

0 commit comments

Comments
 (0)