From eab991f2cbf1d3f174880c28bfd7efd6b8e87ee0 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Wed, 12 Apr 2017 15:01:54 +0300 Subject: main/busybox: ash: support exec -a --- ...ellexec-capable-of-using-separate-argv-0-.patch | 91 ++++++++++++++++++++++ ...0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch | 69 ++++++++++++++++ main/busybox/APKBUILD | 6 +- 3 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 main/busybox/0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch create mode 100644 main/busybox/0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch (limited to 'main/busybox') diff --git a/main/busybox/0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch b/main/busybox/0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch new file mode 100644 index 0000000000..70f420a923 --- /dev/null +++ b/main/busybox/0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch @@ -0,0 +1,91 @@ +From e139ae307e4fd9eb3b86a6fc2e97b4e212925199 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Wed, 12 Apr 2017 21:02:33 +0200 +Subject: [PATCH 13/14] ash: make shellexec capable of using separate argv[0] + and filename to exec + +function old new delta +execcmd 71 78 +7 +shellexec 221 224 +3 +evalcommand 1158 1161 +3 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 3/0 up/down: 13/0) Total: 13 bytes + +Signed-off-by: Denys Vlasenko +--- + shell/ash.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/shell/ash.c b/shell/ash.c +index 983f7b1..044f166 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -7744,9 +7744,8 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** + * have to change the find_command routine as well. + * argv[-1] must exist and be writable! See tryexec() for why. + */ +-static void shellexec(char **, const char *, int) NORETURN; +-static void +-shellexec(char **argv, const char *path, int idx) ++static void shellexec(char *prog, char **argv, const char *path, int idx) NORETURN; ++static void shellexec(char *prog, char **argv, const char *path, int idx) + { + char *cmdname; + int e; +@@ -7755,12 +7754,12 @@ shellexec(char **argv, const char *path, int idx) + int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ + + envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); +- if (strchr(argv[0], '/') != NULL ++ if (strchr(prog, '/') != NULL + #if ENABLE_FEATURE_SH_STANDALONE +- || (applet_no = find_applet_by_name(argv[0])) >= 0 ++ || (applet_no = find_applet_by_name(prog)) >= 0 + #endif + ) { +- tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp); ++ tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp); + if (applet_no >= 0) { + /* We tried execing ourself, but it didn't work. + * Maybe /proc/self/exe doesn't exist? +@@ -7772,7 +7771,7 @@ shellexec(char **argv, const char *path, int idx) + } else { + try_PATH: + e = ENOENT; +- while ((cmdname = path_advance(&path, argv[0])) != NULL) { ++ while ((cmdname = path_advance(&path, prog)) != NULL) { + if (--idx < 0 && pathopt == NULL) { + tryexec(IF_FEATURE_SH_STANDALONE(-1,) cmdname, argv, envp); + if (errno != ENOENT && errno != ENOTDIR) +@@ -7796,8 +7795,8 @@ shellexec(char **argv, const char *path, int idx) + } + exitstatus = exerrno; + TRACE(("shellexec failed for %s, errno %d, suppress_int %d\n", +- argv[0], e, suppress_int)); +- ash_msg_and_raise(EXEXIT, "%s: %s", argv[0], errmsg(e, "not found")); ++ prog, e, suppress_int)); ++ ash_msg_and_raise(EXEXIT, "%s: %s", prog, errmsg(e, "not found")); + /* NOTREACHED */ + } + +@@ -9371,7 +9370,7 @@ execcmd(int argc UNUSED_PARAM, char **argv) + /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */ + /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */ + +- shellexec(argv + 1, pathval(), 0); ++ shellexec(argv[1], argv + 1, pathval(), 0); + /* NOTREACHED */ + } + return 0; +@@ -9773,7 +9772,7 @@ evalcommand(union node *cmd, int flags) + /* fall through to exec'ing external program */ + } + listsetvar(varlist.list, VEXPORT|VSTACK); +- shellexec(argv, path, cmdentry.u.index); ++ shellexec(argv[0], argv, path, cmdentry.u.index); + /* NOTREACHED */ + } /* default */ + case CMDBUILTIN: +-- +2.9.3 + diff --git a/main/busybox/0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch b/main/busybox/0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch new file mode 100644 index 0000000000..028196a40b --- /dev/null +++ b/main/busybox/0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch @@ -0,0 +1,69 @@ +From 6c149f4d9afaed9edb75c88b784ad900c1f40700 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Wed, 12 Apr 2017 21:31:32 +0200 +Subject: [PATCH 14/14] ash: implement "exec -a ARGV0 CMD ARGV1..." + +function old new delta +execcmd 71 112 +41 +shellexec 221 224 +3 +evalcommand 1158 1161 +3 +localcmd 364 366 +2 +unaliascmd 163 154 -9 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 4/1 up/down: 49/-9) Total: 40 bytes + +Signed-off-by: Denys Vlasenko +--- + shell/ash.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +diff --git a/shell/ash.c b/shell/ash.c +index 044f166..e170bec 100644 +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -3345,11 +3345,9 @@ unaliascmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) + { + int i; + +- while ((i = nextopt("a")) != '\0') { +- if (i == 'a') { +- rmaliases(); +- return 0; +- } ++ while (nextopt("a") != '\0') { ++ rmaliases(); ++ return 0; + } + for (i = 0; *argptr; argptr++) { + if (unalias(*argptr)) { +@@ -9354,7 +9352,14 @@ truecmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) + static int FAST_FUNC + execcmd(int argc UNUSED_PARAM, char **argv) + { +- if (argv[1]) { ++ optionarg = NULL; ++ while (nextopt("a:") != '\0') ++ /* nextopt() sets optionarg to "-a ARGV0" */; ++ ++ argv = argptr; ++ if (argv[0]) { ++ char *prog; ++ + iflag = 0; /* exit on error */ + mflag = 0; + optschanged(); +@@ -9370,7 +9375,10 @@ execcmd(int argc UNUSED_PARAM, char **argv) + /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */ + /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */ + +- shellexec(argv[1], argv + 1, pathval(), 0); ++ prog = argv[0]; ++ if (optionarg) ++ argv[0] = optionarg; ++ shellexec(prog, argv, pathval(), 0); + /* NOTREACHED */ + } + return 0; +-- +2.9.3 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index 3f3f4c079b..cdaf1d37b6 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa pkgname=busybox pkgver=1.26.2 -pkgrel=0 +pkgrel=1 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -27,6 +27,8 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 0010-su-FEATURE_SU_NULLOK_SECURE.patch 0011-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch 0012-diff-add-support-for-no-dereference.patch + 0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch + 0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch location-for-cpio.patch @@ -159,6 +161,8 @@ fc291167b2e026166e283d98d2d61cb3c9701e5e83c09062692d0c5a77f3b838ba73065706461095 f82caa1dc4395f266b024a7face267a916a80ead95f3d392b10fd397d0fdf62703e3078357bc71962616d6531ea913aef80e1a7cdf8180bca70e723c7d331238 0010-su-FEATURE_SU_NULLOK_SECURE.patch 16b513b34b3bf16002f14566aae66aab986403cb7a0f416c27264b739706bbd624a99fd37d5b56ff6efe623f3cc48aef3e8fe51c4ae2e94eda3fe9e8e618e3a1 0011-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch 361959788bc11b7f20d4029bb0f561759d270983b09c44fe2a01817378c4eb1c98cd8ef73e7ef8c168b7540170f58ddb36b9e4f80a97565f3fe3ba85b593a471 0012-diff-add-support-for-no-dereference.patch +bf3e7c400e718fbc19fda19d7304ed938e5c59f45d5d1ba6eafd8f62a984d40419dbefd9f6840ac7f220d00abfae67e8f31be78b4c2e25310b265bca8beb91a2 0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch +cb7aa4d5d22596bc8c6510cb653599dd8cf4c3a5312e93adfc6411d811376db2ad3b506a111322f46aa9929a5337e22a169da4ea250fd4b39e703adbc8792a2d 0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch f26e090f5de0096ba5c4d46989ebe0ab5fa64c8bf54cd37ddec302fddfde23eac914858d86cc52bf3b5780a8e81ea2612ef6e713df2828e52c606f86a6816f39 location-for-cpio.patch dadb4c953ebc755b88ee95c1489feb0c2d352f6e44abc716166024e6eea11ab9d10c84fad62c081775834d205cb04aa1be3c994676c88f4284495c54b9188e8b acpid.logrotate d4b9f4a09dcf08ec9f7a66c5250465e3a6dd9beb15140a462a1464110824426c732399e4dab4e6a33073626d4db0e76085b218cd0521027e57ce9f918ff1af29 busyboxconfig -- cgit v1.2.3