Commit 75526aa3 75526aa318cd6cbf29f49bc657d32ccbc82ce88e by Alain Magloire

There were confusion, about the authority_t and the ticket_t.

	An authority_t is an object that implementes an authentication
	mechanism i.e. APOP, SASL, User/Passwd.  To retrieve or get
	information from the client/user, authority_t will use the
	ticket_t, it will call ticket_pop ().  For example, on an
	authority_t object that implements the user/passwd mechanism
	ticket_pop () will be call two times once for the user and
	the other for the passwd, by the authority_t object.

	So far so good, but the problem here was we had
	mailbox_{g,s}et_ticket(), folder_{g,s}et_ticket() and
	mailbox_{g,s}et_authority() and folder_{g,s}_authority().
	For example for a ticket , depending on when xx_set_ticket ()
	was done, a ticket_t could have been set on the mailbox_t structure
	or on the folder_t structure.  This was leading to use the wrong one,
	folder->ticket or mailbox->ticket.  Same problem occurs for
	authority_t.  To clear this up, ticket_t can only be set on the
	authority_t and autority_t can only be on a folder.  Having only one
	way to get at the authority or at the ticket fix the race conditions:
	{
	   // No error checking is done.
	   mailbox_t mbox;
	   folder_t folder;
	   authority_t auth;
	   ticket_t ticket; ..
	   ..
	   // Setting the ticket
	   mailbox_create (&mbox, where);
	   mailbox_get_folder (mbox, &folder);
	   folder_get_authority (folder, &auth)
	   authority_set_ticket (auth, ticket);
	   ....
	}

	* include/mailutils/mailbox.h: Remove mailbox_{g,s}et_ticket().
	mailbox_{gs}et_authority ().
	* include/mailutils/folder.h: Remove folder_{gs}et_authority().
	* mailbox/mailbox.c (mailbox_get_folder): New function.
	(mailbox_get_ticket): Removed.
	(mailbox_set_ticket): Removed.
	(mailbox_set_authority): Removed.
	(mailbox_get_authority): Removed.
	* mailbox/folder.c (folder_get_ticket): Removed.
	(folder_set_ticket): Removed.
	(folder_destroy): Removed destruction of ticket.
	* mailbox/folder_imap.c (folder_imap_get_authority): New function.
	(_folder_imap_init): Create authority.
	* mailbox/folder_pop.c (folder_pop_get_authority): New function.
	(folder_pop_open): New function.
	(folder_pop_close): New function.
	(_folder_pop_init): Create authority.
	* mailbox/mbx_imap.c (_mailbox_imap_init): Remove the creation
	of authority here, moved to _folder_imap_init().
	* mailbox/mbx_pop.c (_mailbox_pop_init): Remove the creation
	of authority here, moved to _folder_imap_init().
