OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Postfix Archives: Re: Stripping GCOS in From: and To:

Re: Stripping GCOS in From: and To:


Subject: Re: Stripping GCOS in From: and To:
From: Wietse Venema (wietseporcupine.org)
Date: Sun Jan 02 2000 - 18:01:07 CST


Jean-Sebastien Morisset:
> Hello everyone!
>
> I just subscribed after installing an outgoing-only load-balanced postfix
> mail server. We were using Qmail for a while, but a friend suggested Postfix
> and it looks damn good so far.
>
> I have a small problemo though... A detail really... Since our server is
> outgoing only, and we store a lot of information in the GCOS field, I'd like
> to be able to strip the GCOS out of the From: and To: headers. The To:
> header can be populated by the mail reader (passwd file matching) and local
> mail software (probably sendmail) stuffs the GCOS in the From: field.
>
> Can I use Postfix to clean the From: and To: headers?

How about Cc:, Errors-To: and so on?

Out of the box, Postfix leaves comments in mail headers alone.

It's not too hard to change the code so it only emits bare addresses,
although that will mutilate inbound mail as well as outbound mail.
The patch below does just that: when emitting headers after rewriting,
emit just the addresses and not the glop in-between them.

One could also attack the problem from the other side, and modify
the Postfix RFC 822 parser to ignore all non-address tokens so they
never appear in the data stream. In that case the output would be
a little prettier.

Leaving some comments alone and stripping other ones without ever
screwing up is far from trivial, given the complexity of RFC 822
header syntax with quotes, parentheses and escape characters.

        Wietse

*** cleanup_message.c- Wed Nov 3 20:09:45 1999
--- cleanup_message.c Sun Jan 2 18:50:19 2000
***************
*** 168,174 ****
--- 168,182 ----
                  cleanup_extract_internal(cleanup_header_buf, *tpp);
      }
      vstring_sprintf(cleanup_header_buf, "%s: ", hdr_opts->name);
+ #if 0
      tok822_externalize(cleanup_header_buf, tree, TOK822_STR_HEAD);
+ #else
+ for (tpp = addr_list; *tpp; tpp++) {
+ tok822_externalize(cleanup_header_buf, tpp[0]->head, TOK822_STR_HEAD);
+ if (tpp[1])
+ vstring_strcat(cleanup_header_buf, ",\n\t");
+ }
+ #endif
      myfree((char *) addr_list);
      tok822_free_tree(tree);
      if ((hdr_opts->flags & HDR_OPT_DROP) == 0)
***************
*** 217,223 ****
--- 225,239 ----
                  cleanup_extract_internal(cleanup_header_buf, *tpp);
      }
      vstring_sprintf(cleanup_header_buf, "%s: ", hdr_opts->name);
+ #if 0
      tok822_externalize(cleanup_header_buf, tree, TOK822_STR_HEAD);
+ #else
+ for (tpp = addr_list; *tpp; tpp++) {
+ tok822_externalize(cleanup_header_buf, tpp[0]->head, TOK822_STR_HEAD);
+ if (tpp[1])
+ vstring_strcat(cleanup_header_buf, ",\n\t");
+ }
+ #endif
      myfree((char *) addr_list);
      tok822_free_tree(tree);
      if ((hdr_opts->flags & HDR_OPT_DROP) == 0)



This archive was generated by hypermail 2b27 : Sun Jan 02 2000 - 18:03:13 CST