From unknown Wed Jun 18 23:17:51 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#53547 <53547@debbugs.gnu.org> To: bug#53547 <53547@debbugs.gnu.org> Subject: Status: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf Reply-To: bug#53547 <53547@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:17:51 +0000 retitle 53547 Error sending email with OpenSMTPD, fatal: time_to_text: bsnp= rintf reassign 53547 guix submitter 53547 Timmy Douglas severity 53547 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 26 00:51:38 2022 Received: (at submit) by debbugs.gnu.org; 26 Jan 2022 05:51:38 +0000 Received: from localhost ([127.0.0.1]:50811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCbDW-0001Ne-6z for submit@debbugs.gnu.org; Wed, 26 Jan 2022 00:51:38 -0500 Received: from lists.gnu.org ([209.51.188.17]:34954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCbDV-0001NW-7t for submit@debbugs.gnu.org; Wed, 26 Jan 2022 00:51:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCbDU-00024K-Fz for bug-guix@gnu.org; Wed, 26 Jan 2022 00:51:36 -0500 Received: from out1.migadu.com ([91.121.223.63]:28316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCbDR-0003bZ-LF for bug-guix@gnu.org; Wed, 26 Jan 2022 00:51:36 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timmydouglas.com; s=key1; t=1643176290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=Qme3xTnBb5fFPTaVdJYGxxr2H11e5T2VAq3b3VPNl5k=; b=Qj0xueehbEnlP+hNJ/Wt64V38ylPV3ElY2Wbe8bHa20THsRcqHeRdyHQXJfBpC1emoYsv8 x9KJCffrKSQpdt4BKONcUwy1YLl225aXWShOcFmhRJMfCzonXpvszmAVT9cwe9YZ9buGdC MXRa5zk8t1F7jGwK28s11qLeYi3dzEU= From: Timmy Douglas To: bug-guix@gnu.org Subject: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf Date: Tue, 25 Jan 2022 21:51:27 -0800 Message-ID: <87mtjjkpsw.fsf@timmydouglas.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: timmydouglas.com Received-SPF: pass client-ip=91.121.223.63; envelope-from=mail@timmydouglas.com; helo=out1.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) I recently installed opensmtpd and have been trying to send email. It appears there is an error with the bsnprintf function: $ ./sendmail -t To: timmy From: me Subject: hi aoeueou (press ^D) sendmail: time_to_text: bsnprintf I reported this issue here: https://github.com/OpenSMTPD/OpenSMTPD/issues/1166 mcron appears to invoke sendmail with `-t`, which is how I discovered the issue. If anyone is trying to figure out how to setup the setuid on Guix system, here is my config.scm file (I couldn't find anything online so maybe this will help): (operating-system ; ... (append (list (setuid-program (program (file-append opensmtpd "/sbin/smtpctl")) (setuid? #f) (setgid? #t) (user "root") (group "smtpq")) (setuid-program (program (file-append opensmtpd "/sbin/sendmail")) (setuid? #f) (setgid? #t) (user "root") (group "smtpq"))) %setuid-programs)) I tried building the latest opensmtpd from git, which required a few other changes to patch the bug: diff --git a/usr.sbin/smtpd/smtpc.c b/usr.sbin/smtpd/smtpc.c index 49750dca..4ed506dc 100644 --- a/usr.sbin/smtpd/smtpc.c +++ b/usr.sbin/smtpd/smtpc.c @@ -114,8 +114,8 @@ parse_tls_options(char *opt) servname = value; break; case -1: - if (suboptarg) - fatalx("invalid TLS option \"%s\"", suboptarg); + //if (suboptarg) + // fatalx("invalid TLS option \"%s\"", suboptarg); fatalx("missing TLS option"); } } diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 00c49cb7..3630ef1d 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -52,6 +52,8 @@ #endif #include +#include + #include "smtpd.h" #include "parser.h" #include "log.h" diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c index 3ea04d89..9928d09b 100644 --- a/usr.sbin/smtpd/to.c +++ b/usr.sbin/smtpd/to.c @@ -176,7 +176,7 @@ const char * time_to_text(time_t when) { struct tm *lt; - static char buf[40]; + static char buf[50]; char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; char *month[] = {"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; @@ -193,6 +193,9 @@ time_to_text(time_t when) #elif defined HAVE_DECL_ALTZONE && defined HAVE_DECL_TIMEZONE offset = lt->tm_isdst > 0 ? altzone : timezone; tz = lt->tm_isdst > 0 ? tzname[1] : tzname[0]; +#else + offset = 0; + tz = "GMT"; #endif /* We do not use strftime because it is subject to locale substitution*/ From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 21 02:09:31 2023 Received: (at submit) by debbugs.gnu.org; 21 Nov 2023 07:09:31 +0000 Received: from localhost ([127.0.0.1]:55092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5Kt1-0006lO-0p for submit@debbugs.gnu.org; Tue, 21 Nov 2023 02:09:31 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5Ksv-0006l7-6h for submit@debbugs.gnu.org; Tue, 21 Nov 2023 02:09:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Ksn-0003KY-4b for bug-guix@gnu.org; Tue, 21 Nov 2023 02:09:17 -0500 Received: from out-178.mta1.migadu.com ([2001:41d0:203:375::b2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Ksk-0002DR-4S for bug-guix@gnu.org; Tue, 21 Nov 2023 02:09:16 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timmydouglas.com; s=key1; t=1700550549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Dn+0G0OlwGPnrmaPzKpDXtpPFx8ipXRq3/yhWnM4v94=; b=Ses+88N0pREmbsElkIv4JE0b9ZNdSXYnvc2lMtRNBoGov4M/zOy1RmV50olS7lX/BeJn+z 5NGTfYVWq6xrvck6Unc2CKIILBHFZBGAbS5XSJmer/mPlBiyVHBXYjSXkG0GLzSeB8qybX PA/pNEupEdpPspPB0311VSfT4b/gBjM= From: Timmy Douglas To: bug-guix@gnu.org Subject: Re: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf In-Reply-To: <87mtjjkpsw.fsf@timmydouglas.com> References: <87mtjjkpsw.fsf@timmydouglas.com> Date: Mon, 20 Nov 2023 23:09:05 -0800 Message-ID: <87jzqba8ha.fsf@timmydouglas.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::b2; envelope-from=mail@timmydouglas.com; helo=out-178.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Tobias Geerinckx-Rice X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Tobias, I noticed you recently updated opensmtpd to 7.4.0 with commit 5e7f27d6ca7be84453e6d4de3d860b700ba3aef7. I was curious if you or anyone else has seen this issue, and if I should try submitting a patch to guix for it. Timmy Douglas writes: > I recently installed opensmtpd and have been trying to send email. It > appears there is an error with the bsnprintf function: > > $ ./sendmail -t > To: timmy > From: me > Subject: hi > > aoeueou > (press ^D) > sendmail: time_to_text: bsnprintf > > I reported this issue here: > https://github.com/OpenSMTPD/OpenSMTPD/issues/1166 > > mcron appears to invoke sendmail with `-t`, which is how I discovered > the issue. > > If anyone is trying to figure out how to setup the setuid on Guix > system, here is my config.scm file (I couldn't find anything online so > maybe this will help): > > (operating-system > ; ... > (append (list (setuid-program > (program (file-append opensmtpd "/sbin/smtpctl")) > (setuid? #f) > (setgid? #t) > (user "root") > (group "smtpq")) > (setuid-program > (program (file-append opensmtpd "/sbin/sendmail")) > (setuid? #f) > (setgid? #t) > (user "root") > (group "smtpq"))) > %setuid-programs)) > > I tried building the latest opensmtpd from git, which required a few > other changes to patch the bug: > > > > diff --git a/usr.sbin/smtpd/smtpc.c b/usr.sbin/smtpd/smtpc.c > index 49750dca..4ed506dc 100644 > --- a/usr.sbin/smtpd/smtpc.c > +++ b/usr.sbin/smtpd/smtpc.c > @@ -114,8 +114,8 @@ parse_tls_options(char *opt) > servname = value; > break; > case -1: > - if (suboptarg) > - fatalx("invalid TLS option \"%s\"", suboptarg); > + //if (suboptarg) > + // fatalx("invalid TLS option \"%s\"", suboptarg); > fatalx("missing TLS option"); > } > } > diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c > index 00c49cb7..3630ef1d 100644 > --- a/usr.sbin/smtpd/smtpctl.c > +++ b/usr.sbin/smtpd/smtpctl.c > @@ -52,6 +52,8 @@ > #endif > #include > > +#include > + > #include "smtpd.h" > #include "parser.h" > #include "log.h" > diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c > index 3ea04d89..9928d09b 100644 > --- a/usr.sbin/smtpd/to.c > +++ b/usr.sbin/smtpd/to.c > @@ -176,7 +176,7 @@ const char * > time_to_text(time_t when) > { > struct tm *lt; > - static char buf[40]; > + static char buf[50]; > char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; > char *month[] = {"Jan","Feb","Mar","Apr","May","Jun", > "Jul","Aug","Sep","Oct","Nov","Dec"}; > @@ -193,6 +193,9 @@ time_to_text(time_t when) > #elif defined HAVE_DECL_ALTZONE && defined HAVE_DECL_TIMEZONE > offset = lt->tm_isdst > 0 ? altzone : timezone; > tz = lt->tm_isdst > 0 ? tzname[1] : tzname[0]; > +#else > + offset = 0; > + tz = "GMT"; > #endif > > /* We do not use strftime because it is subject to locale substitution*/ From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 22 13:03:36 2023 Received: (at submit) by debbugs.gnu.org; 22 Nov 2023 18:03:36 +0000 Received: from localhost ([127.0.0.1]:59865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5rZY-00020y-42 for submit@debbugs.gnu.org; Wed, 22 Nov 2023 13:03:36 -0500 Received: from lists.gnu.org ([2001:470:142::17]:54260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5rZW-00020l-TG for submit@debbugs.gnu.org; Wed, 22 Nov 2023 13:03:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5rZO-0002a9-3p for bug-guix@gnu.org; Wed, 22 Nov 2023 13:03:26 -0500 Received: from mail.nborghese.com ([207.148.28.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5rZI-0007RR-OP for bug-guix@gnu.org; Wed, 22 Nov 2023 13:03:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=062122; bh=oqUqzWNOf5tRa FYjF5qPdTo7MAzNRJC9K9wwuqckzLE=; h=date:in-reply-to:subject:to:from; d=nborghese.com; b=Nwi5JtWpcdoSsaKwBn6I2ASZBdJtawv3OoPq0tOc8Oixyze5zqE F5+I/Bjdhbcmacix6+4ttTPHj4d4o5BsDhFXj73i1zGXjSZb5AniLu3UCoUmjkeVLrd+2N B+NpKQQl+3cxI0cC6veiztq4SDgYqXijsELkEVIUIDqhJYGS+c= Received: by nborghese.com (OpenSMTPD) with ESMTPSA id 4eed7ac4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 22 Nov 2023 18:03:15 +0000 (UTC) From: Nathan To: mail@timmydouglas.com, bug-guix@gnu.org Subject: bug#53547: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf In-Reply-To: <87jzqba8ha.fsf@timmydouglas.com> Date: Wed, 22 Nov 2023 12:57:09 -0500 Message-ID: <87r0khis2j.fsf@nborghese.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=207.148.28.48; envelope-from=nathan_mail@nborghese.com; helo=mail.nborghese.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain I don't have this problem on my server. I looked at your github issue page. Those macros are defined by the `configure' script. I can see that guix's `configure' output defines HAVE_STRUCT_TM_TM_GMTOFF in config.h. (if neither of the #if match, then the `tz' pointer is likely garbage and the program will crash.) A problem with your time zone configuration seems like a reasonable guess. I'd check it with a simple C program like the one attached. --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=a.c Content-Transfer-Encoding: base64 Content-Description: test program Ly8gY29tcGlsZSB3aXRoCi8vIGdjYyAuL2EuYwovLyBydW4gd2l0aAovLyAuL2Eub3V0CiNpbmNs dWRlIDxzdGRpby5oPgojaW5jbHVkZSA8dGltZS5oPgppbnQgbWFpbihpbnQgYXJnYywgY2hhcioq IGFyZ3YpewoJdGltZV90IG5vdz10aW1lKE5VTEwpOwoJc3RydWN0IHRtICpsdD1sb2NhbHRpbWUo Jm5vdyk7CglwcmludGYoIlwiJXNcIlxuIixsdC0+dG1fem9uZSk7Cn0K --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 22 19:04:04 2023 Received: (at submit) by debbugs.gnu.org; 23 Nov 2023 00:04:04 +0000 Received: from localhost ([127.0.0.1]:60067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5xCN-00062F-UE for submit@debbugs.gnu.org; Wed, 22 Nov 2023 19:04:04 -0500 Received: from lists.gnu.org ([2001:470:142::17]:51594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5xCL-00061k-ES for submit@debbugs.gnu.org; Wed, 22 Nov 2023 19:04:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5xCA-0007l9-PN for bug-guix@gnu.org; Wed, 22 Nov 2023 19:03:51 -0500 Received: from out-173.mta0.migadu.com ([91.218.175.173]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5xC8-0004an-DG for bug-guix@gnu.org; Wed, 22 Nov 2023 19:03:50 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timmydouglas.com; s=key1; t=1700697824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LjNXfWQOpqY8ijsUyhCCMnTx1BAWmrRAMGiONSgDHkQ=; b=iH3lld2FMP7GHQTYJ6bJNbk1pXPjDnFzyzA+/HuovP9VV7fD1RvR0HXLTcQ8u5I2ESUvra g6IJHUbYUmSKmdiyr/icu2d3xjhwWoZEM7NG9Iwb7wIwvNN4YO3uAlDOe5KUm1rBNX+u9x p5EUpFdIgWmiE/v3DWtliDxMhsMS988= From: Timmy Douglas To: Nathan , bug-guix@gnu.org Subject: Re: bug#53547: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf In-Reply-To: <87r0khis2j.fsf@nborghese.com> References: <87r0khis2j.fsf@nborghese.com> Date: Wed, 22 Nov 2023 16:03:40 -0800 Message-ID: <87h6ld9vz7.fsf@timmydouglas.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.173; envelope-from=mail@timmydouglas.com; helo=out-173.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Nathan writes: > I don't have this problem on my server. > > I looked at your github issue page. > Those macros are defined by the `configure' script. > I can see that guix's `configure' output defines HAVE_STRUCT_TM_TM_GMTOFF in config.h. > (if neither of the #if match, then the `tz' pointer is likely garbage and the program will crash.) > > A problem with your time zone configuration seems like a reasonable guess. > I'd check it with a simple C program like the one attached. your app prints my timezone as expected. if you run something like this does it work for you? cat << EOF | /run/setuid-programs/sendmail $(whoami) To: $(whoami) Subject: test blah EOF for me, it prints: sendmail: time_to_text: bsnprintf my config.scm: (operating-system ... (setuid-programs (append (list (setuid-program (program (file-append opensmtpd "/sbin/smtpctl")) (setuid? #f) (setgid? #t) (user "root") (group "smtpq")) (setuid-program (program (file-append opensmtpd "/sbin/sendmail")) (setuid? #f) (setgid? #t) (user "root") (group "smtpq"))) %setuid-programs)) From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 02 00:15:43 2023 Received: (at submit) by debbugs.gnu.org; 2 Dec 2023 05:15:43 +0000 Received: from localhost ([127.0.0.1]:56492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9ILu-0003V3-F8 for submit@debbugs.gnu.org; Sat, 02 Dec 2023 00:15:42 -0500 Received: from lists.gnu.org ([2001:470:142::17]:58214) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9ILs-0003Ur-Rl for submit@debbugs.gnu.org; Sat, 02 Dec 2023 00:15:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9ILd-0006pX-DF for bug-guix@gnu.org; Sat, 02 Dec 2023 00:15:25 -0500 Received: from out-175.mta1.migadu.com ([95.215.58.175]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9ILa-00020z-V3 for bug-guix@gnu.org; Sat, 02 Dec 2023 00:15:25 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timmydouglas.com; s=key1; t=1701494117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KDiNtKeiWrqHr1i5SD6+xdiBeKbQqMhYsS8VG4vIhhk=; b=E+gFtbqeQXYRtcdZNqECs6kIw3S6B1odAoqRkkyq0LRHhbGLkgYFSgsU1znpYzcNPcPpPw 0c3vQ2NAH5VQ/wq9cwBOXd/83ezzB3RJqW4Zr2okhyONvI4gCx/RfrjQ2Pu/RhDpKsqIwC vvyL8ADo1uKz4rSONUWiHbHwjuNXCJY= From: Timmy Douglas To: Tobias Geerinckx-Rice , bug-guix@gnu.org Subject: Re: bug#53547: Error sending email with OpenSMTPD, fatal: time_to_text: bsnprintf In-Reply-To: <87plzq7zwa.fsf@nckx> References: <87mtjjkpsw.fsf@timmydouglas.com> <87jzqba8ha.fsf@timmydouglas.com> <87plzq7zwa.fsf@nckx> Date: Fri, 01 Dec 2023 21:15:12 -0800 Message-ID: <8734wlqj6n.fsf@timmydouglas.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.175; envelope-from=mail@timmydouglas.com; helo=out-175.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Tobias Geerinckx-Rice 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: \r\n", 31) = 31 [pid 29134] read(5, "250 2.0.0 Ok\r\n", 4096) = 14 [pid 29134] write(5, "RCPT TO: \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 \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 #include #include #include 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); }