1 parent 92597c73
......@@ -4,7 +4,7 @@
@end example
Internet Message Access Protocol - Version (4rev1). In IMAP the client
Internet Message Access Protocol - Version (4rev1). In IMAP4, the client
must be prepared to accept any responses at all times. The server responses
have three forms: status reponses, server data and command continuation
request. Untaged responses, for hitorical reasons are also call
......
......@@ -60,42 +60,40 @@ struct folder_list
};
/* Constructor/destructor and possible types. */
extern int folder_create __P ((folder_t *, const char *));
extern void folder_destroy __P ((folder_t *));
extern int folder_create __P ((folder_t *, const char *));
extern void folder_destroy __P ((folder_t *));
extern int folder_open __P ((folder_t, int flag));
extern int folder_close __P ((folder_t));
extern int folder_open __P ((folder_t, int flag));
extern int folder_close __P ((folder_t));
extern int folder_delete __P ((folder_t, const char *));
extern int folder_rename __P ((folder_t, const char *, const char *));
extern int folder_subscribe __P ((folder_t, const char *));
extern int folder_unsubscribe __P ((folder_t, const char *));
extern int folder_list __P ((folder_t, const char *, const char *,
extern int folder_delete __P ((folder_t, const char *));
extern int folder_rename __P ((folder_t, const char *, const char *));
extern int folder_subscribe __P ((folder_t, const char *));
extern int folder_unsubscribe __P ((folder_t, const char *));
extern int folder_list __P ((folder_t, const char *, const char *,
struct folder_list *));
extern int folder_lsub __P ((folder_t, const char *, const char *,
extern int folder_lsub __P ((folder_t, const char *, const char *,
struct folder_list *));
extern int folder_list_destroy __P ((struct folder_list *));
extern int folder_list_destroy __P ((struct folder_list *));
/* Stream settings. */
extern int folder_get_stream __P ((folder_t, stream_t *));
extern int folder_set_stream __P ((folder_t, stream_t));
extern int folder_get_stream __P ((folder_t, stream_t *));
extern int folder_set_stream __P ((folder_t, stream_t));
/* Notifications. */
extern int folder_get_observable __P ((folder_t, observable_t *));
extern int folder_get_debug __P ((folder_t, mu_debug_t *));
extern int folder_set_debug __P ((folder_t, mu_debug_t));
extern int folder_get_observable __P ((folder_t, observable_t *));
extern int folder_get_debug __P ((folder_t, mu_debug_t *));
extern int folder_set_debug __P ((folder_t, mu_debug_t));
/* Authentication. */
extern int folder_get_authority __P ((folder_t, authority_t *));
extern int folder_set_authority __P ((folder_t, authority_t));
extern int folder_get_ticket __P ((folder_t, ticket_t *));
extern int folder_set_ticket __P ((folder_t, ticket_t));
extern int folder_get_authority __P ((folder_t, authority_t *));
extern int folder_set_authority __P ((folder_t, authority_t));
/* URL. */
extern int folder_get_url __P ((folder_t, url_t *));
extern int folder_set_url __P ((folder_t, url_t));
extern int folder_get_url __P ((folder_t, url_t *));
extern int folder_set_url __P ((folder_t, url_t));
extern int folder_decremente __P ((folder_t));
extern int folder_decremente __P ((folder_t));
#ifdef __cplusplus
......
......@@ -29,7 +29,6 @@ typedef struct _mailbox *mailbox_t;
#include <mailutils/debug.h>
#include <mailutils/property.h>
#include <mailutils/message.h>
#include <mailutils/auth.h>
#include <mailutils/locker.h>
#include <mailutils/stream.h>
#include <mailutils/folder.h>
......@@ -47,57 +46,52 @@ extern "C" {
#endif /*__P */
/* Constructor/destructor and possible types. */
extern int mailbox_create __P ((mailbox_t *, const char *));
extern void mailbox_destroy __P ((mailbox_t *));
extern int mailbox_create_default __P ((mailbox_t *, const char *));
extern int mailbox_open __P ((mailbox_t, int flag));
extern int mailbox_close __P ((mailbox_t));
extern int mailbox_set_folder __P ((mailbox_t, folder_t));
extern void mailbox_destroy_folder __P ((mailbox_t mbox));
extern int mailbox_uidvalidity __P ((mailbox_t, unsigned long *));
extern int mailbox_uidnext __P ((mailbox_t, size_t *));
extern int mailbox_create __P ((mailbox_t *, const char *));
extern void mailbox_destroy __P ((mailbox_t *));
extern int mailbox_create_default __P ((mailbox_t *, const char *));
extern int mailbox_open __P ((mailbox_t, int flag));
extern int mailbox_close __P ((mailbox_t));
extern int mailbox_get_folder __P ((mailbox_t, folder_t *));
extern int mailbox_set_folder __P ((mailbox_t, folder_t));
extern void mailbox_destroy_folder __P ((mailbox_t mbox));
extern int mailbox_uidvalidity __P ((mailbox_t, unsigned long *));
extern int mailbox_uidnext __P ((mailbox_t, size_t *));
/* Messages. */
extern int mailbox_get_message __P ((mailbox_t, size_t msgno, message_t *));
extern int mailbox_append_message __P ((mailbox_t, message_t));
extern int mailbox_messages_count __P ((mailbox_t, size_t *));
extern int mailbox_messages_recent __P ((mailbox_t, size_t *));
extern int mailbox_message_unseen __P ((mailbox_t, size_t *));
extern int mailbox_expunge __P ((mailbox_t));
extern int mailbox_save_attributes __P ((mailbox_t));
extern int mailbox_get_message __P ((mailbox_t, size_t msgno, message_t *));
extern int mailbox_append_message __P ((mailbox_t, message_t));
extern int mailbox_messages_count __P ((mailbox_t, size_t *));
extern int mailbox_messages_recent __P ((mailbox_t, size_t *));
extern int mailbox_message_unseen __P ((mailbox_t, size_t *));
extern int mailbox_expunge __P ((mailbox_t));
extern int mailbox_save_attributes __P ((mailbox_t));
/* Update and scanning. */
extern int mailbox_get_size __P ((mailbox_t, off_t *size));
extern int mailbox_is_updated __P ((mailbox_t));
extern int mailbox_scan __P ((mailbox_t, size_t no, size_t *count));
extern int mailbox_get_size __P ((mailbox_t, off_t *size));
extern int mailbox_is_updated __P ((mailbox_t));
extern int mailbox_scan __P ((mailbox_t, size_t no, size_t *count));
/* Mailbox Stream. */
extern int mailbox_set_stream __P ((mailbox_t, stream_t));
extern int mailbox_get_stream __P ((mailbox_t, stream_t *));
extern int mailbox_set_stream __P ((mailbox_t, stream_t));
extern int mailbox_get_stream __P ((mailbox_t, stream_t *));
/* Lock settings. */
extern int mailbox_get_locker __P ((mailbox_t, locker_t *));
extern int mailbox_set_locker __P ((mailbox_t, locker_t));
/* Authentication. */
extern int mailbox_get_authority __P ((mailbox_t, authority_t *));
extern int mailbox_set_authority __P ((mailbox_t, authority_t));
extern int mailbox_get_ticket __P ((mailbox_t, ticket_t *));
extern int mailbox_set_ticket __P ((mailbox_t, ticket_t));
extern int mailbox_get_locker __P ((mailbox_t, locker_t *));
extern int mailbox_set_locker __P ((mailbox_t, locker_t));
/* Property. */
extern int mailbox_get_property __P ((mailbox_t, property_t *));
extern int mailbox_get_property __P ((mailbox_t, property_t *));
/* URL. */
extern int mailbox_get_url __P ((mailbox_t, url_t *));
extern int mailbox_get_url __P ((mailbox_t, url_t *));
/* For any debuging */
extern int mailbox_get_debug __P ((mailbox_t, mu_debug_t *));
extern int mailbox_set_debug __P ((mailbox_t, mu_debug_t));
extern int mailbox_get_debug __P ((mailbox_t, mu_debug_t *));
extern int mailbox_set_debug __P ((mailbox_t, mu_debug_t));
/* Events. */
extern int mailbox_get_observable __P ((mailbox_t, observable_t *));
extern int mailbox_get_observable __P ((mailbox_t, observable_t *));
#ifdef __cplusplus
}
......
......@@ -187,8 +187,6 @@ folder_destroy (folder_t *pfolder)
if (folder->_destroy)
folder->_destroy (folder);
monitor_wrlock (monitor);
if (folder->ticket)
ticket_destroy (&(folder->ticket), folder);
if (folder->authority)
authority_destroy (&(folder->authority), folder);
if (folder->stream)
......@@ -263,29 +261,6 @@ folder_get_authority (folder_t folder, authority_t *pauthority)
}
int
folder_set_ticket (folder_t folder, ticket_t ticket)
{
if (folder == NULL)
return EINVAL;
if (folder->ticket)
ticket_destroy (&(folder->ticket), folder);
if (folder->authority)
{
authority_set_ticket (folder->authority, ticket);
}
folder->ticket = ticket;
return 0;
}
int
folder_get_ticket (folder_t folder, ticket_t *pticket)
{
if (folder == NULL || pticket == NULL)
return EINVAL;
*pticket = folder->ticket;
return 0;
}
int
folder_get_observable (folder_t folder, observable_t *pobservable)
{
if (folder == NULL || pobservable == NULL)
......
......@@ -84,6 +84,10 @@ static int folder_imap_rename __P ((folder_t, const char *,
const char *));
static int folder_imap_subscribe __P ((folder_t, const char *));
static int folder_imap_unsubscribe __P ((folder_t, const char *));
static int folder_imap_get_authority __P ((folder_t, authority_t *));
static int authenticate_imap_login __P ((authority_t));
static int authenticate_imap_sasl_anon __P ((authority_t));
/* FETCH */
static int imap_fetch __P ((f_imap_t));
......@@ -114,10 +118,21 @@ static int imap_token __P ((char *, size_t, char **));
int
_folder_imap_init (folder_t folder)
{
int status;
f_imap_t f_imap;
/* Set the authority early:
(1) so we can check for errors.
(2) allow the client to get the authority for setting the ticket
before the open. */
status = folder_imap_get_authority (folder, NULL);
if (status != 0)
return status;
f_imap = folder->data = calloc (1, sizeof (*f_imap));
if (f_imap == NULL)
return ENOMEM;
f_imap->folder = folder;
f_imap->state = IMAP_NO_STATE;
......@@ -152,8 +167,47 @@ folder_imap_destroy (folder_t folder)
}
}
static int
folder_imap_get_authority (folder_t folder, authority_t *pauth)
{
int status = 0;
if (folder->authority == NULL)
{
char *auth;
size_t n = 0;
url_get_auth (folder->url, NULL, 0, &n);
auth = calloc (n + 1, 1);
if (auth == NULL)
return ENOMEM;
url_get_auth (folder->url, auth, n + 1, NULL);
if (strcasecmp (auth, "*") == 0)
{
status = authority_create (&folder->authority, NULL, folder);
if (status == 0)
authority_set_authenticate (folder->authority,
authenticate_imap_login, folder);
}
else if (strcasecmp (auth, "anon") == 0)
{
status = authority_create (&folder->authority, NULL, folder);
if (status == 0)
authority_set_authenticate (folder->authority,
authenticate_imap_sasl_anon, folder);
}
else
{
/* Not a supported authentication mechanism. */
status = ENOSYS;
}
free (auth);
}
if (pauth)
*pauth = folder->authority;
return status;
}
/* Simple User/pass authentication for imap. */
int
static int
authenticate_imap_login (authority_t auth)
{
folder_t folder = authority_get_owner (auth);
......@@ -231,51 +285,49 @@ authenticate_imap_login (authority_t auth)
}
/*
The anonymous SASL mechanism is defined in rfc2245.txt as a single
message from client to server:
message = [email / token]
So the message is optional.
The anonymous SASL mechanism is defined in rfc2245.txt as a single
message from client to server:
The command is:
message = [email / token]
C: <tag> authenticate anonymous
So the message is optional.
The server responds with a request for continuation data (the "message"
in the SASL syntax). We respond with no data, which is legal.
The command is:
S: +
C:
C: <tag> authenticate anonymous
The server should then respond with OK on success, or else a failure
code (NO or BAD).
The server responds with a request for continuation data (the "message"
in the SASL syntax). We respond with no data, which is legal.
If OK, then we are authenticated!
S: +
C:
So, states are:
The server should then respond with OK on success, or else a failure
code (NO or BAD).
AUTH_ANON_REQ
If OK, then we are authenticated!
> g%u AUTHENTICATE ANONYMOUS
So, states are:
AUTH_ANON_WAIT_CONT
AUTH_ANON_REQ
< +
> g%u AUTHENTICATE ANONYMOUS
AUTH_ANON_MSG
AUTH_ANON_WAIT_CONT
>
< +
AUTH_ANON_WAIT_RESP
AUTH_ANON_MSG
< NO/BAD/OK
>
AUTH_ANON_WAIT_RESP
< NO/BAD/OK
*/
int
static int
authenticate_imap_sasl_anon (authority_t auth)
{
folder_t folder = authority_get_owner (auth);
......@@ -290,62 +342,47 @@ authenticate_imap_sasl_anon (authority_t auth)
{
FOLDER_DEBUG1 (folder, MU_DEBUG_PROT, "g%u AUTHENTICATE ANONYMOUS\n",
f_imap->seq);
status = imap_writeline (f_imap, "g%u AUTHENTICATE ANONYMOUS\r\n",
f_imap->seq);
f_imap->seq++;
CHECK_ERROR_CLOSE (folder, f_imap, status);
f_imap->state = IMAP_AUTH_ANON_REQ_SEND;
}
case IMAP_AUTH_ANON_REQ_SEND:
status = imap_send (f_imap);
CHECK_EAGAIN (f_imap, status);
f_imap->state = IMAP_AUTH_ANON_WAIT_CONT;
case IMAP_AUTH_ANON_WAIT_CONT:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
if (strncmp ("+", f_imap->buffer, 2) == 0)
{
f_imap->state = IMAP_AUTH_ANON_MSG;
}
else
{
/* something is wrong! */
/* Something is wrong! */
}
f_imap->state = IMAP_AUTH_ANON_MSG;
case IMAP_AUTH_ANON_MSG:
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, "\n");
status = imap_writeline (f_imap, "\r\n");
CHECK_ERROR_CLOSE (folder, f_imap, status);
f_imap->state = IMAP_AUTH_ANON_MSG_SEND;
case IMAP_AUTH_ANON_MSG_SEND:
status = imap_send (f_imap);
CHECK_EAGAIN (f_imap, status);
f_imap->state = IMAP_AUTH_ANON_WAIT_RESP;
case IMAP_AUTH_ANON_WAIT_RESP:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
default:
......@@ -460,10 +497,10 @@ folder_imap_open (folder_t folder, int flags)
case IMAP_LOGIN:
case IMAP_LOGIN_ACK:
assert (folder->authority);
{
status = authority_authenticate (folder->authority);
CHECK_EAGAIN (f_imap, status);
}
{
status = authority_authenticate (folder->authority);
CHECK_EAGAIN (f_imap, status);
}
case IMAP_AUTH_DONE:
default:
......
......@@ -19,6 +19,8 @@
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <folder0.h>
......@@ -43,9 +45,73 @@ static struct _record _pop_record =
};
record_t pop_record = &_pop_record;
static int folder_pop_open __P ((folder_t, int));
static int folder_pop_close __P ((folder_t));
static int folder_pop_get_authority __P ((folder_t, authority_t *));
extern int _pop_user __P ((authority_t));
int
_folder_pop_init (folder_t folder)
{
(void)folder;
int status;
/* Set the authority early:
(1) so we can check for errors.
(2) allow the client to get the authority for setting the ticket
before the open. */
status = folder_pop_get_authority (folder, NULL);
if (status != 0)
return status;
folder->_open = folder_pop_open;
folder->_close = folder_pop_close;
return 0;
}
static int
folder_pop_open (folder_t folder, int flags)
{
mailbox_t mbox = folder->data;
return mailbox_open (mbox, flags);
}
static int
folder_pop_close (folder_t folder)
{
mailbox_t mbox = folder->data;
return mailbox_close (mbox);
}
static int
folder_pop_get_authority (folder_t folder, authority_t *pauth)
{
int status = 0;
if (folder->authority == NULL)
{
char *auth;
size_t n = 0;
url_get_auth (folder->url, NULL, 0, &n);
auth = calloc (n + 1, 1);
if (auth == NULL)
return ENOMEM;
if (strcasecmp (auth, "*") == 0)
{
status = authority_create (&folder->authority, NULL, folder);
authority_set_authenticate (folder->authority, _pop_user, folder);
}
/*
else...
"+apop" could be supported.
Anything else starting with "+" is an extension mechanism.
Without a "+" it's a SASL mechanism.
*/
else
{
status = ENOSYS;
}
}
if (pauth)
*pauth = folder->authority;
return status;
}
......
......@@ -43,7 +43,6 @@ extern "C" {
struct _folder
{
/* Data */
ticket_t ticket;
authority_t authority;
observable_t observable;
mu_debug_t debug;
......
......@@ -233,9 +233,6 @@ int imap_parse __P ((f_imap_t));
int imap_readline __P ((f_imap_t));
char *section_name __P ((msg_imap_t));
int authenticate_imap_login __P ((authority_t auth));
int authenticate_imap_sasl_anon __P ((authority_t auth));
#ifdef __cplusplus
}
#endif
......
......@@ -45,8 +45,6 @@ struct _mailbox
/* Data */
observable_t observable;
mu_debug_t debug;
ticket_t ticket;
authority_t authority;
property_t property;
locker_t locker;
stream_t stream;
......
......@@ -151,12 +151,6 @@ mailbox_destroy (mailbox_t *pmbox)
stream_destroy (&(mbox->stream), mbox);
}
if (mbox->ticket)
ticket_destroy (&(mbox->ticket), mbox);
if (mbox->authority)
authority_destroy (&(mbox->authority), mbox);
if (mbox->url)
url_destroy (&(mbox->url));
......@@ -316,58 +310,6 @@ mailbox_get_locker (mailbox_t mbox, locker_t *plocker)
}
int
mailbox_set_authority (mailbox_t mbox, authority_t authority)
{
if (mbox == NULL)
return EINVAL;
/* The authority is set on the folder if exist, not the mailbox. */
if (mbox->folder)
return folder_set_authority (mbox->folder, authority);
if (mbox->authority)
authority_destroy (&(mbox->authority), mbox);
mbox->authority = authority;
return 0;
}
int
mailbox_get_authority (mailbox_t mbox, authority_t *pauthority)
{
if (mbox == NULL || pauthority == NULL)
return EINVAL;
/* The authority is set on the folder if exist, not the mailbox. */
if (mbox->folder)
return folder_get_authority (mbox->folder, pauthority);
*pauthority = mbox->authority;
return 0;
}
int
mailbox_set_ticket (mailbox_t mbox, ticket_t ticket)
{
if (mbox == NULL)
return EINVAL;
/* The ticket is set on the folder if exist, not the mailbox. */
if (mbox->folder)
return folder_set_ticket (mbox->folder, ticket);
if (mbox->ticket)
ticket_destroy (&(mbox->ticket), mbox);
mbox->ticket = ticket;
return 0;
}
int
mailbox_get_ticket (mailbox_t mbox, ticket_t *pticket)
{
if (mbox == NULL || pticket == NULL)
return EINVAL;
/* The ticket is set on the folder if exist, not the mailbox. */
if (mbox->folder)
return folder_get_ticket (mbox->folder, pticket);
*pticket = mbox->ticket;
return 0;
}
int
mailbox_set_stream (mailbox_t mbox, stream_t stream)
{
if (mbox == NULL)
......@@ -459,6 +401,24 @@ mailbox_get_url (mailbox_t mbox, url_t *purl)
return 0;
}
int
mailbox_get_folder (mailbox_t mbox, folder_t *pfolder)
{
if (mbox == NULL || pfolder == NULL)
return EINVAL;
*pfolder = mbox->folder;
return 0;
}
int
mailbox_set_folder (mailbox_t mbox, folder_t folder)
{
if (mbox == NULL)
return EINVAL;
mbox->folder = folder;
return 0;
}
void
mailbox_destroy_folder (mailbox_t mbox)
{
......
......@@ -165,32 +165,6 @@ _mailbox_imap_init (mailbox_t mailbox)
property_set_value (property, "TYPE", "IMAP4", 1);
}
assert(folder);
assert(folder->url);
if (folder->authority == NULL)
{
const char *auth = folder->url->auth;
if (auth == NULL || strcasecmp (auth, "*") == 0)
{
authority_create (&(folder->authority), folder->ticket, folder);
authority_set_authenticate (folder->authority,
authenticate_imap_login, folder);
}
else if (strcasecmp (auth, "anon") == 0)
{
authority_create (&(folder->authority), folder->ticket, folder);
authority_set_authenticate (folder->authority,
authenticate_imap_sasl_anon, folder);
}
else
{
/* Not a supported authentication mechanism. */
return ENOSYS;
}
}
return 0;
}
......
......@@ -380,14 +380,6 @@ mbox_open (mailbox_t mailbox, int flags)
MAILBOX_DEBUG2 (mailbox, MU_DEBUG_TRACE, "mbox_open(%s, 0x%x)\n",
mud->name, mailbox->flags);
/* Not of any use to try authenticate for a file mailbox. Do it anyways. */
if (mailbox->authority)
{
status = authority_authenticate (mailbox->authority);
if (status != 0)
return status;
}
/* Give an appropriate way to file lock. */
/* FIXME: use dotlock external program: we may not be setgid. */
if (mailbox->locker == NULL)
......
......@@ -99,7 +99,7 @@ static int pop_scan __P ((mailbox_t, size_t, size_t *));
static int pop_is_updated __P ((mailbox_t));
/* The implementation of message_t */
static int pop_user __P ((authority_t));
int _pop_user __P ((authority_t));
static int pop_get_size __P ((mailbox_t, off_t *));
/* We use pop_top for retreiving headers. */
/* static int pop_header_read (header_t, char *, size_t, off_t, size_t *); */
......@@ -290,41 +290,6 @@ _mailbox_pop_init (mailbox_t mbox)
{
pop_data_t mpd;
int status = 0;
ticket_t ticket = NULL;
char auth[64];
authority_t authority = NULL;
/* Allocate authority based on AUTH type, default to user/pass */
if (mbox->folder)
folder_get_ticket (mbox->folder, &ticket);
if (ticket == NULL)
ticket = mbox->ticket;
if ((status = authority_create (&authority, ticket, mbox->folder)))
return status;
*auth = '\0';
url_get_auth (mbox->url, auth, sizeof auth, NULL);
if (*auth == '\0' || strcasecmp (auth, "*") == 0)
{
authority_set_authenticate (authority, pop_user, mbox->folder);
}
/*
else...
"+apop" could be supported.
Anything else starting with "+" is an extension mechanism.
Without a "+" it's a SASL mechanism.
*/
else
{
authority_destroy (&authority, mbox->folder);
return ENOSYS;
}
folder_set_authority (mbox->folder, authority);
/* Allocate specifics for pop data. */
mpd = mbox->data = calloc (1, sizeof (*mpd));
......@@ -400,8 +365,8 @@ pop_destroy (mailbox_t mbox)
/* Simple User/pass authentication for pop. We ask for the info
from the standard input. */
static int
pop_user (authority_t auth)
int
_pop_user (authority_t auth)
{
folder_t folder = authority_get_owner (auth);
mailbox_t mbox = folder->data;
......