Commit cf9c751d cf9c751dd6b97df3ead5e2947465bccb7c8c4521 by Sergey Poznyakoff

All client utilities: read ~/.mu-tickets

* NEWS: Update.
* include/mailutils/mailbox.h (mu_ticket_file): New extern.
* include/mailutils/message.h (mu_message_save_to_mailbox): Change proto.
* include/mailutils/sieve.h (mu_sieve_get_ticket, mu_sieve_set_ticket): Remove.
* libmu_sieve/actions.c (sieve_action_fileinto): Update call to
mu_message_save_to_mailbox.
* libmu_sieve/sieve-priv.h (struct mu_sieve_machine): Remove ticket.
* libmu_sieve/sieve.y (mu_sieve_get_ticket, mu_sieve_set_ticket): Remove.
* mailbox/mbx_default.c (mu_mailbox_create_default): Read a wicket file and
attach a ticket if mailbox opened successfully.
* mailbox/wicket.c: Re-format.
* sieve/sieve.c: Remove special wicket-handling code.

* libmu_auth/radius.c, movemail/movemail.c: Add missing includes
1 parent 234b002d
1 GNU mailutils NEWS -- history of user-visible changes. 2009-02-18 1 GNU mailutils NEWS -- history of user-visible changes. 2009-03-03
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
3 2008 Free Software Foundation, Inc. 3 2008, 2009 Free Software Foundation, Inc.
4 See the end of file for copying conditions. 4 See the end of file for copying conditions.
5 5
6 Please send mailutils bug reports to <bug-mailutils@gnu.org>. 6 Please send mailutils bug reports to <bug-mailutils@gnu.org>.
...@@ -8,6 +8,30 @@ Please send mailutils bug reports to <bug-mailutils@gnu.org>. ...@@ -8,6 +8,30 @@ Please send mailutils bug reports to <bug-mailutils@gnu.org>.
8 8
9 Version 2.0.90 (Git) 9 Version 2.0.90 (Git)
10 10
11 * Ticket files
12
13 All MU client utilities make use of the user ticket file,
14 ~/.mu-tickets, if it is present.
15
16 * API
17
18 ** Removed functions
19
20 - mu_sieve_get_ticket
21 - mu_sieve_set_ticket
22
23 ** Changed functions
24
25 - mu_message_save_to_mailbox: removed `ticket' argument.
26
27 New prototype is:
28
29 int mu_message_save_to_mailbox (mu_message_t msg,
30 mu_debug_t debug,
31 const char *toname,
32 int perms);
33
34
11 35
12 Version 2.0: 36 Version 2.0:
13 37
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
28 extern "C" { 28 extern "C" {
29 #endif 29 #endif
30 30
31 extern char *mu_ticket_file;
32
31 int mu_set_mail_directory (const char *p); 33 int mu_set_mail_directory (const char *p);
32 int mu_set_mailbox_pattern (const char *pat); 34 int mu_set_mailbox_pattern (const char *pat);
33 void mu_set_folder_directory (const char *p); 35 void mu_set_folder_directory (const char *p);
......
...@@ -123,7 +123,7 @@ extern int mu_message_get_attachment_name (mu_message_t, char *name, ...@@ -123,7 +123,7 @@ extern int mu_message_get_attachment_name (mu_message_t, char *name,
123 size_t bufsz, size_t* sz); 123 size_t bufsz, size_t* sz);
124 extern int mu_message_aget_attachment_name (mu_message_t, char **name); 124 extern int mu_message_aget_attachment_name (mu_message_t, char **name);
125 125
126 extern int mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket, 126 extern int mu_message_save_to_mailbox (mu_message_t msg,
127 mu_debug_t debug, const char *toname, 127 mu_debug_t debug, const char *toname,
128 int perms); 128 int perms);
129 129
......
...@@ -217,7 +217,6 @@ void *mu_sieve_get_data (mu_sieve_machine_t mach); ...@@ -217,7 +217,6 @@ void *mu_sieve_get_data (mu_sieve_machine_t mach);
217 mu_message_t mu_sieve_get_message (mu_sieve_machine_t mach); 217 mu_message_t mu_sieve_get_message (mu_sieve_machine_t mach);
218 size_t mu_sieve_get_message_num (mu_sieve_machine_t mach); 218 size_t mu_sieve_get_message_num (mu_sieve_machine_t mach);
219 int mu_sieve_get_debug_level (mu_sieve_machine_t mach); 219 int mu_sieve_get_debug_level (mu_sieve_machine_t mach);
220 mu_ticket_t mu_sieve_get_ticket (mu_sieve_machine_t mach);
221 mu_mailer_t mu_sieve_get_mailer (mu_sieve_machine_t mach); 220 mu_mailer_t mu_sieve_get_mailer (mu_sieve_machine_t mach);
222 int mu_sieve_get_locus (mu_sieve_machine_t mach, mu_sieve_locus_t *); 221 int mu_sieve_get_locus (mu_sieve_machine_t mach, mu_sieve_locus_t *);
223 char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach); 222 char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach);
...@@ -232,7 +231,6 @@ void mu_sieve_set_debug_object (mu_sieve_machine_t mach, mu_debug_t dbg); ...@@ -232,7 +231,6 @@ void mu_sieve_set_debug_object (mu_sieve_machine_t mach, mu_debug_t dbg);
232 void mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level); 231 void mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level);
233 void mu_sieve_set_logger (mu_sieve_machine_t mach, 232 void mu_sieve_set_logger (mu_sieve_machine_t mach,
234 mu_sieve_action_log_t logger); 233 mu_sieve_action_log_t logger);
235 void mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket);
236 void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer); 234 void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer);
237 void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email); 235 void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email);
238 236
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
42 #include <mailutils/errno.h> 42 #include <mailutils/errno.h>
43 #include <mailutils/nls.h> 43 #include <mailutils/nls.h>
44 #include <mailutils/vartab.h> 44 #include <mailutils/vartab.h>
45 #include <mailutils/io.h>
45 46
46 #ifdef ENABLE_RADIUS 47 #ifdef ENABLE_RADIUS
47 48
......
...@@ -105,7 +105,7 @@ sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -105,7 +105,7 @@ sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
105 if (mu_sieve_is_dry_run (mach)) 105 if (mu_sieve_is_dry_run (mach))
106 return 0; 106 return 0;
107 107
108 rc = mu_message_save_to_mailbox (mach->msg, mach->ticket, mach->debug, 108 rc = mu_message_save_to_mailbox (mach->msg, mach->debug,
109 val->v.string, mbflags); 109 val->v.string, mbflags);
110 if (rc) 110 if (rc)
111 mu_sieve_error (mach, _("cannot save to mailbox: %s"), 111 mu_sieve_error (mach, _("cannot save to mailbox: %s"),
......
...@@ -74,7 +74,6 @@ struct mu_sieve_machine { ...@@ -74,7 +74,6 @@ struct mu_sieve_machine {
74 mu_sieve_action_log_t logger; 74 mu_sieve_action_log_t logger;
75 75
76 mu_mailer_t mailer; 76 mu_mailer_t mailer;
77 mu_ticket_t ticket;
78 mu_debug_t debug; 77 mu_debug_t debug;
79 char *daemon_email; 78 char *daemon_email;
80 void *data; 79 void *data;
......
...@@ -477,18 +477,6 @@ mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger) ...@@ -477,18 +477,6 @@ mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger)
477 mach->logger = logger; 477 mach->logger = logger;
478 } 478 }
479 479
480 void
481 mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket)
482 {
483 mach->ticket = ticket;
484 }
485
486 mu_ticket_t
487 mu_sieve_get_ticket (mu_sieve_machine_t mach)
488 {
489 return mach->ticket;
490 }
491
492 mu_mailer_t 480 mu_mailer_t
493 mu_sieve_get_mailer (mu_sieve_machine_t mach) 481 mu_sieve_get_mailer (mu_sieve_machine_t mach)
494 { 482 {
......
...@@ -34,10 +34,17 @@ ...@@ -34,10 +34,17 @@
34 34
35 #include <mailutils/mailbox.h> 35 #include <mailutils/mailbox.h>
36 #include <mailutils/mutil.h> 36 #include <mailutils/mutil.h>
37 #include <mailutils/debug.h>
37 #include <mailutils/error.h> 38 #include <mailutils/error.h>
38 #include <mailutils/errno.h> 39 #include <mailutils/errno.h>
39 #include <mailutils/mu_auth.h> 40 #include <mailutils/mu_auth.h>
40 #include <mailutils/vartab.h> 41 #include <mailutils/vartab.h>
42 #include <mailutils/folder.h>
43 #include <mailutils/auth.h>
44
45 #include <mailbox0.h>
46
47 char *mu_ticket_file = "~/.mu-tickets";
41 48
42 static char *_mu_mailbox_pattern; 49 static char *_mu_mailbox_pattern;
43 50
...@@ -328,6 +335,44 @@ percent_expand (const char *file, char **mbox) ...@@ -328,6 +335,44 @@ percent_expand (const char *file, char **mbox)
328 return status; 335 return status;
329 } 336 }
330 337
338 static void
339 attach_auth_ticket (mu_mailbox_t mbox)
340 {
341 mu_folder_t folder = NULL;
342 mu_authority_t auth = NULL;
343
344 if (mu_mailbox_get_folder (mbox, &folder) == 0
345 && mu_folder_get_authority (folder, &auth) == 0)
346 {
347 char *filename = mu_tilde_expansion (mu_ticket_file, "/", NULL);
348 mu_wicket_t wicket;
349 int rc;
350
351 MU_DEBUG1 (mbox->debug, MU_DEBUG_TRACE1,
352 "Reading user ticket file %s\n", filename);
353 if ((rc = mu_wicket_create (&wicket, filename)) == 0)
354 {
355 mu_ticket_t ticket;
356
357 if ((rc = mu_wicket_get_ticket (wicket, &ticket, 0, 0)) == 0)
358 {
359 rc = mu_authority_set_ticket (auth, ticket);
360 MU_DEBUG1 (mbox->debug, MU_DEBUG_TRACE1,
361 "Retrieved and set ticket: %d\n", rc);
362 }
363 else
364 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
365 "Error retrieving ticket: %s\n",
366 mu_strerror (rc));
367 mu_wicket_destroy (&wicket);
368 }
369 else
370 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
371 "Error creating wicket: %s\n", mu_strerror (rc));
372 free (filename);
373 }
374 }
375
331 /* We are trying to be smart about the location of the mail. 376 /* We are trying to be smart about the location of the mail.
332 mu_mailbox_create() is not doing this. 377 mu_mailbox_create() is not doing this.
333 % --> system mailbox for the real uid 378 % --> system mailbox for the real uid
...@@ -415,5 +460,8 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) ...@@ -415,5 +460,8 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
415 460
416 status = mu_mailbox_create (pmbox, mbox); 461 status = mu_mailbox_create (pmbox, mbox);
417 free (mbox); 462 free (mbox);
463 if (status == 0)
464 attach_auth_ticket (*pmbox);
465
418 return status; 466 return status;
419 } 467 }
......
...@@ -1110,7 +1110,7 @@ message_body_read (mu_stream_t stream, char *buffer, size_t n, mu_off_t off, ...@@ -1110,7 +1110,7 @@ message_body_read (mu_stream_t stream, char *buffer, size_t n, mu_off_t off,
1110 } 1110 }
1111 1111
1112 int 1112 int
1113 mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket, 1113 mu_message_save_to_mailbox (mu_message_t msg,
1114 mu_debug_t debug, 1114 mu_debug_t debug,
1115 const char *toname, int perms) 1115 const char *toname, int perms)
1116 { 1116 {
...@@ -1128,26 +1128,6 @@ mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket, ...@@ -1128,26 +1128,6 @@ mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket,
1128 if (debug && (rc = mu_mailbox_set_debug (to, debug))) 1128 if (debug && (rc = mu_mailbox_set_debug (to, debug)))
1129 goto end; 1129 goto end;
1130 1130
1131 if (ticket)
1132 {
1133 mu_folder_t folder = NULL;
1134
1135 if ((rc = mu_mailbox_get_folder (to, &folder)))
1136 goto end;
1137
1138 /* FIXME: not all mailboxes have folders, thus this hack. */
1139 if (folder)
1140 {
1141 mu_authority_t auth = NULL;
1142 if ((rc = mu_folder_get_authority (folder, &auth)))
1143 goto end;
1144
1145 /* FIXME: not all folders have authentication, thus this hack. */
1146 if (auth && (rc = mu_authority_set_ticket (auth, ticket)))
1147 goto end;
1148 }
1149 }
1150
1151 if ((rc = mu_mailbox_open (to, 1131 if ((rc = mu_mailbox_open (to,
1152 MU_STREAM_WRITE | MU_STREAM_CREAT 1132 MU_STREAM_WRITE | MU_STREAM_CREAT
1153 | (perms & MU_STREAM_IMASK)))) 1133 | (perms & MU_STREAM_IMASK))))
......
...@@ -91,11 +91,11 @@ mu_wicket_destroy (mu_wicket_t *pwicket) ...@@ -91,11 +91,11 @@ mu_wicket_destroy (mu_wicket_t *pwicket)
91 91
92 int 92 int
93 mu_wicket_get_filename (mu_wicket_t wicket, char *filename, size_t len, 93 mu_wicket_get_filename (mu_wicket_t wicket, char *filename, size_t len,
94 size_t *pwriten) 94 size_t *pwriten)
95 { 95 {
96 size_t n; 96 size_t n;
97 if (wicket == NULL) 97 if (wicket == NULL)
98 return EINVAL; 98 return EINVAL;
99 n = mu_cpystr (filename, wicket->filename, len); 99 n = mu_cpystr (filename, wicket->filename, len);
100 if (pwriten) 100 if (pwriten)
101 *pwriten = n; 101 *pwriten = n;
...@@ -107,10 +107,10 @@ mu_wicket_set_filename (mu_wicket_t wicket, const char *filename) ...@@ -107,10 +107,10 @@ mu_wicket_set_filename (mu_wicket_t wicket, const char *filename)
107 { 107 {
108 if (wicket == NULL) 108 if (wicket == NULL)
109 return EINVAL; 109 return EINVAL;
110 110
111 if (wicket->filename) 111 if (wicket->filename)
112 free (wicket->filename); 112 free (wicket->filename);
113 113
114 wicket->filename = (filename) ? strdup (filename) : NULL; 114 wicket->filename = (filename) ? strdup (filename) : NULL;
115 return 0; 115 return 0;
116 } 116 }
...@@ -127,8 +127,9 @@ mu_wicket_set_ticket (mu_wicket_t wicket, int (*get_ticket) ...@@ -127,8 +127,9 @@ mu_wicket_set_ticket (mu_wicket_t wicket, int (*get_ticket)
127 } 127 }
128 128
129 int 129 int
130 mu_wicket_get_ticket (mu_wicket_t wicket, mu_ticket_t *pticket, const char *user, 130 mu_wicket_get_ticket (mu_wicket_t wicket, mu_ticket_t *pticket,
131 const char *type) 131 const char *user,
132 const char *type)
132 { 133 {
133 if (wicket == NULL || pticket == NULL) 134 if (wicket == NULL || pticket == NULL)
134 return EINVAL; 135 return EINVAL;
...@@ -142,7 +143,8 @@ mu_wicket_get_ticket (mu_wicket_t wicket, mu_ticket_t *pticket, const char *user ...@@ -142,7 +143,8 @@ mu_wicket_get_ticket (mu_wicket_t wicket, mu_ticket_t *pticket, const char *user
142 } 143 }
143 144
144 static int 145 static int
145 myticket_create (mu_ticket_t *pticket, const char *user, const char *pass, const char *filename) 146 myticket_create (mu_ticket_t *pticket, const char *user,
147 const char *pass, const char *filename)
146 { 148 {
147 struct myticket_data *mdata; 149 struct myticket_data *mdata;
148 int status = mu_ticket_create (pticket, NULL); 150 int status = mu_ticket_create (pticket, NULL);
...@@ -197,42 +199,35 @@ myticket_create (mu_ticket_t *pticket, const char *user, const char *pass, const ...@@ -197,42 +199,35 @@ myticket_create (mu_ticket_t *pticket, const char *user, const char *pass, const
197 } 199 }
198 200
199 static int 201 static int
200 myticket_pop (mu_ticket_t ticket, mu_url_t url, const char *challenge, char **parg) 202 myticket_pop (mu_ticket_t ticket, mu_url_t url,
203 const char *challenge, char **parg)
201 { 204 {
202 struct myticket_data *mdata = NULL; 205 struct myticket_data *mdata = NULL;
203 int e = 0; 206 int e = 0;
204 207
205 mu_ticket_get_data (ticket, (void **)&mdata); 208 mu_ticket_get_data (ticket, (void **)&mdata);
206 if (challenge && 209 if (challenge && (strstr (challenge, "ass") != NULL ||
207 ( 210 strstr (challenge, "ASS") != NULL))
208 strstr (challenge, "ass") != NULL ||
209 strstr (challenge, "ASS") != NULL
210 )
211 )
212 {
213 if(mdata->pass)
214 { 211 {
215 *parg = strdup(mdata->pass); 212 if (mdata->pass)
216 if(!*parg) 213 {
217 e = ENOMEM; 214 *parg = strdup (mdata->pass);
218 } 215 if (!*parg)
219 else 216 e = ENOMEM;
220 { 217 }
221 e = get_pass (url, mdata->user, mdata->filename, parg); 218 else
219 e = get_pass (url, mdata->user, mdata->filename, parg);
222 } 220 }
223 }
224 else 221 else
225 {
226 if(mdata->user)
227 {
228 *parg = strdup(mdata->user);
229 if(!*parg)
230 e = ENOMEM;
231 }
232 else
233 { 222 {
234 e = get_user (url, mdata->filename, parg); 223 if (mdata->user)
235 } 224 {
225 *parg = strdup(mdata->user);
226 if (!*parg)
227 e = ENOMEM;
228 }
229 else
230 e = get_user (url, mdata->filename, parg);
236 } 231 }
237 return e; 232 return e;
238 } 233 }
...@@ -255,7 +250,8 @@ myticket_destroy (mu_ticket_t ticket) ...@@ -255,7 +250,8 @@ myticket_destroy (mu_ticket_t ticket)
255 } 250 }
256 251
257 static int 252 static int
258 get_ticket (mu_url_t url, const char *user, const char *filename, mu_url_t * ticket) 253 get_ticket (mu_url_t url, const char *user, const char *filename,
254 mu_url_t * ticket)
259 { 255 {
260 int err = 0; 256 int err = 0;
261 FILE *fp = NULL; 257 FILE *fp = NULL;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
29 #include <mailutils/tls.h> 29 #include <mailutils/tls.h>
30 #include <mu_asprintf.h> 30 #include <mu_asprintf.h>
31 #include "mailutils/libargp.h" 31 #include "mailutils/libargp.h"
32 #include <lib/muaux.h>
32 33
33 const char *program_version = "movemail (" PACKAGE_STRING ")"; 34 const char *program_version = "movemail (" PACKAGE_STRING ")";
34 static char doc[] = N_("GNU movemail"); 35 static char doc[] = N_("GNU movemail");
......
...@@ -106,8 +106,6 @@ static struct argp_option options[] = ...@@ -106,8 +106,6 @@ static struct argp_option options[] =
106 int keep_going; 106 int keep_going;
107 int compile_only; 107 int compile_only;
108 char *mbox_url; 108 char *mbox_url;
109 char *tickets;
110 int tickets_default;
111 int debug_level; 109 int debug_level;
112 int sieve_debug; 110 int sieve_debug;
113 int verbose; 111 int verbose;
...@@ -282,24 +280,13 @@ cb_email (mu_debug_t debug, void *data, mu_config_value_t *val) ...@@ -282,24 +280,13 @@ cb_email (mu_debug_t debug, void *data, mu_config_value_t *val)
282 return rc; 280 return rc;
283 } 281 }
284 282
285 static int
286 cb_ticket (mu_debug_t debug, void *data, mu_config_value_t *val)
287 {
288 if (mu_cfg_assert_value_type (val, MU_CFG_STRING, debug))
289 return 1;
290 free (tickets);
291 tickets = mu_tilde_expansion (val->v.string, "/", NULL);
292 tickets_default = 0;
293 return 0;
294 }
295
296 static struct mu_cfg_param sieve_cfg_param[] = { 283 static struct mu_cfg_param sieve_cfg_param[] = {
297 { "keep-going", mu_cfg_bool, &keep_going, 0, NULL, 284 { "keep-going", mu_cfg_bool, &keep_going, 0, NULL,
298 N_("Do not abort if execution fails on a message.") }, 285 N_("Do not abort if execution fails on a message.") },
299 { "mbox-url", mu_cfg_string, &mbox_url, 0, NULL, 286 { "mbox-url", mu_cfg_string, &mbox_url, 0, NULL,
300 N_("Mailbox to sieve (defaults to user's mail spool)."), 287 N_("Mailbox to sieve (defaults to user's mail spool)."),
301 N_("url") }, 288 N_("url") },
302 { "ticket", mu_cfg_callback, NULL, 0, cb_ticket, 289 { "ticket", mu_cfg_string, &mu_ticket_file, 0, NULL,
303 N_("Ticket file for user authentication."), 290 N_("Ticket file for user authentication."),
304 N_("ticket") }, 291 N_("ticket") },
305 { "debug", mu_cfg_callback, NULL, 0, cb_debug, 292 { "debug", mu_cfg_callback, NULL, 0, cb_debug,
...@@ -405,12 +392,12 @@ sieve_message (mu_sieve_machine_t mach) ...@@ -405,12 +392,12 @@ sieve_message (mu_sieve_machine_t mach)
405 } 392 }
406 393
407 static int 394 static int
408 sieve_mailbox (mu_sieve_machine_t mach, mu_ticket_t ticket, mu_debug_t debug) 395 sieve_mailbox (mu_sieve_machine_t mach, mu_debug_t debug)
409 { 396 {
410 int rc; 397 int rc;
411 mu_mailbox_t mbox = NULL; 398 mu_mailbox_t mbox = NULL;
412 399
413 /* Create, give a ticket to, and open the mailbox. */ 400 /* Create and open the mailbox. */
414 if ((rc = mu_mailbox_create_default (&mbox, mbox_url)) != 0) 401 if ((rc = mu_mailbox_create_default (&mbox, mbox_url)) != 0)
415 { 402 {
416 if (mbox) 403 if (mbox)
...@@ -428,34 +415,6 @@ sieve_mailbox (mu_sieve_machine_t mach, mu_ticket_t ticket, mu_debug_t debug) ...@@ -428,34 +415,6 @@ sieve_mailbox (mu_sieve_machine_t mach, mu_ticket_t ticket, mu_debug_t debug)
428 goto cleanup; 415 goto cleanup;
429 } 416 }
430 417
431 if (ticket)
432 {
433 mu_folder_t folder = NULL;
434 mu_authority_t auth = NULL;
435
436 if ((rc = mu_mailbox_get_folder (mbox, &folder)))
437 {
438 mu_error (_("mu_mailbox_get_folder failed: %s"),
439 mu_strerror (rc));
440 goto cleanup;
441 }
442
443 if ((rc = mu_folder_get_authority (folder, &auth)))
444 {
445 mu_error (_("mu_folder_get_authority failed: %s"),
446 mu_strerror (rc));
447 goto cleanup;
448 }
449
450 /* Authentication-less folders don't have authorities. */
451 if (auth && (rc = mu_authority_set_ticket (auth, ticket)))
452 {
453 mu_error (_("mu_authority_set_ticket failed: %s"),
454 mu_strerror (rc));
455 goto cleanup;
456 }
457 }
458
459 /* Open the mailbox read-only if we aren't going to modify it. */ 418 /* Open the mailbox read-only if we aren't going to modify it. */
460 if (sieve_debug & MU_SIEVE_DRY_RUN) 419 if (sieve_debug & MU_SIEVE_DRY_RUN)
461 rc = mu_mailbox_open (mbox, MU_STREAM_READ); 420 rc = mu_mailbox_open (mbox, MU_STREAM_READ);
...@@ -516,8 +475,6 @@ int ...@@ -516,8 +475,6 @@ int
516 main (int argc, char *argv[]) 475 main (int argc, char *argv[])
517 { 476 {
518 mu_sieve_machine_t mach; 477 mu_sieve_machine_t mach;
519 mu_wicket_t wicket = 0;
520 mu_ticket_t ticket = 0;
521 mu_debug_t debug = 0; 478 mu_debug_t debug = 0;
522 int rc; 479 int rc;
523 480
...@@ -532,8 +489,6 @@ main (int argc, char *argv[]) ...@@ -532,8 +489,6 @@ main (int argc, char *argv[])
532 489
533 mu_register_all_formats (); 490 mu_register_all_formats ();
534 491
535 tickets = mu_tilde_expansion ("~/.tickets", "/", NULL);
536 tickets_default = 1;
537 debug_level = MU_DEBUG_LEVEL_MASK (MU_DEBUG_ERROR); 492 debug_level = MU_DEBUG_LEVEL_MASK (MU_DEBUG_ERROR);
538 mu_log_facility = 0; 493 mu_log_facility = 0;
539 494
...@@ -574,27 +529,6 @@ main (int argc, char *argv[]) ...@@ -574,27 +529,6 @@ main (int argc, char *argv[])
574 return EX_OK; 529 return EX_OK;
575 } 530 }
576 531
577 /* Create a ticket, if we can. */
578 if (tickets)
579 {
580 if ((rc = mu_wicket_create (&wicket, tickets)) == 0)
581 {
582 if ((rc = mu_wicket_get_ticket (wicket, &ticket, 0, 0)) != 0)
583 {
584 mu_error (_("ticket_get failed: %s"), mu_strerror (rc));
585 return EX_SOFTWARE; /* FIXME: really? */
586 }
587 }
588 else if (!(tickets_default && errno == ENOENT))
589 {
590 mu_error (_("mu_wicket_create `%s' failed: %s"),
591 tickets, mu_strerror (rc));
592 return EX_SOFTWARE;
593 }
594 if (ticket)
595 mu_sieve_set_ticket (mach, ticket);
596 }
597
598 /* Create a debug object, if needed. */ 532 /* Create a debug object, if needed. */
599 if (debug_level) 533 if (debug_level)
600 { 534 {
...@@ -617,7 +551,7 @@ main (int argc, char *argv[]) ...@@ -617,7 +551,7 @@ main (int argc, char *argv[])
617 if (mbox_url && strcmp (mbox_url, "-") == 0) 551 if (mbox_url && strcmp (mbox_url, "-") == 0)
618 rc = sieve_message (mach); 552 rc = sieve_message (mach);
619 else 553 else
620 rc = sieve_mailbox (mach, ticket, debug); 554 rc = sieve_mailbox (mach, debug);
621 mu_debug_destroy (&debug, mach); 555 mu_debug_destroy (&debug, mach);
622 556
623 return rc; 557 return rc;
......