summaryrefslogtreecommitdiff
path: root/src/qmail-smtpam.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-smtpam.c
parenta6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (diff)
manual format adjustment
Diffstat (limited to 'src/qmail-smtpam.c')
-rw-r--r--src/qmail-smtpam.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/qmail-smtpam.c b/src/qmail-smtpam.c
index 89105c3..77f0718 100644
--- a/src/qmail-smtpam.c
+++ b/src/qmail-smtpam.c
@@ -38,19 +38,20 @@
#define MAX_SIZE 200000000
#define HUGESMTPTEXT 5000
-#define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */
+#define PORT_SMTP 25 // silly rabbit, /etc/services is for users
#define PORT_SMTPS 465
#define VERIFYDEPTH 1
#define FDPAM 3
#define WHO "qmail-smtpam"
-/** @file qmail-smtpam.c -- TLS enabled SMTP PAM to check mailbox at remote MX
- */
+/**
+ * @file qmail-smtpam.c -- TLS enabled SMTP PAM to check mailbox at remote MX
+ */
int flagauth = 0; /* 1 = login; 2 = plain; 3 =crammd5 */
int flagsmtps = 0; /* RFC 8314 - 'implicit TLS' */
-int flagtls = 0; /* -2 = rejected; -1 = not; 0 = no, default;
+int flagtls = 0; /* -2 = rejected; -1 = not; 0 = no, default;
> 0 see tls_remote.c
+10 = SMTPS; +20 = QMTPS; 100 = active TLS connection */
int flagverify = 0; /* 1 = verify Cert against CA ; -1 = Cert pinning */
@@ -58,10 +59,10 @@ int flagutf8mail = 0;
unsigned long port = PORT_SMTP;
-GEN_ALLOC_typedef(saa, stralloc, sa, len, a)
- GEN_ALLOC_readyplus(saa, stralloc, sa, len, a, i, n, x, 10, saa_readyplus)
+GEN_ALLOC_typedef(saa, stralloc, sa, len, a);
+GEN_ALLOC_readyplus(saa, stralloc, sa, len, a, i, n, x, 10, saa_readyplus);
- stralloc helohost = {0};
+stralloc helohost = {0};
stralloc host = {0};
stralloc ports = {0};
stralloc remotehost = {0};
@@ -89,16 +90,19 @@ void out(char *s)
{
if (buffer_puts(buffer_1small, s) == -1) _exit(111);
}
+
void zero()
{
if (buffer_put(buffer_1small, "\0", 1) == -1) _exit(111);
}
+
void zerodie()
{
zero();
buffer_flush(buffer_1small);
_exit(111);
}
+
void outsafe(stralloc *sa)
{
int i;
@@ -116,16 +120,19 @@ void temp_noip()
out("Zinvalid ipaddr in control/domainips (#4.3.0)\n");
zerodie();
}
+
void temp_nomem()
{
out("ZOut of memory. (#4.3.0)\n");
zerodie();
}
+
void temp_oserr()
{
out("ZSystem resources temporarily unavailable. (#4.3.0)\n");
zerodie();
}
+
void temp_osip()
{
out("ZCan't bind to local ip address: ");
@@ -133,11 +140,13 @@ void temp_osip()
out(". (#4.3.0)\n");
zerodie();
}
+
void temp_noconn()
{
out("ZSorry, I wasn't able to establish an SMTP connection. (#4.4.1)\n");
zerodie();
}
+
void temp_dnscanon()
{
out("ZCNAME lookup failed temporarily for: ");
@@ -145,6 +154,7 @@ void temp_dnscanon()
out(". (#4.4.3)\n");
zerodie();
}
+
void temp_dns()
{
out("ZSorry, I couldn't find any host named: ");
@@ -152,21 +162,25 @@ void temp_dns()
out(". (#4.1.2)\n");
zerodie();
}
+
void temp_chdir()
{
out("ZUnable to switch to home directory. (#4.3.0)\n");
zerodie();
}
+
void temp_control()
{
out("ZUnable to read control files. (#4.3.0)\n");
zerodie();
}
+
void perm_usage()
{
out("Dqmail-smtpam was invoked improperly. (#5.3.5)\n");
zerodie();
}
+
void perm_dns()
{
out("DSorry, I couldn't find any host named: ");
@@ -174,6 +188,7 @@ void perm_dns()
out(". (#5.1.2)\n");
zerodie();
}
+
void outhost()
{
char ipaddr[IPFMT];
@@ -262,7 +277,7 @@ unsigned long smtpcode()
void outsmtptext()
{
int i;
- if (smtptext.s)
+ if (smtptext.s) {
if (smtptext.len) {
out("Remote host said: ");
for (i = 0; i < smtptext.len; ++i)
@@ -270,6 +285,7 @@ void outsmtptext()
if (buffer_put(buffer_1small, smtptext.s, smtptext.len) == -1) _exit(111);
smtptext.len = 0;
}
+ }
}
void quit(char *prepend, char *append)
@@ -443,12 +459,13 @@ void smtp()
if (flagutf8mail) buffer_puts(&bo, " SMTPUTF8");
- if (flagtls > 0 && flagtls < 10) /* STARTTLS */
+ if (flagtls > 0 && flagtls < 10) { /* STARTTLS */
if (starttls_peer()) {
smtp_starttls();
} else if (flagtls > 2) {
temp_tlshost();
}
+ }
buffer_puts(&bo, "MAIL FROM:<>");
if (flagutf8mail) buffer_puts(&bo, " SMTPUTF8");