]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtp.c
more places to fix the new linebreak behaviour of the base64 encoder.
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index eddad6be71fb2f5bad8f63ed6c2ab784383bfc39..a93bb438e384231052681d5ac4346aba074e8feb 100644 (file)
@@ -400,7 +400,11 @@ void smtp_get_user(long offset)
 
        /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, ChrPtr(sSMTP->Cmd)) == login_ok) {
-               CtdlEncodeBase64(buf, "Password:", 9, 0);
+               size_t len = CtdlEncodeBase64(buf, "Password:", 9, 0);
+
+               if (buf[len - 1] == '\n') {
+                       buf[len - 1] = '\0';
+               }
                cprintf("334 %s\r\n", buf);
                sSMTP->command_state = smtp_password;
        }
@@ -519,7 +523,10 @@ void smtp_auth(long offset, long Flags)
                        smtp_get_user(6);
                }
                else {
-                       CtdlEncodeBase64(username_prompt, "Username:", 9, 0);
+                       size_t len = CtdlEncodeBase64(username_prompt, "Username:", 9, 0);
+                       if (username_prompt[len - 1] == '\n') {
+                               username_prompt[len - 1] = '\0';
+                       }
                        cprintf("334 %s\r\n", username_prompt);
                        sSMTP->command_state = smtp_user;
                }
@@ -999,6 +1006,7 @@ void smtp_starttls(long offset, long flags)
  */
 void smtp_command_loop(void)
 {
+       static const ConstStr AuthPlainStr = {HKEY("AUTH PLAIN")};
        struct CitContext *CCC = CC;
        citsmtp *sSMTP = SMTP;
        const char *pch, *pchs;
@@ -1019,7 +1027,10 @@ void smtp_command_loop(void)
        syslog(LOG_DEBUG, "SMTP server: %s\n", ChrPtr(sSMTP->Cmd));
 
        if (sSMTP->command_state == smtp_user) {
-               smtp_get_user(0);
+               if (!strncmp(ChrPtr(sSMTP->Cmd), AuthPlainStr.Key, AuthPlainStr.len))
+                       smtp_try_plain(0, 0);
+               else
+                       smtp_get_user(0);
                return;
        }