smtpd: broken sendmail compatibility
Lloyd <[email protected]>
| Newsgroups | gmane.os.openbsd.bugs |
|---|---|
| Message-ID | <UOZjEvtG0tbod86a9l84SKRvnbcs_j3bVFDSGhW9ToW_gCj54S2QNGSVn1MobCvkSMIL6h2Ln1BEvfozhSoxr69-0dGFb9cSp9PNq_JFero=@proton.me> |
This has been a defect since OpenBSD 5.6 when OpenSMTPD was made the
default MTA.
When invoked as sendmail(8), smtpctl(8) implements a minimal set of
features from Sendmail. As per the man page:
To maintain compatibility with Sendmail, Inc.'s implementation of
sendmail, various other flags are accepted, but have no effect.
This is generally ok, EXCEPT when sendmail is invoked with -bs.
The -bs flag is defined as follows:
Use the SMTP protocol as described in RFC821 on standard input
and output.
This implies a very different mode of operation and will cause some
applications to hang if they invoke `sendmail -bs` because they
expect a RFC821 response on stdio. The way it behaves is broken.
Since sendmail(8) does not implement this function, it shall reject
the -bs flag if invoked to allow the calling application to error out.
I've posted this patch before a few times but never received feedback.
Regards
Lloyd
Index: usr.sbin/smtpd/smtpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.c,v
diff -u -p -u -r1.178 smtpctl.c
--- usr.sbin/smtpd/smtpctl.c 3 Aug 2026 06:58:55 -0000 1.178
+++ usr.sbin/smtpd/smtpctl.c 15 Aug 2026 00:24:21 -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.
*/
- 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();