summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>1999-06-03 20:20:25 +0000
committermarc <marc@openbsd.org>1999-06-03 20:20:25 +0000
commit7562e77422a44796c94fcbbc33f2c45bb063e26c (patch)
treea8e9f8466b52440e45510d0e366a5d4c34b41d6f
parentsync (diff)
downloadwireguard-openbsd-7562e77422a44796c94fcbbc33f2c45bb063e26c.tar.xz
wireguard-openbsd-7562e77422a44796c94fcbbc33f2c45bb063e26c.zip
add support for including the subject of a message being replied to
in the reply; OK'd by deraadt@
-rw-r--r--usr.bin/vacation/vacation.110
-rw-r--r--usr.bin/vacation/vacation.c43
2 files changed, 45 insertions, 8 deletions
diff --git a/usr.bin/vacation/vacation.1 b/usr.bin/vacation/vacation.1
index 6ee0cec022f..d14afd2ada0 100644
--- a/usr.bin/vacation/vacation.1
+++ b/usr.bin/vacation/vacation.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vacation.1,v 1.6 1999/05/16 19:58:06 alex Exp $
+.\" $OpenBSD: vacation.1,v 1.7 1999/06/03 20:20:25 marc Exp $
.\" $NetBSD: vacation.1,v 1.5 1995/08/31 21:57:08 jtc Exp $
.\"
.\" Copyright (c) 1985, 1987, 1990, 1991, 1993
@@ -141,6 +141,14 @@ please contact Keith Bostic <bostic@CS.Berkeley.EDU>.
--eric
.Ed
.Pp
+Any occurance of the string
+.Li $SUBJECT
+in
+.Pa .vacation.msg
+will be replaced by the subject of the message that triggered the
+.Nm vacation
+program.
+.Pp
.Nm vacation
reads the incoming message from standard input, checking the message
headers for either the
diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c
index 0d053a79ef4..fb71d1de3ee 100644
--- a/usr.bin/vacation/vacation.c
+++ b/usr.bin/vacation/vacation.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vacation.c,v 1.11 1999/02/12 01:21:07 marc Exp $ */
+/* $OpenBSD: vacation.c,v 1.12 1999/06/03 20:20:26 marc Exp $ */
/* $NetBSD: vacation.c,v 1.7 1995/04/29 05:58:27 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)vacation.c 8.2 (Berkeley) 1/26/94";
#endif
-static char rcsid[] = "$OpenBSD: vacation.c,v 1.11 1999/02/12 01:21:07 marc Exp $";
+static char rcsid[] = "$OpenBSD: vacation.c,v 1.12 1999/06/03 20:20:26 marc Exp $";
#endif /* not lint */
/*
@@ -90,6 +90,7 @@ ALIAS *names;
DB *db;
char from[MAXLINE];
+char subj[MAXLINE];
int junkmail __P((void));
int nsearch __P((char *, char *));
@@ -219,7 +220,8 @@ readheaders()
case 'F': /* "From " */
cont = 0;
if (!strncmp(buf, "From ", 5)) {
- for (p = buf + 5; *p && *p != ' '; ++p);
+ for (p = buf + 5; *p && *p != ' '; ++p)
+ ;
*p = '\0';
(void)strcpy(from, buf + 5);
if (p = strchr(from, '\n'))
@@ -234,7 +236,8 @@ readheaders()
sizeof("Return-Path:")-1) ||
buf[12] != ' ' && buf[12] != '\t')
break;
- for (p = buf + 12; *p && isspace(*p); ++p);
+ for (p = buf + 12; *p && isspace(*p); ++p)
+ ;
if (strlcpy(from, p, sizeof from ) > sizeof from) {
syslog(LOG_NOTICE,
"Return-Path %s exceeds limits", p);
@@ -260,6 +263,22 @@ readheaders()
!strncasecmp(p, "list", 4))
exit(0);
break;
+ case 'S': /* Subject: */
+ cont = 0;
+ if (strncasecmp(buf, "Subject:",
+ sizeof("Subject:")-1) ||
+ buf[8] != ' ' && buf[8] != '\t')
+ break;
+ for (p = buf + 8; *p && isspace(*p); ++p)
+ ;
+ if (strlcpy(subj, p, sizeof subj ) > sizeof subj) {
+ syslog(LOG_NOTICE,
+ "Subject %s exceeds limits", p);
+ exit(1);
+ }
+ if (p = strchr(subj, '\n'))
+ *p = '\0';
+ break;
case 'C': /* "Cc:" */
if (strncmp(buf, "Cc:", 3))
break;
@@ -334,7 +353,8 @@ junkmail()
++p;
else
p = from;
- for (; *p; ++p);
+ for (; *p; ++p)
+ ;
}
len = p - from;
for (cur = ignore; cur->name; ++cur)
@@ -452,8 +472,17 @@ sendmessage(myname)
close(pvect[0]);
sfp = fdopen(pvect[1], "w");
fprintf(sfp, "To: %s\n", from);
- while (fgets(buf, sizeof buf, mfp))
- fputs(buf, sfp);
+ while (fgets(buf, sizeof buf, mfp)) {
+ char *s = strstr(buf, "$SUBJECT");
+ if ( s ) {
+ *s = 0;
+ fputs(buf, sfp);
+ fputs(subj, sfp);
+ fputs(s+8, sfp);
+ } else {
+ fputs(buf, sfp);
+ }
+ }
fclose(mfp);
fclose(sfp);
}