subscriber@viliar.net.ru schreef:
I'll test very interesting plugin xexec. It seems very nice and can be used in many things. It's compiled perfect with dovecot 1.0, but certanly not with dovecot 1.1. It's stopped with next error:
I did not write that module, but tonight I got a bit bored, so I gave it a quick try to port it to Dovecot 1.1. The attached patch provides a compile fix to make it compile without warnings for dovecot-1.1. I only tested whether the module is successfully loaded by Dovecot and not whether XEXEC still does what it is supposed to. It does not segfault on the xexec command, but that is all I tested. I got a backend command error and now it is bed time for me, but there is a good chance that this works if you bother to read the wiki page properly ;) So, consider this to be more like an 'It compiles! Ship it!' kind of fix. But, anyways, it should help you to get where you want. Just apply inside the xexec directory using the usual patch -p1. Let me know what you find out. Regards, Stephan. Updated module to dovecot-1.1 diff -r 521e4f5eb2fe cmd-xexec.c --- a/cmd-xexec.c Wed Mar 19 00:22:45 2008 +0100 +++ b/cmd-xexec.c Wed Mar 19 00:57:30 2008 +0100 @@ -128,10 +128,10 @@ static void cmd_xexec_stderr(void *conte bool cmd_xexec(struct client_command_context *cmd) { - struct imap_arg * imap_args; + const struct imap_arg *imap_args; const char *imap_command; char **backend_command; - array_t ARRAY_DEFINE(command, char *); + ARRAY_DEFINE(command, char *); pid_t pid; int status; int pipe_in[2]; @@ -177,12 +177,13 @@ bool cmd_xexec(struct client_command_con return FALSE; } - ARRAY_CREATE(&command, unsafe_data_stack_pool, char *, 8); + t_array_init(&command, 8); - array_append(&command, backend_command, strarray_length((char const * const *)backend_command)); + array_append(&command, backend_command, + str_array_length((char const * const *)backend_command)); for (i = 1; imap_args[i].type != IMAP_ARG_EOL; i++) { - const char *str = imap_arg_string(&imap_args[i]); + char *str = p_strdup(cmd->pool, imap_arg_string(&imap_args[i])); if (str == NULL) { client_send_command_error(cmd, "Invalid arguments."); t_pop(); @@ -246,11 +247,11 @@ bool cmd_xexec(struct client_command_con close(pipe_out[1]); close(pipe_err[1]); - ctx->in = o_stream_create_file(pipe_in[1], default_pool, 0, TRUE); - ctx->out = i_stream_create_file(pipe_out[0], default_pool, 1024, TRUE); - ctx->err = i_stream_create_file(pipe_err[0], default_pool, 1024, TRUE); + ctx->in = o_stream_create_fd(pipe_in[1], 0, TRUE); + ctx->out = i_stream_create_fd(pipe_out[0], 1024, TRUE); + ctx->err = i_stream_create_fd(pipe_err[0], 1024, TRUE); - ctx->loop = io_loop_create(default_pool); + ctx->loop = io_loop_create(); ctx->io_out = io_add(i_stream_get_fd(ctx->out), IO_READ, cmd_xexec_stdout, ctx); ctx->io_err = io_add(i_stream_get_fd(ctx->err), IO_READ, diff -r 521e4f5eb2fe xexec.h --- a/xexec.h Wed Mar 19 00:22:45 2008 +0100 +++ b/xexec.h Wed Mar 19 00:57:30 2008 +0100 @@ -5,7 +5,7 @@ struct xexec { - array_t ARRAY_DEFINE(setups, struct xexec_setups *); + ARRAY_DEFINE(setups, struct xexec_setup *); }; struct xexec_setup { diff -r 521e4f5eb2fe xexec_plugin.c --- a/xexec_plugin.c Wed Mar 19 00:22:45 2008 +0100 +++ b/xexec_plugin.c Wed Mar 19 00:57:30 2008 +0100 @@ -75,7 +75,7 @@ static struct xexec *xexec_init(void) struct xexec *xexec; xexec = i_new(struct xexec, 1); - ARRAY_CREATE(&xexec->setups, default_pool, struct xexec_setup *, 4); + i_array_init(&xexec->setups, 4); return xexec; } @@ -122,7 +122,7 @@ void xexec_plugin_init(void) } t_pop(); - command_register("XEXEC", cmd_xexec); + command_register("XEXEC", cmd_xexec, 0); str_append(capability_string, " XEXEC"); }