Mercurial > dovecot > core-2.2
changeset 12606:54bcc1728a43
script utility now supports the script using stdio/stdout for communication.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 28 Jan 2011 19:41:03 +0200 |
parents | d675c0264190 |
children | 40f668d36547 |
files | src/plugins/quota/quota.c src/util/script.c |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota.c Fri Jan 28 19:39:00 2011 +0200 +++ b/src/plugins/quota/quota.c Fri Jan 28 19:41:03 2011 +0200 @@ -1015,7 +1015,7 @@ } str = t_str_new(1024); - str_append(str, "VERSION\tscript\t1\t0\n"); + str_append(str, "VERSION\tscript\t2\t0\n"); for (; *args != NULL; args++) { str_append(str, *args); str_append_c(str, '\n');
--- a/src/util/script.c Fri Jan 28 19:39:00 2011 +0200 +++ b/src/util/script.c Fri Jan 28 19:41:03 2011 +0200 @@ -11,7 +11,7 @@ #include <stdlib.h> #include <unistd.h> -#define SCRIPT_MAJOR_VERSION 1 +#define SCRIPT_MAJOR_VERSION 2 #define SCRIPT_READ_TIMEOUT_SECS 10 static ARRAY_TYPE(const_string) exec_args; @@ -44,7 +44,9 @@ arg 1 <lf> arg 2 <lf> ... - <lf> */ + <lf> + [data] + */ alarm(SCRIPT_READ_TIMEOUT_SECS); do { prev_size = input->used; @@ -82,6 +84,13 @@ } if (close(MASTER_STATUS_FD) < 0) i_error("close(status) failed: %m"); + + if (write(conn->fd, "1\n", 2) != 2) + i_error("write() failed: %m"); + + if (dup2(conn->fd, STDIN_FILENO) < 0 || + dup2(conn->fd, STDOUT_FILENO) < 0) + i_error("dup2() failed: %m"); if (close(conn->fd) < 0) i_error("close() failed: %m");