mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
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:
2 files changed
+21
No files matched your search
+10
@@ -39,6 +39,7 @@
|
|||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
#include <paths.h>
|
||||||
#ifdef _LIBITE_LITE
|
#ifdef _LIBITE_LITE
|
||||||
# include <libite/lite.h>
|
# include <libite/lite.h>
|
||||||
#else
|
#else
|
||||||
@@ -622,6 +623,15 @@ int main(int argc, char *argv[])
|
|||||||
return EX_NOPERM;
|
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
|
* Need /dev, /proc, and /sys for console=, remount and cgroups
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,6 +82,17 @@ pid_t run_sh (char *tty, int noclear, int nowait, struct rlimit rlimi
|
|||||||
pid_t run_bg (char *cmd, char *args[]);
|
pid_t run_bg (char *cmd, char *args[]);
|
||||||
int run_parts (char *dir, char *cmd, const char *env[], int progress, int sysv);
|
int run_parts (char *dir, char *cmd, const char *env[], int progress, int sysv);
|
||||||
|
|
||||||
|
|
||||||
|
static inline int checkenv(const char *env)
|
||||||
|
{
|
||||||
|
const char *val = getenv(env);
|
||||||
|
|
||||||
|
if (!val || !val[0])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int dprint(int fd, const char *s, size_t len)
|
static inline int dprint(int fd, const char *s, size_t len)
|
||||||
{
|
{
|
||||||
size_t loop = 3;
|
size_t loop = 3;
|
||||||
|
|||||||
Reference in new issue
Block a user