-void pop3_apop(char *argbuf)
-{
- char username[SIZ];
- char userdigest[MD5_HEXSTRING_SIZE];
- char realdigest[MD5_HEXSTRING_SIZE];
- char *sptr;
-
- if (CC->logged_in)
- {
- cprintf("-ERR You are already logged in; not in the AUTHORIZATION phase.\r\n");
- return;
- }
-
- if ((sptr = strchr(argbuf, ' ')) == NULL)
- {
- cprintf("-ERR Invalid APOP line.\r\n");
- return;
- }
-
- *sptr++ = '\0';
-
- while ((*sptr) && isspace(*sptr))
- sptr++;
-
- strncpy(username, argbuf, sizeof(username)-1);
- username[sizeof(username)-1] = '\0';
-
- memset(userdigest, MD5_HEXSTRING_SIZE, 0);
- strncpy(userdigest, sptr, MD5_HEXSTRING_SIZE-1);
-
- if (CtdlLoginExistingUser(NULL, username) != login_ok)
- {
- cprintf("-ERR No such user.\r\n");
- return;
- }
-
- if (CtdlGetUser(&CC->user, CC->curr_user))
- {
- cprintf("-ERR No such user.\r\n");
- return;
- }
-
- make_apop_string(CC->user.password, CC->cs_nonce, realdigest, sizeof realdigest);
- if (!strncasecmp(realdigest, userdigest, MD5_HEXSTRING_SIZE-1))
- {
- do_login();
- pop3_login();
- }
- else
- {
- cprintf("-ERR That is NOT the password.\r\n");
- }
-}
-