Download raw body.
mail(1) set Date and User-Agent [was: Re: Back to rfc2045]
On Fri, Aug 02, 2024 at 12:21:43PM +0200, Sven M. Hallberg wrote:
> NB: Calling date() twice in puthead() seems wrong and is useless anyway,
> since it never returns NULL.
>
Solved:
Index: extern.h
===================================================================
RCS file: /cvs/src/usr.bin/mail/extern.h,v
diff -u -p -r1.30 extern.h
--- extern.h 21 May 2024 05:00:48 -0000 1.30
+++ extern.h 2 Aug 2024 15:06:36 -0000
@@ -100,6 +100,7 @@ int collabort(void);
void commands(void);
int copycmd(void *);
int count(struct name *);
+size_t date(char *str);
int deletecmd(void *);
int delm(int *);
int deltype(void *);
Index: send.c
===================================================================
RCS file: /cvs/src/usr.bin/mail/send.c,v
diff -u -p -r1.26 send.c
--- send.c 8 Mar 2023 04:43:11 -0000 1.26
+++ send.c 2 Aug 2024 15:06:36 -0000
@@ -516,15 +516,22 @@ puthead(struct header *hp, FILE *fo, int
{
int gotcha;
char *from;
+ char time[32];
gotcha = 0;
from = hp->h_from ? hp->h_from : value("from");
+ if (date(time) > 0 && fo != stdout)
+ fprintf(fo, "Date: %s\n", time), gotcha++;
if (from != NULL)
fprintf(fo, "From: %s\n", from), gotcha++;
if (hp->h_to != NULL && w & GTO)
fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++;
if (hp->h_subject != NULL && w & GSUBJECT)
fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++;
+ if (fo != stdout) {
+ fprintf(fo, "User-Agent: OpenBSD mail(1)\n"),
+ gotcha++;
+ }
if (hp->h_cc != NULL && w & GCC)
fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++;
if (hp->h_bcc != NULL && w & GBCC)
Index: util.c
===================================================================
RCS file: /cvs/src/usr.bin/mail/util.c,v
diff -u -p -r1.2 util.c
--- util.c 26 Dec 2022 19:16:01 -0000 1.2
+++ util.c 2 Aug 2024 15:06:36 -0000
@@ -641,3 +641,20 @@ clearnew(void)
}
}
}
+
+size_t
+date(char *str)
+{
+ struct tm newtime;
+ time_t ltime;
+ static char buf[32];
+ size_t n;
+
+ ltime = time(<ime);
+ localtime_r(<ime, &newtime);
+ n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z", &newtime);
+
+ snprintf(str, sizeof(buf), "%s\n", buf);
+
+ return (n);
+}
--
Walter
mail(1) set Date and User-Agent [was: Re: Back to rfc2045]