]> code.citadel.org Git - citadel.git/commitdiff
* Support for PLAIN logins in IMAP (need to test!)
authorArt Cancro <ajc@citadel.org>
Thu, 12 Feb 2004 04:16:39 +0000 (04:16 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 12 Feb 2004 04:16:39 +0000 (04:16 +0000)
citadel/ChangeLog
citadel/serv_imap.c

index 3a001a0ce75334a242f9cf0411c4a7f1a32c4d1e..ed5849f1688bdf58f1a7217a46f1c240e4d4f32e 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.27  2004/02/12 04:16:38  ajc
+ * Support for PLAIN logins in IMAP (need to test!)
+
  Revision 614.26  2004/02/11 03:50:49  ajc
  * The groupware folders "Calendar", "Contacts", "Notes", and "Tasks" are
    now presented as subfolders of INBOX when using IMAP.  This is for the
@@ -5313,4 +5316,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index b2cfbba85bb92fe89a81f3925e9e4b4844c5a15e..62fe9a2ea1a74e1305cae79b99ce4f121b1424ee 100644 (file)
@@ -337,13 +337,16 @@ void imap_login(int num_parms, char *parms[]) {
  */
 void imap_authenticate(int num_parms, char *parms[]) {
        char buf[SIZ];
-
-       if (num_parms != 3) {
-               cprintf("%s BAD incorrect number of parameters\r\n", parms[0]);
-               return;
-       }
+       char plain_authident[SIZ];
+       char plain_username[SIZ];
+       char plain_password[SIZ];
 
        if (!strcasecmp(parms[2], "LOGIN")) {
+               if (num_parms != 3) {
+                       cprintf("%s BAD incorrect number of parameters\r\n",
+                               parms[0]);
+                       return;
+               }
                CtdlEncodeBase64(buf, "Username:", 9);
                cprintf("+ %s\r\n", buf);
                IMAP->authstate = imap_as_expecting_username;
@@ -351,6 +354,29 @@ void imap_authenticate(int num_parms, char *parms[]) {
                return;
        }
 
+       else if (!strcasecmp(parms[2], "PLAIN")) {
+               if (num_parms != 4) {
+                       cprintf("%s BAD incorrect number of parameters\r\n",
+                               parms[0]);
+                       return;
+               }
+               if (CC->logged_in) {
+                       cprintf("%s BAD Already logged in.\r\n", parms[0]);
+                       return;
+               }
+               strcpy(plain_authident, parms[3]);
+               strcpy(plain_username, &parms[3][strlen(plain_authident)+2]);
+               strcpy(plain_password, &parms[3][strlen(plain_authident)+strlen(plain_username)+3]);
+               if (CtdlLoginExistingUser(plain_username) == login_ok) {
+                       if (CtdlTryPassword(plain_password) == pass_ok) {
+                               cprintf("%s OK login successful\r\n", parms[0]);
+                               return;
+                       }
+               }
+               cprintf("%s BAD i=%s u=%s p=%s FIXME\r\n", parms[0],
+                       plain_authident, plain_username, plain_password);
+       }
+
        else {
                cprintf("%s NO AUTHENTICATE %s failed\r\n",
                        parms[0], parms[1]);
@@ -388,7 +414,7 @@ void imap_auth_login_pass(char *cmd) {
  * implements the CAPABILITY command
  */
 void imap_capability(int num_parms, char *parms[]) {
-       cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN");
+       cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=PLAIN AUTH=LOGIN");
 
 #ifdef HAVE_OPENSSL_XXX /* temporarily disabled due to bugs */
        cprintf(" STARTTLS");