doveadm.c revision 6d2b3ce2c6ef62334985ece4f0ab8b154e0e9560
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen"usage: doveadm \n"
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen" purge <user>\n"
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen" force-resync <user> <mailbox>\n"
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen for (ns = user->namespaces; ns != NULL; ns = ns->next) {
40eb305d9b12cf48400fe3806a8a15ad6d372952Timo Sirainen if (ns->type != NAMESPACE_PRIVATE || ns->alias_for != NULL)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen i_error("Purging namespace '%s' failed: %s", ns->prefix,
00bde9ae9eab9e720462bf6ec9a4dd85e88c3bbfTimo Sirainen mail_storage_get_last_error(ns->storage, NULL));
6fabfb7bbfd88d0c1de66981e52850f26067623bTimo Sirainenstatic struct mailbox *
22535a9e685e29214082878e37a267157044618eTimo Sirainenmailbox_find_and_open(struct mail_user *user, const char *mailbox)
40eb305d9b12cf48400fe3806a8a15ad6d372952Timo Sirainen ns = mail_namespace_find(user->namespaces, &mailbox);
312d3129573fc63ba0d39105b68daccfab9f0c8fTimo Sirainen i_fatal("Can't find namespace for mailbox %s", mailbox);
312d3129573fc63ba0d39105b68daccfab9f0c8fTimo Sirainen box = mailbox_open(&storage, mailbox, NULL, MAILBOX_OPEN_KEEP_RECENT |
40eb305d9b12cf48400fe3806a8a15ad6d372952Timo Sirainen i_fatal("Opening mailbox %s failed: %s", orig_mailbox,
40eb305d9b12cf48400fe3806a8a15ad6d372952Timo Sirainenstatic void cmd_force_resync(struct mail_user *user, const char *mailbox)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FORCE_RESYNC |
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen MAILBOX_SYNC_FLAG_FIX_INCONSISTENT, 0, NULL) < 0) {
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen i_fatal("Forcing a resync on mailbox %s failed: %s", mailbox,
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen enum mail_storage_service_flags service_flags = 0;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen getopt_str = t_strconcat("u:v", master_service_getopt_string(), NULL);
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen while ((c = getopt(argc, argv, getopt_str)) > 0) {
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen if (!master_service_parse_option(service, c, optarg))
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen i_fatal("USER environment is missing and -u option not used");
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen mail_user = mail_storage_service_init_user(service, user, NULL,
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen i_set_failure_prefix(t_strdup_printf("doveadm(%s): ",
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen else if (strcmp(argv[optind], "force-resync") == 0)