|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Howto get all RCPT TO values?Hi,
I'm trying to set up automatic mail encryption with Anubis. I want to encrypt all mails, not regarding wether the user set some header or subject values. Therefore I'm trying to get all e-mail adresses from the the "RCPT TO" command. I don't use the CC: or To: Headerlines as the header doesn't contain the BCC recepients. But it seems that I do only geht the first address of RCPT TO, even when I send the mail to multiple recepients. Heres my rule: if command ["rcpt to:"] :extended "(.*)" add body "\1" fi Its just setup for testing yet, so the encryption isn't done yet. Sending an e-mail with this rule to: to: user1@... to: user2@... cc: user3@... bcc: user4@... I hope to get an e-mail with: user1@... user2@... user3@... user4@... in the body of the mail. Anyway I only get user1@... in the mail body. The rest is just not printed to the body (also Anubis finds all the other users, when a do a test on user4). Is there any way to get all recpients in one variable? Regards Ben Fleckenstein _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
|
|
Re: Howto get all RCPT TO values?Benjamin Fleckenstein <bfnbkr@...> ha escrit:
> But it seems that I do only geht the first address of RCPT TO, even when > I send the mail to multiple recepients. Yes, it is a known bug of Anubis 4.0. Technically speaking,the reason for this behavior is that commands are kept internally in an associative array, and the search in this array terminates when the first matching entry is found. It was made on the assumption that any meaningful two- part SMTP command is issued once. However, RCPT TO is just the command that can lawfully be issued multiple times, and this breaks the logics. Attached is a patch that I have in my local tree for months. With this patch, all RCPT TO values are stored internally as a single comma-separated string (much like To: or Cc: headers). So, the effect of your rule will be: user1@...,user2@...,user3@...,user4@... Hope this will help. Regards, Sergey Index: src/tunnel.c =================================================================== RCS file: /cvsroot/anubis/anubis/src/tunnel.c,v retrieving revision 1.51 diff -p -u -r1.51 tunnel.c --- src/tunnel.c 6 Aug 2007 15:29:24 -0000 1.51 +++ src/tunnel.c 30 Oct 2007 18:37:01 -0000 @@ -412,9 +412,10 @@ smtp_session (void) static void save_command (MESSAGE * msg, char *line) { - int i; - ASSOC *asc = xmalloc (sizeof (*asc)); - + int i, j; + ASSOC *asc; + int rcpt_to = -1; + for (i = 0; line[i] && !isspace ((u_char) line[i]); i++) ; @@ -424,26 +425,49 @@ save_command (MESSAGE * msg, char *line) if (memcmp (line, "mail", 4) == 0) expect = " from:"; else if (memcmp (line, "rcpt", 4) == 0) - expect = " to:"; + { + rcpt_to++; + expect = " to:"; + } + if (expect) { int n = strlen (expect); if (strncmp (&line[i], expect, n) == 0) - i += n; + { + rcpt_to++; + i += n; + } } } - asc->key = xmalloc (i + 1); - memcpy (asc->key, line, i); - asc->key[i] = 0; - for (; line[i] && isspace ((u_char) line[i]); i++) + for (j = i; line[j] && isspace ((u_char) line[j]); j++) ; - if (line[i]) - asc->value = strdup (&line[i]); + if (rcpt_to > 0 + && (asc = list_locate (msg->commands, "rcpt to:", anubis_assoc_cmp))) + { + size_t vlen = strlen (asc->value); + size_t alen = strlen (line + j); + size_t len = vlen + 1 + alen; + asc->value = xrealloc (asc->value, len + 1); + asc->value[vlen++] = ','; + memcpy (asc->value + vlen, line + j, alen); + asc->value[len] = 0; + } else - asc->value = NULL; - list_append (msg->commands, asc); + { + asc = xmalloc (sizeof (*asc)); + asc->key = xmalloc (i + 1); + memcpy (asc->key, line, i); + asc->key[i] = 0; + if (line[j]) + asc->value = strdup (&line[j]); + else + asc->value = NULL; + list_append (msg->commands, asc); + } + } static int _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
|
|
Re: Howto get all RCPT TO values?Forgotten to tell: although this patch is perfectly working, it is by
no means a final solution. It will be included in the coming new release, if we don't find a better way out. So, any feedback is greatly appreciated. Regards, Sergey _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
|
|
Re: Howto get all RCPT TO values?Hi,
thanks a lot, I didn't hope to get such a quick reply. Unfortunately there is a problem with the patch. In tunnel.c on line 217 int len; //make outputs a warning that len ist initalised. //changing to the following helped. int len = 0; In tunnel.c on line 442. tunnel.c:442: error: `anubis_assoc_cmp' undeclared (first use in this function) I greped through the code but couldn't find that variable anywhere. Regards Ben _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
|
|
Re: Howto get all RCPT TO values?Benjamin Fleckenstein <bfnbkr@...> ha escrit:
> Unfortunately there is a problem with the patch. Ah, yes. It was made against CVS, which is quite ahead of 4.0. Here is the patch reduced for that version: diff -pur anubis-4.0/src/tunnel.c anubis-4.0-mod/src/tunnel.c --- anubis-4.0/src/tunnel.c 2004-12-17 18:52:01.000000000 +0200 +++ anubis-4.0-mod/src/tunnel.c 2007-10-30 21:47:04.000000000 +0200 @@ -403,12 +403,21 @@ smtp_session (void) THE MAIL COMMANDS *********************/ +int +anubis_assoc_cmp (void *item, void *data) +{ + ASSOC *p = item; + return strcmp (p->key, data); +} + + static void save_command (MESSAGE * msg, char *line) { - int i; - ASSOC *asc = xmalloc (sizeof (*asc)); - + int i, j; + ASSOC *asc; + int rcpt_to = -1; + for (i = 0; line[i] && !isspace ((u_char) line[i]); i++) ; @@ -418,26 +427,49 @@ save_command (MESSAGE * msg, char *line) if (memcmp (line, "mail", 4) == 0) expect = " from:"; else if (memcmp (line, "rcpt", 4) == 0) - expect = " to:"; + { + rcpt_to++; + expect = " to:"; + } + if (expect) { int n = strlen (expect); if (strncmp (&line[i], expect, n) == 0) - i += n; + { + rcpt_to++; + i += n; + } } } - asc->key = xmalloc (i + 1); - memcpy (asc->key, line, i); - asc->key[i] = 0; - for (; line[i] && isspace ((u_char) line[i]); i++) + for (j = i; line[j] && isspace ((u_char) line[j]); j++) ; - if (line[i]) - asc->value = strdup (&line[i]); + if (rcpt_to > 0 + && (asc = list_locate (msg->commands, "rcpt to:", anubis_assoc_cmp))) + { + size_t vlen = strlen (asc->value); + size_t alen = strlen (line + j); + size_t len = vlen + 1 + alen; + asc->value = xrealloc (asc->value, len + 1); + asc->value[vlen++] = ','; + memcpy (asc->value + vlen, line + j, alen); + asc->value[len] = 0; + } else - asc->value = NULL; - list_append (msg->commands, asc); + { + asc = xmalloc (sizeof (*asc)); + asc->key = xmalloc (i + 1); + memcpy (asc->key, line, i); + asc->key[i] = 0; + if (line[j]) + asc->value = strdup (&line[j]); + else + asc->value = NULL; + list_append (msg->commands, asc); + } + } static int Regards, Sergey _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
|
|
Re: Howto get all RCPT TO values?Thanks a lot, works perfectly now!
Regards Ben _______________________________________________ Bug-anubis mailing list Bug-anubis@... http://lists.gnu.org/mailman/listinfo/bug-anubis |
| Free embeddable forum powered by Nabble | Forum Help |