Charles Cazabon
2013-Sep-21 17:32 UTC
[Dovecot] Passing info from mail process to mail_filter plugin script?
Hi, all, The mail_filter plugin allows you to pass messages through an external script/command on the way into and out of the Maildir/mbox/etc mail store. With the recent/new version of the plugin, this seems to work correctly. However, my mail-filter script (for filtering messages on the way from the mail store through the IMAP process to a remote client) needs some extra info from the IMAP mail process. I'm having difficulty figuring out how this can be accomplished. Ideally, I'd like to pass another open file descriptor (opened in the IMAP process) to the script, but I'm not sure if this is possible. Opening the file in the IMAP main.c fails, presumably due to file descriptor limits, but I don't see where restrict_fd_limit() is called there. My second choice for passing this info would be in an environment variable or argument to the mail filter script. Adding env_put() to the IMAP code doesn't seem to get the value passed to the script, presumably because the environment is getting cleared, but again I'm not certain where the list of env vars to keep is set here. There may be another way to accomplish this that I'm not thinking of? Any assistance would be appreciated. Charles -- ----------------------------------------------------------------------- Charles Cazabon GPL'ed software available at: http://pyropus.ca/software/ -----------------------------------------------------------------------
Timo Sirainen
2013-Sep-22 04:29 UTC
[Dovecot] Passing info from mail process to mail_filter plugin script?
On 21.9.2013, at 20.32, Charles Cazabon <charlesc-dovecot at pyropus.ca> wrote:> The mail_filter plugin allows you to pass messages through an external > script/command on the way into and out of the Maildir/mbox/etc mail store. > With the recent/new version of the plugin, this seems to work correctly. > > However, my mail-filter script (for filtering messages on the way from the > mail store through the IMAP process to a remote client) needs some extra info > from the IMAP mail process. I'm having difficulty figuring out how this can > be accomplished. > > Ideally, I'd like to pass another open file descriptor (opened in the IMAP > process) to the script, but I'm not sure if this is possible. Opening the > file in the IMAP main.c fails, presumably due to file descriptor limits, but I > don't see where restrict_fd_limit() is called there.imap process communicates with the mail_filter process via UNIX socket. It would be possible to pass a file descriptor, but it would need motifications to both the mail-filter/[io]stream-ext-filter.c and to src/util/script.c to use fd_send() and fd_recv(). Without modifications the only way to pass data is via the plugin { mail_filter } parameters, such as the %u expanding to username in the example. If you want some other parameters that don't exist in %variables (they get expanded immediately when the imap process starts), you need to modify for example mail-filter-plugin.c where it passes muser->args and muser->out_args to [io]_stream_create_ext_filter().
Maybe Matching Threads
- mail-filter plugin v2.2 - corrupts IMAP indexes?
- mail_filter and mail_filter_out broken somewhere between 2.2.27 and 2.3.4, problem still exists in git
- mail_filter plugin: failed: EOF without input
- mail_filter plugin: failed: EOF without input
- Is the users password available from a mail_filter?