diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2019-06-12 10:43:33 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-07-03 08:47:53 +0200 |
commit | f3a0ba62b015fe455648fb47561ad8a5e7945ebd (patch) | |
tree | a06ae41fc4a46ee407b049a12e382255a1c3b04c | |
parent | d755a24939eb1297a68c5bdec1ae1362b081dfd4 (diff) | |
download | barebox-f3a0ba62b015fe455648fb47561ad8a5e7945ebd.tar.gz barebox-f3a0ba62b015fe455648fb47561ad8a5e7945ebd.tar.xz |
startup: execute /env/bin/init as part of the initial shell
Commit 90df2a955e3c ("defaultenv: Convert init script to C")
unintentionally changed the way the legacy "/env/bin/init" script is
run, so that it runs in a sub-shell context, effectively changing
`run_command("source /env/bin/init");` to
`run_command("/env/bin/init");`. Therefore, any changes to shell
environment variables made by the script are undone when the script
exits. This patch reverts back to the old behavior.
Fixes: 90df2a955e3c ("defaultenv: Convert init script to C")
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/startup.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/common/startup.c b/common/startup.c index a5fd36ba48..5686c0fb32 100644 --- a/common/startup.c +++ b/common/startup.c @@ -187,11 +187,12 @@ static bool test_abort(void) return false; } +#define INITFILE "/env/bin/init" + static int run_init(void) { DIR *dir; struct dirent *d; - const char *initfile = "/env/bin/init"; const char *initdir = "/env/init"; const char *menufile = "/env/menu/mainmenu"; struct stat s; @@ -205,10 +206,10 @@ static int run_init(void) setenv("PATH", "/env/bin"); /* Run legacy /env/bin/init if it exists */ - env_bin_init_exists = stat(initfile, &s) == 0; + env_bin_init_exists = stat(INITFILE, &s) == 0; if (env_bin_init_exists) { - pr_info("running %s...\n", initfile); - run_command(initfile); + pr_info("running %s...\n", INITFILE); + run_command("source " INITFILE); return 0; } |