DOH! Forgot to CC to the mailinglist: subscriber@viliar.net.ru schreef:subscriber@viliar.net.ru schreef:
subscriber@viliar.net.ru schreef: Thank you, Stephan, for your help. Patch applies without any problem and compilation was successful. According maillog, Dovecot load it without problems too:
Mar 19 09:06:37 mx3 dovecot: IMAP(alx@skymail.alx.in): Module loaded: /usr/lib/dovecot/imap/lib10_xexec_plugin.so I have activate it in config as for dovecot 1.0. But "sub commands" does not started:
...
[pid 4093] --- SIGSEGV (Segmentation fault) @ 0 (0) --- Process 4093 detached <... select resumed> ) = 2 (in [8 10], left {2147482, 996000}) --- SIGCHLD (Child exited) @ 0 (0) -- Found it, apparently dovecot-1.1 does not like a NULL parameter to the array_get function anymore:
- execvp(*(char **)array_idx(&command, 0), array_get(&command, NULL)); + execvp(*(char **)array_idx(&command, 0), array_idx(&command, 0)); With this additional change, the attached full patch manages to update the XEXEC plugin to dovecot-1.1. This was tested with the 'average' example and that worked flawlessly. Regards, Stephan Updated module to dovecot-1.1 diff -r 7cafabf38524 cmd-xexec.c --- a/cmd-xexec.c Wed Mar 19 00:58:24 2008 +0100 +++ b/cmd-xexec.c Fri Mar 21 18:12:26 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(); @@ -236,7 +237,7 @@ bool cmd_xexec(struct client_command_con } close(pipe_err[1]); - execvp(*(char **)array_idx(&command, 0), array_get(&command, NULL)); + execvp(*(char **)array_idx(&command, 0), array_idx(&command, 0)); exit(1); } @@ -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 7cafabf38524 xexec.h --- a/xexec.h Wed Mar 19 00:58:24 2008 +0100 +++ b/xexec.h Fri Mar 21 18:12:26 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 7cafabf38524 xexec_plugin.c --- a/xexec_plugin.c Wed Mar 19 00:58:24 2008 +0100 +++ b/xexec_plugin.c Fri Mar 21 18:12:26 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"); }