mirror of
https://github.com/topjohnwu/ndk-box-kitchen.git
synced 2024-11-23 11:29:45 +00:00
85 lines
2.7 KiB
Diff
85 lines
2.7 KiB
Diff
From b3f7ddd0ca5a8234204cd6171f04225954684c57 Mon Sep 17 00:00:00 2001
|
|
From: topjohnwu <topjohnwu@gmail.com>
|
|
Date: Mon, 15 Jul 2024 17:44:50 -0700
|
|
Subject: [PATCH 13/18] Update shell paths to Android specific values
|
|
|
|
---
|
|
include/libbb.h | 4 ++--
|
|
init/init.c | 2 +-
|
|
libbb/get_shell_name.c | 4 ++++
|
|
shell/ash.c | 4 ++--
|
|
4 files changed, 9 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/include/libbb.h b/include/libbb.h
|
|
index cae6bfb6c..2f5f61d9e 100644
|
|
--- a/include/libbb.h
|
|
+++ b/include/libbb.h
|
|
@@ -2343,12 +2343,12 @@ void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC;
|
|
* use bb_default_login_shell and following defines.
|
|
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
|
|
* don't forget to change increment constant. */
|
|
-#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
|
|
+#define LIBBB_DEFAULT_LOGIN_SHELL "-/system/bin/sh"
|
|
extern const char bb_default_login_shell[] ALIGN1;
|
|
/* "/bin/sh" */
|
|
#define DEFAULT_SHELL (bb_default_login_shell+1)
|
|
/* "sh" */
|
|
-#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
|
|
+#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+13)
|
|
|
|
/* The following devices are the same on all systems. */
|
|
#define CURRENT_TTY "/dev/tty"
|
|
diff --git a/init/init.c b/init/init.c
|
|
index 1e1ce833d..57129e9c2 100644
|
|
--- a/init/init.c
|
|
+++ b/init/init.c
|
|
@@ -1106,7 +1106,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
|
|
|
|
/* Make sure environs is set to something sane */
|
|
putenv((char *) bb_PATH_root_path);
|
|
- putenv((char *) "SHELL=/bin/sh");
|
|
+ putenv((char *) "SHELL=/system/bin/sh");
|
|
putenv((char *) "USER=root"); /* needed? why? */
|
|
/* Linux kernel sets HOME="/" when execing init,
|
|
* and it can be overridden (but not unset?) on kernel's command line.
|
|
diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c
|
|
index 5aebe9cdc..5af53bdda 100644
|
|
--- a/libbb/get_shell_name.c
|
|
+++ b/libbb/get_shell_name.c
|
|
@@ -17,6 +17,10 @@ const char* FAST_FUNC get_shell_name(void)
|
|
if (shell && shell[0])
|
|
return shell;
|
|
|
|
+#ifdef __ANDROID__
|
|
+ return DEFAULT_SHELL_SHORT_NAME;
|
|
+#endif
|
|
+
|
|
pw = getpwuid(getuid());
|
|
if (pw && pw->pw_shell && pw->pw_shell[0])
|
|
return pw->pw_shell;
|
|
diff --git a/shell/ash.c b/shell/ash.c
|
|
index 9344e4de1..19eed5451 100644
|
|
--- a/shell/ash.c
|
|
+++ b/shell/ash.c
|
|
@@ -14537,7 +14537,7 @@ procargs(char **argv)
|
|
int login_sh;
|
|
|
|
xargv = argv;
|
|
- login_sh = xargv[0] && xargv[0][0] == '-';
|
|
+ login_sh = 1; /* = xargv[0] && xargv[0][0] == '-'; - make always true for Android */
|
|
#if NUM_SCRIPTS > 0
|
|
if (minusc)
|
|
goto setarg0;
|
|
@@ -14713,7 +14713,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
|
|
const char *hp;
|
|
|
|
state = 1;
|
|
- read_profile("/etc/profile");
|
|
+ read_profile("/system/etc/profile");
|
|
state1:
|
|
state = 2;
|
|
hp = lookupvar("HOME");
|
|
--
|
|
2.46.0
|
|
|