From d60d21300924fad507d812edca3de30074b52e02 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 25 Jul 2002 06:04:55 +0000 Subject: Use execv ("sh", "-c", command) rather than execing the command directly. 2002-07-25 Jeffrey Stedfast * camel-filter-search.c (run_command): Use execv ("sh", "-c", command) rather than execing the command directly. svn path=/trunk/; revision=17582 --- camel/camel-filter-search.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'camel/camel-filter-search.c') diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index 9475f3ad57..3bcb582fba 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -503,6 +503,9 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa int in_fds[2]; pid_t pid; + if (argc < 1 || argv[0]->value.string[0] == '\0') + return 0; + if (pipe (in_fds) == -1) { camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to create pipe to '%s': %s"), @@ -512,7 +515,6 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa if (!(pid = fork ())) { /* child process */ - GPtrArray *args; int maxfd, i; if (dup2 (in_fds[0], STDIN_FILENO) < 0) @@ -528,16 +530,7 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa } } - args = g_ptr_array_new (); - g_ptr_array_add (args, g_basename (argv[0]->value.string)); - for (i = 1; i < argc; i++) { - g_ptr_array_add (args, argv[i]->value.string); - } - g_ptr_array_add (args, NULL); - - execvp (argv[0]->value.string, (char **) args->pdata); - - g_ptr_array_free (args, TRUE); + execv ("sh", "-c", argv[0]->value.string); fprintf (stderr, "Could not execute %s: %s\n", argv[0]->value.string, g_strerror (errno)); -- cgit v1.2.3