aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-02-08 05:41:05 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-02-08 05:41:05 +0000
commit9c5a1f23f1c04458ec35c8713737be1df629339f (patch)
treee342b1b58db16d10c7be74971b7c4c31db6b7dbc
parent17a28de8bf05d314426ed6498e2690baac129b58 (diff)
downloadsmtpd-starttls-proxy-9c5a1f23f1c04458ec35c8713737be1df629339f.tar.gz
s6-tlsc needs two distinct fds as 6 and 7
-rw-r--r--src/qmail-remote/qmail-remote.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/qmail-remote/qmail-remote.c b/src/qmail-remote/qmail-remote.c
index 2fa98ab..a9fdd13 100644
--- a/src/qmail-remote/qmail-remote.c
+++ b/src/qmail-remote/qmail-remote.c
@@ -28,15 +28,18 @@
#define dieusage() qmailr_perm("qmail-remote was invoked improperly")
-static inline void exec_tls (int fd, char const *fmtip, unsigned int timeoutconnect, unsigned int timeoutremote, qmailr_tls const *qtls, size_t helopos, size_t const *eaddrpos, unsigned int n, char const *storage) gccattr_noreturn ;
-static inline void exec_tls (int fd, char const *fmtip, unsigned int timeoutconnect, unsigned int timeoutremote, qmailr_tls const *qtls, size_t helopos, size_t const *eaddrpos, unsigned int n, char const *storage)
+static inline void exec_tls (int fdr, char const *fmtip, unsigned int timeoutconnect, unsigned int timeoutremote, qmailr_tls const *qtls, size_t helopos, size_t const *eaddrpos, unsigned int n, char const *storage) gccattr_noreturn ;
+static inline void exec_tls (int fdr, char const *fmtip, unsigned int timeoutconnect, unsigned int timeoutremote, qmailr_tls const *qtls, size_t helopos, size_t const *eaddrpos, unsigned int n, char const *storage)
{
+ int fdw = dup(fdr) ;
unsigned int m = 0 ;
- char fmtfd[UINT_FMT] ;
+ char fmtr[UINT_FMT] ;
+ char fmtw[UINT_FMT] ;
char fmtt[UINT_FMT] ;
char fmtk[UINT_FMT] ;
char const *argv[20 + n] ;
+ if (fdw == -1) qmailr_tempusys("duplicate file descriptor") ;
if (!env_mexec("TLS_UID", 0) || !env_mexec("TLS_GID", 0)
|| !env_mexec(qtls->flagtadir ? "CADIR" : "CAFILE", storage + qtls->tapos)) dienomem() ;
if (qtls->flagclientcert)
@@ -54,7 +57,8 @@ static inline void exec_tls (int fd, char const *fmtip, unsigned int timeoutconn
}
}
- fmtfd[uint_fmt(fmtfd, (unsigned int)fd)] = 0 ;
+ fmtr[uint_fmt(fmtr, (unsigned int)fdr)] = 0 ;
+ fmtw[uint_fmt(fmtw, (unsigned int)fdw)] = 0 ;
fmtt[uint_fmt(fmtt, timeoutremote)] = 0 ;
fmtk[uint_fmt(fmtk, timeoutconnect > UINT_MAX/1000 ? UINT_MAX : timeoutconnect * 1000)] = 0 ;
@@ -63,18 +67,18 @@ static inline void exec_tls (int fd, char const *fmtip, unsigned int timeoutconn
argv[m++] = "-K" ;
argv[m++] = fmtk ;
argv[m++] = "-6" ;
- argv[m++] = fmtfd ;
+ argv[m++] = fmtr ;
argv[m++] = "-7" ;
- argv[m++] = fmtfd ;
+ argv[m++] = fmtw ;
argv[m++] = "--" ;
argv[m++] = SMTPD_STARTTLS_PROXY_LIBEXECPREFIX "qmail-remote-io" ;
argv[m++] = "-t" ;
argv[m++] = fmtt ;
argv[m++] = "-6" ;
- argv[m++] = fmtfd ;
+ argv[m++] = fmtr ;
argv[m++] = "-7" ;
- argv[m++] = fmtfd ;
+ argv[m++] = fmtw ;
argv[m++] = "--" ;
argv[m++] = fmtip ;
argv[m++] = storage + helopos ;