Set critical env PATH + SHELL early

When running Finit under boothcartd (bootchart2 project) the PATH is
lost due to a bug.  This was a wakeup, so set critical variables in
main() early, before calling fs_init().

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2025-12-31 23:29:28 +01:00
1 parent 0dc2513b32
commit 21753e26dd
2 files changed
+21

No files matched your search

+10
View File
@@ -39,6 +39,7 @@
#include <sys/sysmacros.h>
#endif
#include <sys/prctl.h>
#include <paths.h>
#ifdef _LIBITE_LITE
# include <libite/lite.h>
#else
@@ -622,6 +623,15 @@ int main(int argc, char *argv[])
return EX_NOPERM;
}
/*
* Sanity check critical environment variables. We need PATH
* and SHELL for early commands like mount in fs_init().
*/
if (!checkenv("PATH"))
setenv("PATH", _PATH_STDPATH, 1);
if (!checkenv("SHELL"))
setenv("SHELL", _PATH_BSHELL, 1);
/*
* Need /dev, /proc, and /sys for console=, remount and cgroups
*/