tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

vacation(1) addition



All,

recently, one of my users voiced confusion about a bounced vacation(1) response to a local gitlab server instance's mail.

Apart from the gitlab instance trying to submit a mail from a non-whitelisted address to the wrong mailserver, it turned out that both vacation(1) and gitlab thought they did the right thing, and talked past each other:

Gitlab added "Auto-Submitted: auto-generated" to its mail, which vacation(1) does not check for, but only "Precedence:". vacation will, on the other hand, set "Auto-Submitted: auto-generated" in its response, but not "Precedence:".

The enclosed patch handles both variations, and documents them.

I was tempted to have vacation(1) add the "Delivered-By-The-Graces-Of: The Vacation program" header from the man page, but decided maybe that was just an example of what you can do in .vacation.msg. ;)

Comments?

Cheerio,
Hauke

--
     The ASCII Ribbon Campaign                    Hauke Fath
()     No HTML/RTF in email	        Institut für Nachrichtentechnik
/\     No Word docs in email                     TU Darmstadt
     Respect for open standards              Ruf +49-6151-16-21344
? vacation.patch
Index: vacation.1
===================================================================
RCS file: /cvsroot/src/usr.bin/vacation/vacation.1,v
retrieving revision 1.32
diff -u -u -r1.32 vacation.1
--- vacation.1	6 May 2019 06:56:07 -0000	1.32
+++ vacation.1	6 Apr 2023 11:52:15 -0000
@@ -172,6 +172,7 @@
 or
 .Dq Cc:
 headers of the mail.
+.Pp
 No messages from
 .Dq ???-REQUEST ,
 .Dq Postmaster ,
@@ -180,12 +181,20 @@
 or
 .Dq MAILER-DAEMON
 will be replied to (where these strings are
-case insensitive) nor is a notification sent if a
+case insensitive).
+.Pp
+No notification is sent if a
 .Dq Precedence: bulk
 .Dq Precedence: list
-or
 .Dq Precedence: junk
-line is included in the mail headers.
+line or an
+.Dq Auto-Submitted:
+line with any qualifier except
+.Dq no
+are included in the mail headers.
+.Nm
+will include these headers in its response to avoid auto-responder loops.
+.Pp
 The people who have sent you messages are maintained as a
 .Xr db 3
 database in the file
@@ -195,7 +204,7 @@
 .Nm
 expects a file
 .Pa .vacation.msg ,
-in your home directory, containing a message to be sent back to each
+in your home directory containing a message to be sent back to each
 sender.
 It should be an entire message (including headers).
 If the message contains the string
@@ -207,7 +216,6 @@
 From: eric%CS.Berkeley.EDU@localhost (Eric Allman)
 Subject: I am on vacation
 Delivered-By-The-Graces-Of: The Vacation program
-Precedence: bulk
 
 I am on vacation until July 22.
 Your mail regarding "$SUBJECT" will be read when I return.
@@ -242,6 +250,9 @@
 .Sh SEE ALSO
 .Xr sendmail 1 ,
 .Xr syslog 3
+.Pp
+RFC 2076 ,
+RFC 3834
 .Sh HISTORY
 The
 .Nm
Index: vacation.c
===================================================================
RCS file: /cvsroot/src/usr.bin/vacation/vacation.c,v
retrieving revision 1.37
diff -u -u -r1.37 vacation.c
--- vacation.c	5 May 2019 23:08:37 -0000	1.37
+++ vacation.c	6 Apr 2023 11:52:15 -0000
@@ -325,7 +325,7 @@
 			    COMPARE(buf, "From:") == 0)
 				getfrom(buf + sizeof("From:") - 1);
 			break;
-		case 'P':		/* "Precedence:" */
+		case 'P':		/* "Precedence:" rfc 2076 ch 3.9 */
 			cont = 0;
 			if (CASECOMPARE(buf, "Precedence") != 0 ||
 			    (buf[10] != ':' && buf[10] != ' ' &&
@@ -352,12 +352,26 @@
 				break;
 			cont = 1;
 			goto findme;
-		case 'A':		/* "Apparently-To:" */
-			if ((tflag & APPARENTLY_TO) == 0 ||
-			    COMPARE(buf, "Apparently-To:") != 0)
+		case 'A':
+                        /* "Apparently-To:" */
+			if ((tflag & APPARENTLY_TO) != 0 &&
+			    COMPARE(buf, "Apparently-To:") == 0) {
+				cont = 1;
+				goto findme;
+			}
+			/* "Auto-Submitted:" rfc 3834 ch 5 */
+			cont = 0;
+			if (CASECOMPARE(buf, "Auto-Submitted") != 0 ||
+			    (buf[14] != ':' && buf[14] != ' ' &&
+			    buf[14] != '\t'))
 				break;
-			cont = 1;
-			goto findme;
+			if ((p = strchr(buf, ':')) == NULL)
+				break;
+			while (*++p && isspace((unsigned char)*p))
+				continue;
+			if (CASECOMPARE(p, "no") != 0 )
+				exit(0);
+			break;
 		case 'D':		/* "Delivered-To:" */
 			if ((tflag & DELIVERED_TO) == 0 ||
 			    COMPARE(buf, "Delivered-To:") != 0)
@@ -628,6 +642,7 @@
 	} 
 	(void)fprintf(sfp, "To: %s\n", from);
 	(void)fputs("Auto-Submitted: auto-replied\n", sfp);
+	(void)fputs("Precedence: bulk\n", sfp);
 	while (fgets(buf, sizeof buf, mfp) != NULL) {
 		char *p;
 		if ((p = strstr(buf, "$SUBJECT")) != NULL) {


Home | Main Index | Thread Index | Old Index