Index: mailbox/wicket.c =================================================================== RCS file: /cvsroot/mailutils/mailutils/mailbox/wicket.c,v retrieving revision 1.2 diff -u -r1.2 wicket.c --- mailbox/wicket.c 2001/11/15 02:17:29 1.2 +++ mailbox/wicket.c 2001/11/15 05:36:47 @@ -28,6 +28,7 @@ #include #include +#include struct myticket_data { @@ -40,10 +41,13 @@ static void myticket_destroy __P ((ticket_t)); static int _get_ticket __P ((ticket_t *, const char *, const char *)); static int myticket_pop __P ((ticket_t, const char *, char **)); +static int _wicket_pop __P ((ticket_t, const char *, char **)); int wicket_create (wicket_t *pwicket, const char *filename) { + ticket_t ticket; + if (pwicket == NULL) return EINVAL; @@ -51,13 +55,29 @@ if (*pwicket == NULL) return ENOMEM; + ticket = &(*pwicket)->ticket; + if (filename) (*pwicket)->filename = strdup (filename); + + ticket_set_pop (ticket, _wicket_pop, NULL); + ticket_set_data (ticket, *pwicket, NULL); + return 0; } +int +wicket_to_ticket (wicket_t wicket, ticket_t * pticket) +{ + if (wicket == NULL || pticket == NULL) + return EINVAL; + + *pticket = &wicket->ticket; + + return 0; +} int -wicket_destroy (wicket_t *pwicket) +wicket_destroy (wicket_t * pwicket) { if (pwicket && *pwicket) { @@ -67,6 +87,7 @@ free (wicket); *pwicket = NULL; } + return 0; } int @@ -230,6 +251,31 @@ else *parg = strdup (mdata->user); return 0; +} + +static int +_wicket_pop (ticket_t ticket, const char *challenge, char **parg) +{ + wicket_t wicket = NULL; + ticket_t t = NULL; + int status = 0; + + if ((status = ticket_get_data (ticket, (void **) &wicket)) != 0) + return status; + + status = _get_ticket (&t, wicket->filename, NULL + /* PROBLEM! Who do we want a ticket for? + Can we crawl back to find the user? + */ + ); + + if (status == 0) + status = myticket_pop (t, challenge, parg); + + if (t) + ticket_destroy (&t, NULL); + + return status; } static void Index: mailbox/include/auth0.h =================================================================== RCS file: /cvsroot/mailutils/mailutils/mailbox/include/auth0.h,v retrieving revision 1.6 diff -u -r1.6 auth0.h --- mailbox/include/auth0.h 2001/11/14 17:55:05 1.6 +++ mailbox/include/auth0.h 2001/11/15 05:36:47 @@ -55,6 +55,8 @@ struct _wicket { + struct _ticket ticket; + char *filename; int (*_get_ticket) __P ((wicket_t, const char *, const char *, ticket_t *)); }; Index: include/mailutils/auth.h =================================================================== RCS file: /cvsroot/mailutils/mailutils/include/mailutils/auth.h,v retrieving revision 1.5 diff -u -r1.5 auth.h --- include/mailutils/auth.h 2001/11/14 17:55:05 1.5 +++ include/mailutils/auth.h 2001/11/15 05:36:47 @@ -70,6 +70,8 @@ const char *, ticket_t *)))); extern int wicket_get_ticket __P ((wicket_t, ticket_t *, const char *, const char *)); +extern int wicket_to_ticket __P ((wicket_t, ticket_t *)); + #ifdef __cplusplus } #endif Index: sieve/sieve.c =================================================================== RCS file: /cvsroot/mailutils/mailutils/sieve/sieve.c,v retrieving revision 1.5 diff -u -r1.5 sieve.c --- sieve/sieve.c 2001/08/03 02:45:03 1.5 +++ sieve/sieve.c 2001/11/15 05:36:48 @@ -69,11 +69,30 @@ mailbox_t to = 0; mailbox_t from = 0; + wicket_t wicket = NULL; + res = mailbox_create_default (&to, toname); if (res == ENOENT) *errmsg = "no handler for this type of mailbox"; + /* if we can't create it, we'll just do without */ + wicket_create (&wicket, "~/.tickets"); + + if (wicket) + { + ticket_t ticket = NULL; + folder_t folder = NULL; + authority_t auth = NULL; + + wicket_to_ticket (wicket, &ticket); + + /* if we get a wicket, this must succeed */ + if ((res = mailbox_get_folder (to, &folder)) == 0) + if ((res = folder_get_authority (folder, &auth)) == 0) + res = authority_set_ticket (auth, ticket); + + } if (!res) { if (message_get_mailbox (mesg, &from) == 0) @@ -101,6 +120,8 @@ } mailbox_destroy (&to); + wicket_destroy (&wicket); + return res; } @@ -135,7 +156,7 @@ /** sieve context structures -The object relationship diagram is this, with the names in [] +The object relationship diagram is this, with the names in "" being the argument name when the context's are provided as arguments to callback functions.