Re: Working Vacation?? [solved?]

2003-01-24 Thread Mark Keasling
Hi,

Gary Mills says
 Sendmail can rewrite header addresses for local delivery.  This works
 well.  It's only the envelope recipient that has the domain stripped.

And it has only taken a week or two to figure out how to prevent that...
cyrusv2.mc patch:
-cyrusv2.mc-
  # divert(-1)
  #
  #   (C) Copyright 2000 by Carnegie Mellon University
  #
  #   This sample mc file is for a site that uses the Cyrus IMAP server
  #   exclusively for local mail. This requires Sendmail 8.10 or later.
  #
  # $Id: cyrusv2.mc,v 1.4 2001/08/23 23:26:56 leg Exp $
  
  divert(0)dnl
  VERSIONID(`cyrus v2 sample configuartion')
  
  OSTYPE(linux)
  define(`confBIND_OPTS',`-DNSRCH -DEFNAMES')
  define(`confTO_IDENT',`0')
  
  dnl setting cyrus as the trusted user will make it easier to pass
  dnl Sendmail's safefile checks.  however, it means that someone with the
  dnl cyrus password could easily become root.
  dnl define(`confTRUSTED_USER', `cyrus')
  
  define(`confLOCAL_MAILER', `cyrus')
  
  dnl if you aren't using Sendmail 8.12, you might need to remove
  dnl the following feature.
  FEATURE(`preserve_local_plus_detail')
  
  FEATURE(`nocanonify')
  FEATURE(`always_add_domain')
  MAILER(`local')
  MAILER(`smtp')
  
  MAILER_DEFINITIONS
  Mcyrus, P=[IPC], F=lsDFMnqA@/:|SmXz, E=\r\n,
- S=EnvFromL, R=EnvToL/HdrToL, T=DNS/RFC822/X-Unix, 
+ S=EnvFromL, R=HdrToL, T=DNS/RFC822/X-Unix, 
A=FILE /var/imap/socket/lmtp
  
  LOCAL_RULE_0
  Rbb + $+  @ $=w . $#cyrus $: + $1
  


Dump `EnvToL/' from R= and you get working sieve vacations.
The fix turned out to be rather trivial.

Does anyone spot problems with this?

On Thu, 23 Jan 2003 08:25:05 -0600, Gary Mills [EMAIL PROTECTED] wrote...
 On Thu, Jan 23, 2003 at 08:02:42PM +0900, Mark Keasling wrote:
  
  Sendmail is removing the domain part from smtp envelope TO
  addresses (RCPT TO) when they are sent to the local deliverer
  in my case LMTP.  Apparently, there is no way to avoid this
  obnoxious behavior.  Hacking on sendmail.cf has had no effect.
 
 Yes, sendmail assumes that the domain name is not needed for the
 envelope recipient for local delivery.
 
  No vacation reply gets sent because lmtpd substitutes unspecified-domain
  for the domain which was removed by sendmail.  Its to me check
  fails because user@unspecified-domain is definitely not in the
  message's headers.
 
 Yes, when I was debugging this, I found that CCing the message to
 user@unspecified-domain would cause vacation to work!
 
  The following patches seem to fix the sieve vacation problem.
  It would be nice if these patches could be incorporated into
  the main source so that other people who use sendmail can have
  vacations too.  If someone spots a problem with these patches
  or notices a deficiency PLEASE let me know how they should be
  fixed as I'll be putting them into production use RSN.
 
 I'm using a similar set of patches.  I did submit them to the Cyrus
 maintainers, but they were rejected as unnecessary.
 
  There will be some interactions with aliases where [EMAIL PROTECTED]
  [EMAIL PROTECTED] and [EMAIL PROTECTED]
  are all equivalent and all are used.  Mail sent to one address will
  get vacation replies while mail sent to the others will not.  I
  know of no simple way to solve this unless sendmail is kind enough
  to rewrite the addresses in the message header.
 
 Sendmail can rewrite header addresses for local delivery.  This works
 well.  It's only the envelope recipient that has the domain stripped.
 
 -- 
 -Gary Mills--Unix Support--U of M Academic Computing and Networking-

Regards,
Mark Keasling [EMAIL PROTECTED]




Re: Working Vacation?? [solved?]

2003-01-24 Thread Igor Brezac

On Thu, 23 Jan 2003, John Alton Tamplin wrote:

 Mikael Brandström wrote:

 It should be possible to rewrite rulset Parse0 (and maybe Parse1) to make
 them leave the local adress qualified while delivering locally. There
 might even be something among the files in cf/cf which kan fix it, I have
 a vague memory of something such.  Just my 2c.
 
 
 I made changes locally that amounted to always setting $@ whenever
 $#local was selected as a mailer (for mailers that don't use $h, it
 shouldn't matter at all).  If you redefine the local mailer to be
 cyrusv2, then look for $#cyrusv2.  The places that have to be changed are:

 Ruleset 0, change:

 R@$#local $: @  special case error msgs

 to

 R@$#local $@ $M $: @special case error msgs

 (if you aren't masquerading use $j instead of $M -- it could be cleaned
 up so it would work for more general configs but I was in a hurry to get
 something working for our setup).  In Ruleset Parse1, change:

 R  $+ + $*  $+  $#local $: $1 + $2  plussed name?

 to

 R  $+ + $*  @ $+$#local $@ $3 $: $1 + $2plussed name?

 and then the last two rules in Parse1 change from:

 R$=L$#local $: @ $1  special local names
 R$+ $#local $: $1regular local names

 to

 R$=L$#local $@ $M $: @ $1special local names
 R$+ $#local $@ $M $: $1  regular local names

 Remember that tabs separate the columns, not spaces.

 Then in the mailer definition, you can pass $u@$h rather than just $u.
  I am currently using my own deliver program which then connects to LMTP
 -- this should work for the stock deliver program as well, but for
 direct LMTP delivery from sendmail you will have to get more creative.
  I haven't tried it, but it should be possible to copy ruleset
 EnvFromSMTP to something else and modify it to add @$h to the end of the
 address if $h is defined, and then change the cyrusv2 mailer to use that
 for the envelope sender rewrite ruleset.


This is what I use (no sendmail m4 hacking neccessary).

FEATURE(`mailertable', ...
define(`_VIRTUSER_STOP_ONE_LEVEL_RECURSION_', `1')dnl
FEATURE(`virtusertable', ...

Mcyrus, P=[IPC], F=1lsDFMnqAmXzS,
S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n,
T=DNS/RFC822/SMTP,
A=FILE $h

virtusertable:
[EMAIL PROTECTED]  [EMAIL PROTECTED]

mailertable:
domain.com lmtp:/var/imap/socket/lmtp

Hope this helps.

 If anyone wants patches to the stock sendmail 8.12.7 proto.m4 file, I
 will be happy to send them with the usual disclaimers (I have not made
 any effort to make the changes more general, just working for our
 particular configuration -- YMMV).

 I also have changes (including 3 lines of source changes) to allow the w
 flag to be used with a local mailer yet pass through any users that
 aren't listed in getpwent (ie, I wanted to have user .forward files yet
 still allow delivery to shared mailboxes).  This hack is even more
 likely to be a problem in the future, as they are likely to eventually
 use the flag letter 'y' for something else, but if you want them just ask.

 One day when I get time I will clean these up and try and submit them to
 see if they will get included.



-- 
Igor











Re: Working Vacation?? [solved?]

2003-01-24 Thread Igor Brezac

On Fri, 24 Jan 2003, John Alton Tamplin wrote:

 Igor Brezac wrote:

 virtusertable:
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 
 
 So you have to have an entry in virtusertable for every user on the
 domain?

Yes.

 What is the _mbox%3 part for?

userid_mbox is really meant to be a name of the mailbox.

%3 handles plussed email addresses, [EMAIL PROTECTED]

-- 
Igor






Re: Working Vacation?? [solved?]

2003-01-23 Thread Mark Keasling
Hi,

Sieve is not sending vacation replies.  Why?  Here's my stab...
in the dark...

Sieve vacation wants a domain part for the rcpt to address
for its Was the message send directly to me as opposed to
being sent to an alias or got to me some other way check.
Being sent directly to me means my address will appear verbatim
in either the TO, CC or BCC headers.  It is comparing the
stmp envelope's TO to the addresses in the message header.

Sendmail is removing the domain part from smtp envelope TO
addresses (RCPT TO) when they are sent to the local deliverer
in my case LMTP.  Apparently, there is no way to avoid this
obnoxious behavior.  Hacking on sendmail.cf has had no effect.

No vacation reply gets sent because lmtpd substitutes unspecified-domain
for the domain which was removed by sendmail.  Its to me check
fails because user@unspecified-domain is definitely not in the
message's headers.

What I did was to:
  add parseaddr_getdomain() to lib/parseaddr.c which retrieves
the domain name.  It returns unspecified-domain if no domain
name was set.
  add parseaddr_setdomain(domain) to lib/parseaddr.c which sets
the domain name.
  call parseaddr_setdomain(config_servername) in imap/config.c
after config_servername has been set.
  call parseaddr_getdomain() in lib/parseaddr.c and sieve/message.c
before setting unspecified-domain.

The following patches seem to fix the sieve vacation problem.
It would be nice if these patches could be incorporated into
the main source so that other people who use sendmail can have
vacations too.  If someone spots a problem with these patches
or notices a deficiency PLEASE let me know how they should be
fixed as I'll be putting them into production use RSN.

There will be some interactions with aliases where [EMAIL PROTECTED]
[EMAIL PROTECTED] and [EMAIL PROTECTED]
are all equivalent and all are used.  Mail sent to one address will
get vacation replies while mail sent to the others will not.  I
know of no simple way to solve this unless sendmail is kind enough
to rewrite the addresses in the message header.

lib/parseaddr.h
*** parseaddr.h.old Thu Jan 23 18:14:19 2003
--- parseaddr.h Thu Jan 23 17:53:59 2003
***
*** 64,69 
--- 64,71 
  
  extern void parseaddr_list P((const char *s, struct address **addrp));
  extern void parseaddr_free P((struct address *addr));
+ extern void parseaddr_setdomain P((const char *domain));
+ extern char * parseaddr_getdomain ();
  
  
  #endif /* INCLUDED_PARSEADDR_H */
lib/parseaddr.c
*** parseaddr.c.old Thu Jan 23 18:15:38 2003
--- parseaddr.c Thu Jan 23 17:56:11 2003
***
*** 189,194 
--- 189,197 
  
  newaddr-mailbox = mailbox;
  
+ if ( domain  !*domain) {
+   domain = parseaddr_getdomain();
+ }
  if (domain  !*domain) {
domain = parseaddr_unspecified_domain;
  }
***
*** 364,367 
--- 367,389 
return c;
}
  }
  }
+ 
+ /*
+  * manage the default domain
+  */
+ static char *parseaddr_domain_name = (char *)0;
+ 
+ void parseaddr_setdomain (domain)
+  const char * domain ;
+ {
+ if (parseaddr_domain_name) free(parseaddr_domain_name);
+ if (domain  *domain) parseaddr_domain_name = xstrdup(domain) ;
+ else parseaddr_domain_name = (char*)0;
+ }
+ 
+ char * parseaddr_getdomain ()
+ {
+ if (parseaddr_domain_name) return parseaddr_domain_name;
+ return unspecified-domain;
+ }
sieve/message.c
*** message.c.old   Thu Jan 23 19:15:02 2003
--- message.c   Thu Jan 23 17:16:15 2003
***
*** 460,466 
  #define U_USER unknown-user
if (a-mailbox || a-domain) {
char *m = a-mailbox ? a-mailbox : U_USER;
!   char *d = a-domain ? a-domain : U_DOMAIN;
  
am-freeme = (char *) xmalloc(strlen(m) + strlen(d) + 2);
  
--- 460,468 
  #define U_USER unknown-user
if (a-mailbox || a-domain) {
char *m = a-mailbox ? a-mailbox : U_USER;
!   /* char *d = a-domain ? a-domain : U_DOMAIN; */
+   char *d = a-domain ? a-domain : parseaddr_getdomain();
+   if (!d || !*d) d = U_DOMAIN;
  
am-freeme = (char *) xmalloc(strlen(m) + strlen(d) + 2);
  


Many thanks to all the busy people, in particular Ken Murchison,
who have provided assistance without recompense.  Your accomulated
wisdom pointed me in the right direction.  You have my humble thanks
such as they may be.

Regards,
Mark Keasling [EMAIL PROTECTED]




Re: Working Vacation?? [solved?]

2003-01-23 Thread Gary Mills
On Thu, Jan 23, 2003 at 08:02:42PM +0900, Mark Keasling wrote:
 
 Sendmail is removing the domain part from smtp envelope TO
 addresses (RCPT TO) when they are sent to the local deliverer
 in my case LMTP.  Apparently, there is no way to avoid this
 obnoxious behavior.  Hacking on sendmail.cf has had no effect.

Yes, sendmail assumes that the domain name is not needed for the
envelope recipient for local delivery.

 No vacation reply gets sent because lmtpd substitutes unspecified-domain
 for the domain which was removed by sendmail.  Its to me check
 fails because user@unspecified-domain is definitely not in the
 message's headers.

Yes, when I was debugging this, I found that CCing the message to
user@unspecified-domain would cause vacation to work!

 The following patches seem to fix the sieve vacation problem.
 It would be nice if these patches could be incorporated into
 the main source so that other people who use sendmail can have
 vacations too.  If someone spots a problem with these patches
 or notices a deficiency PLEASE let me know how they should be
 fixed as I'll be putting them into production use RSN.

I'm using a similar set of patches.  I did submit them to the Cyrus
maintainers, but they were rejected as unnecessary.

 There will be some interactions with aliases where [EMAIL PROTECTED]
 [EMAIL PROTECTED] and [EMAIL PROTECTED]
 are all equivalent and all are used.  Mail sent to one address will
 get vacation replies while mail sent to the others will not.  I
 know of no simple way to solve this unless sendmail is kind enough
 to rewrite the addresses in the message header.

Sendmail can rewrite header addresses for local delivery.  This works
well.  It's only the envelope recipient that has the domain stripped.

-- 
-Gary Mills--Unix Support--U of M Academic Computing and Networking-



Re: Working Vacation?? [solved?]

2003-01-23 Thread Mikael Brandström


On Thu, 23 Jan 2003 at 08:25, Gary Mills wrote:

 On Thu, Jan 23, 2003 at 08:02:42PM +0900, Mark Keasling wrote:
 
  Sendmail is removing the domain part from smtp envelope TO
  addresses (RCPT TO) when they are sent to the local deliverer
  in my case LMTP.  Apparently, there is no way to avoid this
  obnoxious behavior.  Hacking on sendmail.cf has had no effect.

 Yes, sendmail assumes that the domain name is not needed for the
 envelope recipient for local delivery.

It should be possible to rewrite rulset Parse0 (and maybe Parse1) to make
them leave the local adress qualified while delivering locally. There
might even be something among the files in cf/cf which kan fix it, I have
a vague memory of something such.  Just my 2c.

Mikael




Re: Working Vacation?? [solved?]

2003-01-23 Thread John Alton Tamplin
Mikael Brandström wrote:


It should be possible to rewrite rulset Parse0 (and maybe Parse1) to make
them leave the local adress qualified while delivering locally. There
might even be something among the files in cf/cf which kan fix it, I have
a vague memory of something such.  Just my 2c.
 

I made changes locally that amounted to always setting $@ whenever 
$#local was selected as a mailer (for mailers that don't use $h, it 
shouldn't matter at all).  If you redefine the local mailer to be 
cyrusv2, then look for $#cyrusv2.  The places that have to be changed are:

Ruleset 0, change:

R@$#local $: @  special case error msgs

   to

R@$#local $@ $M $: @special case error msgs

(if you aren't masquerading use $j instead of $M -- it could be cleaned 
up so it would work for more general configs but I was in a hurry to get 
something working for our setup).  In Ruleset Parse1, change:

R  $+ + $*  $+  $#local $: $1 + $2  plussed name?

   to

R  $+ + $*  @ $+$#local $@ $3 $: $1 + $2plussed name?

and then the last two rules in Parse1 change from:

R$=L$#local $: @ $1  special local names
R$+ $#local $: $1regular local names

   to

R$=L$#local $@ $M $: @ $1special local names
R$+ $#local $@ $M $: $1  regular local names

Remember that tabs separate the columns, not spaces.

Then in the mailer definition, you can pass $u@$h rather than just $u. 
I am currently using my own deliver program which then connects to LMTP 
-- this should work for the stock deliver program as well, but for 
direct LMTP delivery from sendmail you will have to get more creative. 
I haven't tried it, but it should be possible to copy ruleset 
EnvFromSMTP to something else and modify it to add @$h to the end of the 
address if $h is defined, and then change the cyrusv2 mailer to use that 
for the envelope sender rewrite ruleset.

If anyone wants patches to the stock sendmail 8.12.7 proto.m4 file, I 
will be happy to send them with the usual disclaimers (I have not made 
any effort to make the changes more general, just working for our 
particular configuration -- YMMV).

I also have changes (including 3 lines of source changes) to allow the w 
flag to be used with a local mailer yet pass through any users that 
aren't listed in getpwent (ie, I wanted to have user .forward files yet 
still allow delivery to shared mailboxes).  This hack is even more 
likely to be a problem in the future, as they are likely to eventually 
use the flag letter 'y' for something else, but if you want them just ask.

One day when I get time I will clean these up and try and submit them to 
see if they will get included.

--
John A. Tamplin   Unix System Administrator
Emory University, School of Public Health +1 404/727-9931