From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 2 18:10:05 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E775FB9B for ; Wed, 2 Jan 2013 18:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id C77AD1A4E for ; Wed, 2 Jan 2013 18:10:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id r02IA5mk063043 for ; Wed, 2 Jan 2013 18:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id r02IA51o063042; Wed, 2 Jan 2013 18:10:05 GMT (envelope-from gnats) Resent-Date: Wed, 2 Jan 2013 18:10:05 GMT Resent-Message-Id: <201301021810.r02IA51o063042@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Olli Hauer Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E4597317 for ; Wed, 2 Jan 2013 18:03:01 +0000 (UTC) (envelope-from ohauer@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id D4D7019D2 for ; Wed, 2 Jan 2013 18:03:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id r02I31YO062608 for ; Wed, 2 Jan 2013 18:03:01 GMT (envelope-from ohauer@freefall.freebsd.org) Received: (from ohauer@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id r02I31Kt062607; Wed, 2 Jan 2013 18:03:01 GMT (envelope-from ohauer) Message-Id: <201301021803.r02I31Kt062607@freefall.freebsd.org> Date: Wed, 2 Jan 2013 18:03:01 GMT From: Olli Hauer To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/174905: [patch] cron honor rfc821, rfc5321, rfc2076, rfc3834 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jan 2013 18:10:06 -0000 >Number: 174905 >Category: bin >Synopsis: [patch] cron honor rfc821, rfc5321, rfc2076, rfc3834 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jan 02 18:10:05 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Olli Hauer >Release: >Organization: >Environment: >Description: o per rfc821, rfc5321 and others there should be an CRLF after each mail-headers line, so change '\n' to '\r\n' o enclose mail addresses between '<>' (rfc821) o swap From: line to DisplayName (rfc5312) Add various mail headers to suppress auto-replies (out of office ...) o add rfc2076 header (Precedence: bulk) o add rfc3834 header (Auto-Submitted: auto-generated) (this header is already honored by dovecot2) o add special header for MS Exchange (X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply) patch can be grabbed additional from here: http://people.freebsd.org/~ohauer/diffs/cron_2013-01-02.diff >How-To-Repeat: - replace sendmail with another mailer and do a strict rfc821 enforce. - implement a vacation mail on your main mailbox (dovecot2/MS-Exchange/...) and let a couple of machines send cron mails to your mailbox >Fix: --- cron_2013-01-02.diff begins here --- Index: head/usr.sbin/cron/cron/do_command.c =================================================================== --- head/usr.sbin/cron/cron/do_command.c (revision 244958) +++ head/usr.sbin/cron/cron/do_command.c (working copy) @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/7/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/7/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/7/usr.sbin/cron/cron/do_command.c (working copy) @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/8/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/8/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/8/usr.sbin/cron/cron/do_command.c (working copy) @@ -147,7 +147,7 @@ #ifdef USE_SIGCHLD /* our parent is watching for our death by catching SIGCHLD. we * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which + * use wait() explicitly. so we have to disable the signal (which * was inherited from the parent). */ (void) signal(SIGCHLD, SIG_DFL); @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/9/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/9/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/9/usr.sbin/cron/cron/do_command.c (working copy) @@ -147,7 +147,7 @@ #ifdef USE_SIGCHLD /* our parent is watching for our death by catching SIGCHLD. we * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which + * use wait() explicitly. so we have to disable the signal (which * was inherited from the parent). */ (void) signal(SIGCHLD, SIG_DFL); @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ --- cron_2013-01-02.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: