Default login shell path on Android devices

Dudy Kohen kohen.d at gmail.com
Thu Mar 3 23:45:14 UTC 2011


Hi,
A lot of "aftermarket" Android developers add busybox to their builds.
I have found out that the hardcoded default login shell is not valid
in Android and it causes issues with scrips that do not have shebangs.
I have sent this to one of the AOSP-based projects and it got
accepted, and I thought it would benefit if it existed upstream as
well.
I know that you do not have Android code as part of your normal
source, but this change is controlled by #ifdefs and thus should not
affect the resulting code at all if not defined as Android.
Thanks,
David Kohen



commit f4c57f6e494fd628dcad4e684fdb14cd980fdb0c
Author: David Kohen <kohen.d at gmail.com>
Date:   Thu Mar 3 16:20:28 2011 +0200

    Made it so scripts without shebangs will work on Android

     Basically, busybox has a default shell setting that I changed
when ANDROID is defined

    Change-Id: Ie6dcee76d6169d50144f7bb79a4fcb2458cb0fe5

diff --git a/include/libbb.h b/include/libbb.h
index 8b86390..2b86463 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1555,12 +1555,22 @@ extern struct globals *const ptr_to_globals;
  * 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"
 extern const char bb_default_login_shell[];
+/* Since android does not have the /bin path, unlike most unix systems,
+ * it needs an exception in the default shell path. */
+#ifdef ANDROID
+#define LIBBB_DEFAULT_LOGIN_SHELL      "-/system/xbin/sh"
+/* "/system/xbin/sh" */
+#define DEFAULT_SHELL     (bb_default_login_shell+1)
+/* "sh" */
+#define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+14)
+#else
+#define LIBBB_DEFAULT_LOGIN_SHELL      "-/bin/sh"
 /* "/bin/sh" */
 #define DEFAULT_SHELL     (bb_default_login_shell+1)
 /* "sh" */
 #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)
+#endif

 #if ENABLE_FEATURE_DEVFS
 # define CURRENT_VC "/dev/vc/0"


More information about the busybox mailing list