+void imap_auth_plain(char *cmd)
+{
+ char decoded_authstring[1024];
+ char ident[256];
+ char user[256];
+ char pass[256];
+
+ CtdlDecodeBase64(decoded_authstring, cmd, strlen(cmd));
+ safestrncpy(ident, decoded_authstring, sizeof ident);
+ safestrncpy(user, &decoded_authstring[strlen(ident) + 1], sizeof user);
+ safestrncpy(pass, &decoded_authstring[strlen(ident) + strlen(user) + 2], sizeof pass);
+
+ IMAP->authstate = imap_as_normal;
+ if (CtdlLoginExistingUser(user) == login_ok) {
+ if (CtdlTryPassword(pass) == pass_ok) {
+ cprintf("%s OK authentication succeeded\r\n", IMAP->authseq);
+ return;
+ }
+ }
+ cprintf("%s NO authentication failed\r\n", IMAP->authseq);
+}
+