sys-apps/busybox: fix default shell handling
authorMike Frysinger <vapier@chromium.org>
Wed, 26 Apr 2017 21:09:04 +0000 (17:09 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 26 Apr 2017 21:12:26 +0000 (17:12 -0400)
Make sure we explicitly select sh->ash by default as newer versions
are defaulting to sh->hush.

Also fix up the hush patch to include the /bin/busybox fallbacks.

sys-apps/busybox/busybox-1.26.2-r1.ebuild [moved from sys-apps/busybox/busybox-1.26.2.ebuild with 99% similarity]
sys-apps/busybox/files/busybox-1.26.2-bb.patch

similarity index 99%
rename from sys-apps/busybox/busybox-1.26.2.ebuild
rename to sys-apps/busybox/busybox-1.26.2-r1.ebuild
index 1feb3a5ac229b3dc7bdd47921fbbff9b68f86e9f..6c42e41a4521468a3c3abc743df696ba0c6a9c52 100644 (file)
@@ -126,6 +126,7 @@ src_configure() {
        # If these are not set and we are using a uclibc/busybox setup
        # all calls to system() will fail.
        busybox_config_option y ASH
+       busybox_config_option y SH_IS_ASH
        busybox_config_option n HUSH
 
        busybox_config_option '"/run"' PID_FILE_PATH
index f120340162bf08e162dea893f96b0d3bdde511ea..5e2405c3a67028d41ada8fe15099567eb0a0ece5 100644 (file)
@@ -1,6 +1,11 @@
-diff -Naur busybox-1.26.2.orig/shell/ash.c busybox-1.26.2/shell/ash.c
---- busybox-1.26.2.orig/shell/ash.c    2017-01-10 10:55:51.000000000 -0500
-+++ busybox-1.26.2/shell/ash.c 2017-01-28 17:02:08.961584737 -0500
+add `bb` and `bbsh` shortcuts as aliases to the main shell so we can install
+symlinks in Gentoo at /bin/bb as our recovery shell.
+
+we also add fallbacks to /bin/busybox and /bin/busybox.static in case /proc
+is not yet mounted during early boot.
+
+--- a/shell/ash.c
++++ b/shell/ash.c
 @@ -144,6 +144,8 @@
  //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
  //applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
@@ -19,9 +24,8 @@ diff -Naur busybox-1.26.2.orig/shell/ash.c busybox-1.26.2/shell/ash.c
                /* If they called chroot or otherwise made the binary no longer
                 * executable, fall through */
        }
-diff -Naur busybox-1.26.2.orig/shell/hush.c busybox-1.26.2/shell/hush.c
---- busybox-1.26.2.orig/shell/hush.c   2017-01-10 10:55:51.000000000 -0500
-+++ busybox-1.26.2/shell/hush.c        2017-01-28 17:05:13.235936850 -0500
+--- a/shell/hush.c
++++ b/shell/hush.c
 @@ -221,6 +221,8 @@
  //applet:IF_MSH(APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
  //applet:IF_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
@@ -35,8 +39,17 @@ diff -Naur busybox-1.26.2.orig/shell/hush.c busybox-1.26.2/shell/hush.c
        if (SPECIAL_JOBSTOP_SIGS != 0)
                switch_off_special_sigs(G.special_sig_mask & SPECIAL_JOBSTOP_SIGS);
        execve(bb_busybox_exec_path, argv, pp);
-+      execve("/bin/busybox.static", argv, envp);
-+      execve("/bin/busybox", argv, envp);
++      execve("/bin/busybox.static", argv, pp);
++      execve("/bin/busybox", argv, pp);
        /* Fallback. Useful for init=/bin/hush usage etc */
        if (argv[0][0] == '/')
                execve(argv[0], argv, pp);
+@@ -6931,6 +6931,8 @@
+                       if (SPECIAL_JOBSTOP_SIGS != 0)
+                               switch_off_special_sigs(G.special_sig_mask & SPECIAL_JOBSTOP_SIGS);
+                       execv(bb_busybox_exec_path, argv);
++                      execv("/bin/busybox.static", argv);
++                      execv("/bin/busybox", argv);
+                       /* If they called chroot or otherwise made the binary no longer
+                        * executable, fall through */
+               }