Index | Thread | Search

From:
Kirill A. Korinsky <kirill@korins.ky>
Subject:
calendar(1): introduce RECIPIENT_EMAIL
To:
OpenBSD tech <tech@openbsd.org>
Date:
Sat, 01 Feb 2025 23:18:40 +0100

Download raw body.

Thread
tech@

Here a patch which introduced a special variable RECIPIENT_EMAIL in
calendar(1).

By default it sends daily emails to a user and it can be forwarded via
~/.forward to desire destination. But here no way to send calendar's email
to other email.

My patch introduced a variable RECIPIENT_EMAIL which can be used to override
the destination email in calendar file.

Feedback? Ok?

Index: usr.bin/calendar/calendar.1
===================================================================
RCS file: /home/cvs/src/usr.bin/calendar/calendar.1,v
diff -u -p -r1.44 calendar.1
--- usr.bin/calendar/calendar.1	29 Jan 2019 22:28:30 -0000	1.44
+++ usr.bin/calendar/calendar.1	1 Feb 2025 22:03:35 -0000
@@ -107,6 +107,10 @@ Use
 .Dq CALENDAR=
 to return to the default (Gregorian).
 .Pp
+The
+.Dq RECIPIENT_EMAIL
+variable can be used to specify recipient of daily mails.
+.Pp
 To enforce special date calculation mode for Cyrillic calendars
 you should specify
 .Dq LANG=<local_name>
Index: usr.bin/calendar/io.c
===================================================================
RCS file: /home/cvs/src/usr.bin/calendar/io.c,v
diff -u -p -r1.51 io.c
--- usr.bin/calendar/io.c	7 Dec 2021 14:00:33 -0000	1.51
+++ usr.bin/calendar/io.c	31 Jan 2025 01:01:38 -0000
@@ -51,6 +51,9 @@
 #include "calendar.h"
 
 
+char *recipient = NULL;
+
+
 struct iovec header[] = {
 	{ "From: ", 6 },
 	{ NULL, 0 },
@@ -123,6 +126,11 @@ cal(void)
 			if ((prefix = strdup(buf + 6)) == NULL)
 				err(1, NULL);
 			continue;
+		} else if (strncmp(buf, "RECIPIENT_EMAIL=", 16) == 0) {
+			free(recipient);
+			if ((recipient = strdup(buf + 16)) == NULL)
+				err(1, NULL);
+			continue;
 		}
 		/* User defined names for special events */
 		if ((p = strchr(buf, '='))) {
@@ -408,7 +416,7 @@ closecal(FILE *fp)
 		}
 		(void)close(pdes[1]);
 		execl(_PATH_SENDMAIL, "sendmail", "-i", "-t", "-F",
-		    "\"Reminder Service\"", (char *)NULL);
+		    "\"Reminder Service\"", recipient, (char *)NULL);
 		warn(_PATH_SENDMAIL);
 		_exit(1);
 	}


-- 
wbr, Kirill