Re: Make cron supply valid RFC822 From: and To: headers

2012-11-14 Thread Todd C. Miller
On Tue, 13 Nov 2012 11:02:00 +0100, Alexander Hall wrote:

 Since I switched to SMTPD I noticed a few cron emails being marked as
 spam by spamassassin, largely caused by the From: and To: headers not
 containing a domain part.

Sendmail will add the domain if the always_add_domain feature is
enabled (as it is in our default config).

 If I read RFC822 correctly, the domain part is not optional, and thus
 we should append one, unless MAILTO already specifies one.
 
 Historical reasons from the land of pre-smtp why I'm wrong?

Historically, cron has been able to work with non-internet mailers
that simply write to the local spool file.  It seems like smtpd
should add the domain for locally-generated messages if one is
missing.

 - todd



Make cron supply valid RFC822 From: and To: headers

2012-11-13 Thread Alexander Hall
Since I switched to SMTPD I noticed a few cron emails being marked as
spam by spamassassin, largely caused by the From: and To: headers not
containing a domain part.

If I read RFC822 correctly, the domain part is not optional, and thus
we should append one, unless MAILTO already specifies one.

Historical reasons from the land of pre-smtp why I'm wrong?
Comments?
OK's?

/Alexander


(Indentation style sucks balls in there. I kept it up.)

Index: do_command.c
===
RCS file: /data/openbsd/cvs/src/usr.sbin/cron/do_command.c,v
retrieving revision 1.36
diff -u -p -r1.36 do_command.c
--- do_command.c22 Aug 2011 19:32:42 -  1.36
+++ do_command.c13 Nov 2012 09:48:53 -
@@ -412,8 +412,13 @@ child_process(entry *e, user *u) {
perror(mailcmd);
(void) _exit(EXIT_FAILURE);
}
-   fprintf(mail, From: root (Cron Daemon)\n);
-   fprintf(mail, To: %s\n, mailto);
+   fprintf(mail, From: root@%s (Cron Daemon)\n,
+   hostname);
+   if (strchr(mailto, '@') == NULL)
+   fprintf(mail, To: %s@%s\n, mailto,
+   hostname);
+   else
+   fprintf(mail, To: %s\n, mailto);
fprintf(mail, Subject: Cron %s@%s %s\n,
usernm, first_word(hostname, .),
e-cmd);



Re: Make cron supply valid RFC822 From: and To: headers

2012-11-13 Thread Alexander Hall

On 11/13/12 13:49, Christian Weisgerber wrote:

Alexander Hall alexan...@beard.se wrote:


Since I switched to SMTPD I noticed a few cron emails being marked as
spam by spamassassin, largely caused by the From: and To: headers not
containing a domain part.

If I read RFC822 correctly, the domain part is not optional, and thus
we should append one, unless MAILTO already specifies one.


This looks like a problem in smtpd.  Sendmail and compatible MTAs
have always fully qualified any incomplete addresses.


Ok, no matter how we parse the rfc's, since old sendmail and friends 
rewrites those headers, I guess it's already a de-facto standard, in 
practice forcing us to make smtpd do it too.


In the meantime, would the diff hurt anyone? Or is it just a lousy 
workaround?


/Alexander



Re: Make cron supply valid RFC822 From: and To: headers

2012-11-13 Thread Otto Moerbeek
On Tue, Nov 13, 2012 at 03:14:06PM +0100, Alexander Hall wrote:

 On 11/13/12 13:49, Christian Weisgerber wrote:
 Alexander Hall alexan...@beard.se wrote:
 
 Since I switched to SMTPD I noticed a few cron emails being marked as
 spam by spamassassin, largely caused by the From: and To: headers not
 containing a domain part.
 
 If I read RFC822 correctly, the domain part is not optional, and thus
 we should append one, unless MAILTO already specifies one.
 
 This looks like a problem in smtpd.  Sendmail and compatible MTAs
 have always fully qualified any incomplete addresses.
 
 Ok, no matter how we parse the rfc's, since old sendmail and friends
 rewrites those headers, I guess it's already a de-facto standard, in
 practice forcing us to make smtpd do it too.
 
 In the meantime, would the diff hurt anyone? Or is it just a lousy
 workaround?
 
 /Alexander

I believe sendmail has options to add a specific domain to unqualified
names.  I think you want the sendmail (like) mechanism here, not a
specific one for cron only. 

-Otto