From 6ec1970b75504d015116fc6bfe2133e9ee4908cd Mon Sep 17 00:00:00 2001 From: Nate Straz Date: Wed, 31 Aug 2005 18:47:46 +0000 Subject: Remove cmdline splitting. We can just run everything through the shell. --- qarsh/qarshd.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/qarsh/qarshd.c b/qarsh/qarshd.c index 8919984..f7e5dd6 100644 --- a/qarsh/qarshd.c +++ b/qarsh/qarshd.c @@ -84,34 +84,7 @@ run_cmd(const char *cmd, int p_in, int p_out, int p_err) if (new_err == -1) syslog(LOG_WARNING, "connect to new_err failed"); dup2(new_err, fileno(stderr)); - /* If there are any shell-type characters in the - * cmdline such as '>', '<', '$', '|', '~','*' etc, - * then we exec a shell and run the cmd under a shell. - * - * Otherwise exec the cmd directly. - */ - - if (strpbrk(cmd, "\"';|<>$\\~*&")) { - execlp("sh", "sh", "-c", cmd, NULL); - } else { - char **argv; - char *sp, *tmpcmd; - int argc = 1; - - /* We need to split the string up */ - tmpcmd = strdup(cmd); - for (sp = tmpcmd; (sp = strchr(sp, ' ')); argc++) { - if (*sp == ' ') sp++; - } - syslog(LOG_INFO, "cmdline split into %d args", argc); - argv = calloc(argc+1, sizeof *argv); - for (argc = 0; (sp = strsep(&tmpcmd, " ")); argc++) { - argv[argc] = sp; - } - argv[argc] = NULL; - execvp(argv[0], argv); - printf("exec of %s failed: %d, %s\n", argv[0], errno, strerror(errno)); - } + execlp("sh", "sh", "-c", cmd, NULL); exit(127); } return pid; -- cgit