summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--threadproc/unix/proc.c44
2 files changed, 40 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index a083e759f..3bd68a8e9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
Changes with APR 0.9.4
+ *) apr_proc_create() on Unix: Make the APR_SHELLCMD mode work
+ when there is more than one program argument passed in.
+ [Jeff Trawick]
+
*) Add --cc and --cpp flags to apr-config. [Jeff Trawick]
*) Don't segfault trying to close a file in error paths of flock
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index 015fe04c3..2fbcb2908 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -317,7 +317,6 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
apr_pool_t *pool)
{
int i;
- const char **newargs;
new->in = attr->parent_in;
new->err = attr->parent_err;
@@ -423,22 +422,51 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
if (attr->cmdtype == APR_SHELLCMD) {
- i = 0;
- while (args[i]) {
- i++;
- }
+ int onearg_len = 0;
+ const char *newargs[4];
- newargs = (const char **)apr_palloc(pool, sizeof (char *) * (i + 3));
newargs[0] = SHELL_PATH;
newargs[1] = "-c";
i = 0;
while (args[i]) {
- newargs[i + 2] = args[i];
+ onearg_len += strlen(args[i]);
+ onearg_len++; /* for space delimiter */
i++;
}
- newargs[i + 2] = NULL;
+ switch(i) {
+ case 0:
+ /* bad parameters; we're doomed */
+ break;
+ case 1:
+ /* no args, or caller already built a single string from
+ * progname and args
+ */
+ newargs[2] = args[0];
+ break;
+ default:
+ {
+ char *ch, *onearg;
+
+ ch = onearg = apr_palloc(pool, onearg_len);
+ i = 0;
+ while (args[i]) {
+ size_t len = strlen(args[i]);
+
+ memcpy(ch, args[i], len);
+ ch += len;
+ *ch = ' ';
+ ++ch;
+ ++i;
+ }
+ --ch; /* back up to trailing blank */
+ *ch = '\0';
+ newargs[2] = onearg;
+ }
+ }
+
+ newargs[3] = NULL;
if (attr->detached) {
apr_proc_detach(APR_PROC_DETACH_DAEMONIZE);