From: Lloyd Subject: smtpd: reject the -bs flag in sendmail-compat mode To: "tech@openbsd.org" Date: Wed, 30 Apr 2025 19:14:25 +0000 The below patch formally rejects the -bs flag when passed to smtpctl in sendmail compatibility mode. When -bs is passed to OG sendmail(tm) it implies very different behavior: Use the SMTP protocol as described in RFC821 on standard input and output. This flag implies all the operations of the -ba flag that are compatible with SMTP. e.g. running sendmail -bs will immediately return the following on stdout: 220 foo.bar ESMTP Sendmail 8.14.8/8.14.8/Submit; Wed, 30 Apr 2025 19:03:40 GMT This was a source of a long-standing bug in Alpine since the switch to smtpd in OpenBSD 5.6, which would cause it to hang indefinitely when sending a message to the local mail queue (documented here): https://marc.info/?l=openbsd-ports&m=174603887323430&w=2 With this patch, smtpctl will return an error if -bs is requested, notifying the calling application something is wrong because that mode is unsupported. With this change, the following is immediately returned in Alpine instead of hanging indefinitely at "Sending..." until the process was killed: [Error sending: SMTP greeting failure: 421 SMTP connection broken (reply)] Index: smtpctl.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.c,v retrieving revision 1.176 diff -u -p -u -p -r1.176 smtpctl.c --- smtpctl.c 21 Nov 2024 13:42:22 -0000 1.176 +++ smtpctl.c 30 Apr 2025 18:28:50 -0000 @@ -1115,10 +1115,16 @@ sendmail_compat(int argc, char **argv) /* * determine whether we are called with flags * that should invoke makemap/newaliases. + * + * if unsupported sendmail -bs mode is invoked, + * return an error to the calling application. */ - for (i = 1; i < argc; i++) + for (i = 1; i < argc; i++) { if (strncmp(argv[i], "-bi", 3) == 0) exit(makemap(P_SENDMAIL, argc, argv)); + if (strncmp(argv[i], "-bs", 3) == 0) + errx(1, "-bs mode is not supported"); + } if (!srv_connect()) offlinefp = offline_file();