This is a little piece of code which can be applied onto toaster-0.8.
It provides the "require authentication" function to netqmail.
After applying the patch, set the environment REQUIREAUTH="" in the
tcp.smtp file and it will require all smtp session to be authenticated.
Hope this help those who need this function in their qmail
installation. (like me)
Bill, you can incorporate the code into your next release of toaster if
you find it appropriate.
Kelvin
--- qmail-smtpd.c.orig 2005-09-07 09:33:08.000000000 +0800
+++ qmail-smtpd.c 2005-09-07 09:33:58.000000000 +0800
@@ -125,6 +125,7 @@
int err_noauth() { out("504 auth type unimplemented (#5.5.1)\r\n"); return -1;
}
int err_authabrt() { out("501 auth exchange canceled (#5.0.0)\r\n"); return
-1; }
int err_input() { out("501 malformed auth input (#5.5.4)\r\n"); return -1; }
+void err_authrequired() { out("503 you must authenticate first (#5.5.1)\r\n");
}
void err_authfail() { out("535 authentication failed (#5.7.1)\r\n"); }
int saferead(fd,buf,len) int fd; char *buf; int len;
@@ -170,6 +171,8 @@
char *remoteinfo;
char *local;
char *relayclient;
+char *requireauth;
+int flagauth = 0;
stralloc helohost = {0};
char *fakehelo; /* pointer into helohost, or 0 */
@@ -259,6 +262,7 @@
if (!remotehost) remotehost = "unknown";
remoteinfo = env_get("TCPREMOTEINFO");
relayclient = env_get("RELAYCLIENT");
+ requireauth = env_get("REQUIREAUTH");
#ifdef TLS
if (env_get("SMTPS")) { smtps = 1; tls_init(); }
@@ -501,6 +505,7 @@
void smtp_mail(arg) char *arg;
{
int r;
+ if (requireauth && !flagauth) { err_authrequired(); return; }
if (!addrparse(arg)) { err_syntax(); return; }
flagsize = 0;
mailfrom_parms(arg);
@@ -767,7 +772,6 @@
static stralloc slop = {0}; /* b64 challenge */
#endif
-int flagauth = 0;
char **childargs;
char ssauthbuf[512];
substdio ssauth = SUBSTDIO_FDBUF(safewrite,3,ssauthbuf,sizeof(ssauthbuf));