1 --- netqmail-1.05/qmail-smtpd.c 2006-06-16 20:01:36.000000000 +0100
2 +++ netqmail-1.05-patched/qmail-smtpd.c 2006-06-16 20:03:03.000000000 +0100
4 int err_noauth() { out("504 auth type unimplemented (#5.5.1)\r\n"); return -1; }
5 int err_authabrt() { out("501 auth exchange canceled (#5.0.0)\r\n"); return -1; }
6 int err_input() { out("501 malformed auth input (#5.5.4)\r\n"); return -1; }
7 +#if defined(TLS) && defined(TLS_BEFORE_AUTH)
8 +int err_wantstarttls() { out("530 Must issue a STARTTLS command first (#5.7.0)\r\n"); return -1; };
10 void err_authfail() { out("535 authentication failed (#5.7.1)\r\n"); }
12 stralloc greeting = {0};
14 smtp_greet("250 "); out("\r\n");
15 seenmail = 0; dohelo(arg);
17 +void smtp_authout() {
19 + out("250-AUTH LOGIN PLAIN CRAM-MD5\r\n");
21 + out("250-AUTH LOGIN PLAIN\r\n");
24 /* ESMTP extensions are published here */
25 void smtp_ehlo(arg) char *arg;
29 size[fmt_ulong(size,(unsigned int) databytes)] = 0;
30 out("\r\n250-PIPELINING\r\n250-8BITMIME\r\n");
31 - out("250-SIZE "); out(size); out("\r\n");
33 - out("250 AUTH LOGIN PLAIN CRAM-MD5\r\n");
34 +#if defined(TLS) && defined(TLS_BEFORE_AUTH)
35 + if(ssl) smtp_authout();
37 - out("250 AUTH LOGIN PLAIN\r\n");
40 + out("250 SIZE "); out(size); out("\r\n");
41 seenmail = 0; dohelo(arg);
43 void smtp_rset(arg) char *arg;
48 +#if defined(TLS) && defined(TLS_BEFORE_AUTH)
49 + if (!ssl) return err_wantstarttls();
52 if (r = b64decode(arg,str_len(arg),&user) == 1) return err_input();
58 +#if defined(TLS) && defined(TLS_BEFORE_AUTH)
59 + if (!ssl) return err_wantstarttls();
62 if (r = b64decode(arg,str_len(arg),&resp) == 1) return err_input();
68 +#if defined(TLS) && defined(TLS_BEFORE_AUTH)
69 + if (!ssl) return err_wantstarttls();
72 s = unique; /* generate challenge */
73 s += fmt_uint(s,getpid());