summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/busybox/busybox/0001-flock-update-the-behaviour-of-c-parameter-to-match-u.patch77
1 files changed, 34 insertions, 43 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-flock-update-the-behaviour-of-c-parameter-to-match-u.patch b/meta/recipes-core/busybox/busybox/0001-flock-update-the-behaviour-of-c-parameter-to-match-u.patch
index 8bcbd73de9..78520f0d90 100644
--- a/meta/recipes-core/busybox/busybox/0001-flock-update-the-behaviour-of-c-parameter-to-match-u.patch
+++ b/meta/recipes-core/busybox/busybox/0001-flock-update-the-behaviour-of-c-parameter-to-match-u.patch
@@ -1,35 +1,24 @@
1From 198f18addf1d814c2fefcb492f3b9fbd221669bb Mon Sep 17 00:00:00 2001 1From e1d426fd65c00a6d01a10d85edf8a294ae8a2d2b Mon Sep 17 00:00:00 2001
2From: "Maxin B. John" <maxin.john@intel.com> 2From: Denys Vlasenko <vda.linux@googlemail.com>
3Date: Wed, 20 Apr 2016 18:24:45 +0300 3Date: Sun, 24 Apr 2016 18:19:49 +0200
4Subject: [PATCH] flock: update the behaviour of -c parameter to match upstream 4Subject: [PATCH] flock: fix -c; improve error handling of fork+exec
5
6In upstream, -c 'PROG ARGS' means "run sh -c 'PROG ARGS'"
7 5
8function old new delta 6function old new delta
9flock_main 286 377 +91 7flock_main 254 334 +80
10.rodata 155849 155890 +41
11 8
12Upstream-Status: Submitted 9Upstream-Status: Backport
13[ http://lists.busybox.net/pipermail/busybox/2016-April/084142.html ]
14 10
11Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
15Signed-off-by: Maxin B. John <maxin.john@intel.com> 12Signed-off-by: Maxin B. John <maxin.john@intel.com>
16--- 13---
17 util-linux/flock.c | 20 ++++++++++++++------ 14 util-linux/flock.c | 19 +++++++++++++++++--
18 1 file changed, 14 insertions(+), 6 deletions(-) 15 1 file changed, 17 insertions(+), 2 deletions(-)
19 16
20diff --git a/util-linux/flock.c b/util-linux/flock.c 17diff --git a/util-linux/flock.c b/util-linux/flock.c
21index 05a747f..c85a25d 100644 18index 05a747f..539a835 100644
22--- a/util-linux/flock.c 19--- a/util-linux/flock.c
23+++ b/util-linux/flock.c 20+++ b/util-linux/flock.c
24@@ -20,6 +20,7 @@ int flock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 21@@ -57,7 +57,6 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
25 int flock_main(int argc UNUSED_PARAM, char **argv)
26 {
27 int mode, opt, fd;
28+ char *cmd_args[4];
29 enum {
30 OPT_s = (1 << 0),
31 OPT_x = (1 << 1),
32@@ -57,7 +58,6 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
33 /* If it is "flock FILE -c PROG", then -c isn't caught by getopt32: 22 /* If it is "flock FILE -c PROG", then -c isn't caught by getopt32:
34 * we use "+" in order to support "flock -opt FILE PROG -with-opts", 23 * we use "+" in order to support "flock -opt FILE PROG -with-opts",
35 * we need to remove -c by hand. 24 * we need to remove -c by hand.
@@ -37,35 +26,37 @@ index 05a747f..c85a25d 100644
37 */ 26 */
38 if (argv[0] 27 if (argv[0]
39 && argv[0][0] == '-' 28 && argv[0][0] == '-'
40@@ -65,7 +65,10 @@ int flock_main(int argc UNUSED_PARAM, char **argv) 29@@ -66,6 +65,9 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
41 || (ENABLE_LONG_OPTS && strcmp(argv[0] + 1, "-command") == 0)
42 ) 30 )
43 ) { 31 ) {
44- argv++; 32 argv++;
45+ if (argc != optind + 3) 33+ if (argv[1])
46+ bb_error_msg_and_die("-c requires exactly one command argument"); 34+ bb_error_msg_and_die("-c takes only one argument");
47+ else 35+ opt |= OPT_c;
48+ argv++;
49 } 36 }
50 37
51 if (OPT_s == LOCK_SH && OPT_x == LOCK_EX && OPT_n == LOCK_NB && OPT_u == LOCK_UN) { 38 if (OPT_s == LOCK_SH && OPT_x == LOCK_EX && OPT_n == LOCK_NB && OPT_u == LOCK_UN) {
52@@ -89,9 +92,14 @@ int flock_main(int argc UNUSED_PARAM, char **argv) 39@@ -90,8 +92,21 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
53 return EXIT_FAILURE;
54 bb_perror_nomsg_and_die(); 40 bb_perror_nomsg_and_die();
55 } 41 }
56- 42
57- if (argv[0]) 43- if (argv[0])
58- return spawn_and_wait(argv); 44+ if (argv[0]) {
59- 45+ if (!(opt & OPT_c)) {
60+ if (argv[0]) { 46+ int rc = spawn_and_wait(argv);
61+ cmd_args[0] = getenv("SHELL"); 47+ if (rc < 0)
62+ if (!cmd_args[0]) 48+ bb_simple_perror_msg(argv[0]);
63+ cmd_args[0] = (char*)DEFAULT_SHELL; 49+ return rc;
64+ cmd_args[1] = (char*)"-c"; 50+ }
65+ cmd_args[2] = argv[0]; 51+ /* -c 'PROG ARGS' means "run sh -c 'PROG ARGS'" */
66+ cmd_args[3] = NULL; 52+ argv -= 2;
67+ return spawn_and_wait(cmd_args); 53+ argv[0] = (char*)get_shell_name();
68+ } 54+ argv[1] = (char*)"-c";
55+ /* argv[2] = "PROG ARGS"; */
56+ /* argv[3] = NULL; */
57 return spawn_and_wait(argv);
58+ }
59
69 return EXIT_SUCCESS; 60 return EXIT_SUCCESS;
70 } 61 }
71-- 62--