summaryrefslogtreecommitdiff
path: root/src/qmail-smtpd.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 19:03:11 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 19:03:11 +0200
commit20b85c03e751b4876fa3c92040464e483172b746 (patch)
tree734fadbfdbc143ec4465093857f4c239448715e0 /src/qmail-smtpd.c
parenta6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (diff)
manual format adjustment
Diffstat (limited to 'src/qmail-smtpd.c')
-rw-r--r--src/qmail-smtpd.c70
1 files changed, 53 insertions, 17 deletions
diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c
index 6d2d0d4..035eecf 100644
--- a/src/qmail-smtpd.c
+++ b/src/qmail-smtpd.c
@@ -93,6 +93,7 @@ void flush()
{
buffer_flush(&bo);
} // this triggers writing to STDIO
+
void out(char *s)
{
buffer_puts(&bo, s);
@@ -121,8 +122,9 @@ int dnsq(char *arg, char type)
at = byte_rchr(arg, len, '@');
if (at < len) {
if (!stralloc_copyb(&sa, arg + at + 1, len - at - 1)) die_nomem();
- } else if (!stralloc_copyb(&sa, arg, len))
+ } else if (!stralloc_copyb(&sa, arg, len)) {
die_nomem();
+ }
random = now() + (getpid() << 16);
@@ -150,10 +152,12 @@ void smtp_greet(char *code)
buffer_puts(&bo, code);
buffer_put(&bo, greeting.s, greeting.len);
}
+
void smtp_help()
{
out("214 s/qmail home page: https://www.fehcom.de/sqmail.html\r\n");
}
+
void smtp_quit()
{
smtp_greet("221 ");
@@ -247,8 +251,18 @@ static struct cdb cdbm;
static struct cdb cdbl;
static int fdbmt;
-int flagmimetype =
- 0; /* 1: white; 2: cdb; 3: white+cdb; 4: !relay+white; 6: !relay+white+cdb; -1: found in cdb; -2: found white */
+
+/*
+ -2: found white
+ -1: found in cdb;
+ 1: white;
+ 2: cdb;
+ 3: white+cdb;
+ 4: !relay+white;
+ 6: !relay+white+cdb;
+*/
+int flagmimetype = 0;
+
char *badmimeinit;
static int fdblt;
@@ -275,13 +289,32 @@ int greylist = 0;
stralloc pgbind = {0};
char *auth;
-int smtpauth =
- 0; /* -1:Cert 0:none 1:login/plain 2:cram 3:login/plain/cram 11:must_login/plain 12:must_2 13:must_3 */
+
+/*
+ -1: Cert
+ 0: none
+ 1: login/plain
+ 2: cram
+ 3: login/plain/cram
+ 11: must_login/plain
+ 12: must_2
+ 13: must_3
+*/
+int smtpauth = 0;
+
int seenauth = 0; /* 1:ESMTPA 2:~CLIENTDN */
stralloc authmethod = {0};
-int starttls =
- 0; /* -1:TLS 0:none 1:STARTTLS 2:require_STARTTLS 3:relay_if_CLIENTDN 4:require_+_relay_if_CLIENTDN */
+/*
+ -1: TLS
+ 0: none
+ 1: STARTTLS
+ 2: require_STARTTLS
+ 3: relay_if_CLIENTDN
+ 4: require_+_relay_if_CLIENTDN
+*/
+int starttls = 0;
+
int seentls = 0; /* 1:~STARTTLS 2:~TLS 3:~CLIENTDN */
char *ucspitls = 0;
char *tlsversion;
@@ -344,8 +377,9 @@ void setup()
remoteip = remoteip + 7;
flagip6 = 0;
}
- } else
+ } else {
flagip6 = 0;
+ }
if (!remoteip) {
remoteip = "unknown";
flagip6 = -1;
@@ -375,7 +409,7 @@ void setup()
if (x) {
scan_ulong(x, &u);
maxrcptcount = u;
- };
+ }
if (!(maxrcptcount + 1)) --maxrcptcount;
helocheck = env_get("HELOCHECK");
@@ -390,12 +424,12 @@ void setup()
if (x) {
scan_ulong(x, &u);
tarpitcount = u;
- };
+ }
x = env_get("TARPITDELAY");
if (x) {
scan_ulong(x, &u);
tarpitdelay = u;
- };
+ }
x = env_get("POSTGREY"); // RFC 6647
if (x) {
@@ -532,9 +566,9 @@ int modssl_info()
cipherused = env_get("SSL_CIPHER_USEKEYSIZE");
if (!cipherused) cipherused = "unknown";
clientdn = env_get("SSL_CLIENT_S_DN");
- if (!clientdn)
+ if (!clientdn) {
clientdn = "none";
- else {
+ } else {
seentls = 3;
seenauth = 2;
smtpauth = -1;
@@ -794,13 +828,14 @@ int brtcheck()
}
i = 0;
- for (j = 0; j < brt.len; ++j)
+ for (j = 0; j < brt.len; ++j) {
if (!brt.s[j]) {
subvalue = brt.s[i] != '!';
if (!subvalue) i++;
if ((k != subvalue) && wildmat(addr.s, brt.s + i)) k = subvalue;
i = j + 1;
}
+ }
return k;
}
return 0;
@@ -842,9 +877,9 @@ int localaddr(char *mf)
if (localmf == 3) {
if (!case_diffs(remoteinfo, mf)) return 2;
return -3;
- } else if (localmf == 2)
+ } else if (localmf == 2) {
return mfrules(fdmav, remoteip, remotehost, remoteinfo, mf);
- else {
+ } else {
if (str_len(localmfcheck) > 1) {
case_lowerb(localmfcheck, str_len(localmfcheck));
at = byte_rchr(mf, mflen, '@');
@@ -988,8 +1023,9 @@ void mailfrom_parms(char *arg)
}
if (case_starts(mfparms.s, "AUTH=")) mailfrom_auth(mfparms.s + 5, mfparms.len - 5);
if (!stralloc_copys(&mfparms, "")) die_nomem();
- } else if (!stralloc_catb(&mfparms, arg, 1))
+ } else if (!stralloc_catb(&mfparms, arg, 1)) {
die_nomem();
+ }
}
}
}