From: Timmy Douglas via Bug reports for GNU Guix <bug-guix@gnu.org>
To: me@tobias.gr, 53547@debbugs.gnu.org
Subject: bug#53547: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf
Date: Fri, 01 Dec 2023 21:15:12 -0800 [thread overview]
Message-ID: <8734wlqj6n.fsf@timmydouglas.com> (raw)
In-Reply-To: <87plzq7zwa.fsf@nckx>
Tobias Geerinckx-Rice <me@tobias.gr> writes:
> [snip]
> I'm running opensmtpd@7.4.0p1. Have you tried that yet?
>
> Guix would certainly accept a patch to fix a bug, but I'm also
> paranoid and would prefer to first see some response from upstream
> that this is the correct diagnosis.
So I found a workaround on my computer with that script that didn't seem
to repro. If I set TZ=UTC instead of what I had
(TZ=America/Los_Angeles), I was able to make that script work. I should
be able to propagate that to mcron and work around the issue...
What I tried before that:
When I straced sendmail earlier I saw this:
[pid 29134] newfstatat(5, "", {st_mode=S_IFSOCK|0777, st_size=0, ...}, AT_EMPTY_PATH) = 0
[pid 29134] read(5, "220 localhost ESMTP OpenSMTPD\r\n", 4096) = 31
[pid 29134] write(5, "EHLO localhost\r\n", 16) = 16
[pid 29134] read(5, "250-localhost Hello localhost [l"..., 4096) = 128
[pid 29134] write(5, "MAIL FROM:<timmy@localhost> \r\n", 31) = 31
[pid 29134] read(5, "250 2.0.0 Ok\r\n", 4096) = 14
[pid 29134] write(5, "RCPT TO:<root@localhost> \r\n", 27) = 27
[pid 29134] read(5, "250 2.1.5 Destination address va"..., 4096) = 51
[pid 29134] write(5, "DATA\r\n", 6) = 6
[pid 29134] read(5, "354 Enter mail, end with \".\" on "..., 4096) = 50
[pid 29134] write(2, "sendmail: time_to_text: bsnprint"..., 34sendmail: time_to_text: bsnprintf
) = 34
[pid 29134] write(5, "From: timmy <timmy@localhost>\r\n", 31) = 31
[pid 29134] exit_group(1) = ?
It looks like the code of the sendmail client will try to add a Date
header if one wasn't passed to the client. (smtp_session.c:2647)
I was able to send an email directly with telnet, so that verified the
code wasn't on the server. I tried throwing together a standalone repro
(below), but didn't have any luck reproducing it. With opensmtpd's
sendmail being setgid, I didn't really feel like debugging further.
// compile with
// gcc ./a.c
// run with
// ./a.out
#include <stdio.h>
#include <time.h>
#include <stdarg.h>
#include <stdlib.h>
int
bsnprintf(char *str, size_t size, const char *format, ...)
{
int ret;
va_list ap;
va_start(ap, format);
ret = vsnprintf(str, size, format, ap);
va_end(ap);
if (ret < 0 || (size_t)ret >= size)
return 0;
return 1;
}
const char *
time_to_text(time_t when)
{
struct tm *lt;
static char buf[40];
const char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
const char *month[] = {"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
const char *tz;
long offset;
lt = localtime(&when);
if (lt == NULL || when == 0)
perror("time_to_text: localtime");
#if 1
offset = lt->tm_gmtoff;
tz = lt->tm_zone;
#elif 0
offset = lt->tm_isdst > 0 ? altzone : timezone;
tz = lt->tm_isdst > 0 ? tzname[1] : tzname[0];
#endif
/* We do not use strftime because it is subject to locale substitution*/
if (!bsnprintf(buf, sizeof(buf),
"%s, %d %s %d %02d:%02d:%02d %c%02d%02d (%s)",
day[lt->tm_wday], lt->tm_mday, month[lt->tm_mon],
lt->tm_year + 1900,
lt->tm_hour, lt->tm_min, lt->tm_sec,
offset >= 0 ? '+' : '-',
abs((int)offset / 3600),
abs((int)offset % 3600) / 60,
tz))
perror("time_to_text: bsnprintf");
else
{
printf("'%s'", buf);
}
return buf;
}
int main(int argc, char** argv){
time_t now=time(NULL);
time_to_text(now);
struct tm *lt=localtime(&now);
}
prev parent reply other threads:[~2023-12-02 5:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 5:51 bug#53547: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf Timmy Douglas via Bug reports for GNU Guix
2023-11-21 7:09 ` Timmy Douglas via Bug reports for GNU Guix
2023-11-22 17:57 ` Nathan via Bug reports for GNU Guix
2023-11-23 0:03 ` Timmy Douglas via Bug reports for GNU Guix
[not found] ` <87plzq7zwa.fsf@nckx>
2023-12-02 5:15 ` Timmy Douglas via Bug reports for GNU Guix [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8734wlqj6n.fsf@timmydouglas.com \
--to=bug-guix@gnu.org \
--cc=53547@debbugs.gnu.org \
--cc=mail@timmydouglas.com \
--cc=me@tobias.gr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).