>Synopsis: smtpd does not reject -bs switch causing deadlock
>Category: mail
>Environment:
System : OpenBSD 7.7
Details : OpenBSD 7.7 (GENERIC) #619: Sun Apr 13 08:19:34 MDT 2025
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
The default behavior of smtpctl(8) when invoked as `sendmail` is to
ignore
all unsupported flags, rather than reject them. Per the man page:
"To maintain compatibility with Sendmail, Inc.'s implementation of
sendmail, various other flags are accepted, but have no effect."
In the original Sendmail, the -bs flag implies the following alternate
mode:
"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."
i.e. running `sendmail -bs` should immediately write an SMTP greeting
to stdout:
220 foo.bar ESMTP Sendmail 8.14.8/8.14.8/Submit; Wed, 30 Apr 2025
19:03:40 GMT
Software that calls /usr/sbin/sendmail -bs when OpenSMTPD is the
default MTA
will deadlock if until such time it times out, as it is waiting for an
SMTP
greeting which never comes, and smtpctl is waiting for input on stdin.
>How-To-Repeat:
1. run `sendmail -bs`
2. note no greeting is returned
3. smtpctl sits there waiting on stdin
>Fix:
The below patch will explicitly throw an error if smtpctl is invoked as
`sendmail` and -bs is specified on the command line, signaling to the
caller that -bs mode is not supported by OpenSMTPD.
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();