>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 <mail address> (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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to