diff options
author | Ron Yorston <rmy@pobox.com> | 2016-11-10 10:52:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-11-10 10:52:50 +0000 |
commit | 550b6b0421d3f74c2c6ff3f8d9dfbc9e7ac22c3a (patch) | |
tree | 9c48aa74b3a7ca2d58a740af4eca3bbf7d8e7096 /libbb | |
parent | 87ff6cda847a11db5994205cb068d8deb8c4fdd1 (diff) | |
parent | 87e039d0160be16a9a242f74af2e90cdb9f97e12 (diff) | |
download | busybox-w32-550b6b0421d3f74c2c6ff3f8d9dfbc9e7ac22c3a.tar.gz busybox-w32-550b6b0421d3f74c2c6ff3f8d9dfbc9e7ac22c3a.tar.bz2 busybox-w32-550b6b0421d3f74c2c6ff3f8d9dfbc9e7ac22c3a.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/common_bufsiz.c | 9 | ||||
-rw-r--r-- | libbb/executable.c | 2 | ||||
-rw-r--r-- | libbb/run_shell.c | 29 |
3 files changed, 22 insertions, 18 deletions
diff --git a/libbb/common_bufsiz.c b/libbb/common_bufsiz.c index 1a3585169..2847eb57d 100644 --- a/libbb/common_bufsiz.c +++ b/libbb/common_bufsiz.c | |||
@@ -54,6 +54,15 @@ char bb_common_bufsiz1[COMMON_BUFSIZE] ALIGNED(sizeof(long long)); | |||
54 | #else | 54 | #else |
55 | 55 | ||
56 | # ifndef setup_common_bufsiz | 56 | # ifndef setup_common_bufsiz |
57 | /* For now, this is never used: | ||
58 | * scripts/generate_BUFSIZ.sh never generates "malloced" bufsiz1: | ||
59 | * enum { COMMON_BUFSIZE = 1024 }; | ||
60 | * extern char *const bb_common_bufsiz1; | ||
61 | * void setup_common_bufsiz(void); | ||
62 | * This has proved to be worse than the approach of defining | ||
63 | * larger bb_common_bufsiz1[] array. | ||
64 | */ | ||
65 | |||
57 | /* | 66 | /* |
58 | * It is not defined as a dummy macro. | 67 | * It is not defined as a dummy macro. |
59 | * It means we have to provide this function. | 68 | * It means we have to provide this function. |
diff --git a/libbb/executable.c b/libbb/executable.c index 308c525a3..5f0ff8c6e 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
@@ -111,5 +111,5 @@ void FAST_FUNC exec_prog_or_SHELL(char **argv) | |||
111 | if (argv[0]) { | 111 | if (argv[0]) { |
112 | BB_EXECVP_or_die(argv); | 112 | BB_EXECVP_or_die(argv); |
113 | } | 113 | } |
114 | run_shell(getenv("SHELL"), /*login:*/ 1, NULL, NULL); | 114 | run_shell(getenv("SHELL"), /*login:*/ 1, NULL); |
115 | } | 115 | } |
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 4d92c3caa..b6b9360e8 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
@@ -50,19 +50,17 @@ void FAST_FUNC set_current_security_context(security_context_t sid) | |||
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | /* Run SHELL, or DEFAULT_SHELL if SHELL is "" or NULL. | 52 | /* Run SHELL, or DEFAULT_SHELL if SHELL is "" or NULL. |
53 | * If COMMAND is nonzero, pass it to the shell with the -c option. | 53 | * If ADDITIONAL_ARGS is not NULL, pass them to the shell. |
54 | * If ADDITIONAL_ARGS is nonzero, pass it to the shell as more | 54 | */ |
55 | * arguments. */ | 55 | void FAST_FUNC run_shell(const char *shell, int loginshell, const char **additional_args) |
56 | void FAST_FUNC run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) | ||
57 | { | 56 | { |
58 | const char **args; | 57 | const char **args; |
59 | int argno; | ||
60 | int additional_args_cnt = 0; | ||
61 | 58 | ||
62 | for (args = additional_args; args && *args; args++) | 59 | args = additional_args; |
63 | additional_args_cnt++; | 60 | while (args && *args) |
61 | args++; | ||
64 | 62 | ||
65 | args = xmalloc(sizeof(char*) * (4 + additional_args_cnt)); | 63 | args = xmalloc(sizeof(char*) * (2 + (args - additional_args))); |
66 | 64 | ||
67 | if (!shell || !shell[0]) | 65 | if (!shell || !shell[0]) |
68 | shell = DEFAULT_SHELL; | 66 | shell = DEFAULT_SHELL; |
@@ -70,16 +68,13 @@ void FAST_FUNC run_shell(const char *shell, int loginshell, const char *command, | |||
70 | args[0] = bb_get_last_path_component_nostrip(shell); | 68 | args[0] = bb_get_last_path_component_nostrip(shell); |
71 | if (loginshell) | 69 | if (loginshell) |
72 | args[0] = xasprintf("-%s", args[0]); | 70 | args[0] = xasprintf("-%s", args[0]); |
73 | argno = 1; | 71 | args[1] = NULL; |
74 | if (command) { | ||
75 | args[argno++] = "-c"; | ||
76 | args[argno++] = command; | ||
77 | } | ||
78 | if (additional_args) { | 72 | if (additional_args) { |
79 | for (; *additional_args; ++additional_args) | 73 | int cnt = 1; |
80 | args[argno++] = *additional_args; | 74 | for (;;) |
75 | if ((args[cnt++] = *additional_args++) == NULL) | ||
76 | break; | ||
81 | } | 77 | } |
82 | args[argno] = NULL; | ||
83 | 78 | ||
84 | #if ENABLE_SELINUX | 79 | #if ENABLE_SELINUX |
85 | if (current_sid) | 80 | if (current_sid) |