Allow pipe + redirect in task/run stanzas, exec() in /bin/sh

This patch extends the capabilities of task and run .conf stanzas by
enabling pipes and redirects.

Example:

    task [s] echo "foo" | cat >/tmp/bar
    run  [s] echo "$HOME" >/tmp/secret

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-09-04 16:00:49 +02:00
1 parent 442598282f
commit 684314db0f
4 files changed
+26 -1

No files matched your search

+21
View File
@@ -213,6 +213,27 @@ int run_interactive(char *cmd, char *fmt, ...)
return status;
}
int exec_runtask(char *cmd, char *args[])
{
size_t i;
char buf[1024] = "";
char *argv[4] = {
"sh",
"-c",
buf,
NULL
};
for (i = 0; args[i]; i++) {
strlcat(buf, args[i], sizeof(buf));
if (args[i + 1])
strlcat(buf, " ", sizeof(buf));
}
logit(LOG_DEBUG, "Calling %s %s", _PATH_BSHELL, buf);
return execve(_PATH_BSHELL, argv, __environ);
}
static void prepare_tty(char *tty, char *procname, int console)
{
/* Reset signal handlers that were set by the parent process */