~ubuntu-branches/ubuntu/precise/dovecot/precise-updates

« back to all changes in this revision

Viewing changes to src/doveadm/doveadm-mail.c

  • Committer: Bazaar Package Importer
  • Author(s): James Page
  • Date: 2011-10-19 15:54:40 UTC
  • mfrom: (4.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20111019155440-dp0hs4h1trmm7bbe
Tags: 1:2.0.15-1ubuntu1
* Merge from Debian Testing, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and 
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/{control,rules}: enable PIE hardening.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}. 
      d/mail-stack-deliver.postinst:
      Convert init script to upstart.
* d/01-mail-stack-delivery.conf: Add postfix->dovecot auth listener
  to mail-stack-delivery configuration (LP: #874135).
* d/mail-stack-delivery.{postinst,postrm}: Restart dovecot to pickup/drop
  mail-stack-delivery configuration (LP: #870244).
* d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
  xz compression in Ubuntu.
* d/control: Demote dovecot-common Recommends: to Suggests: to prevent
  install of extra packages on upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
 
194
194
        i_set_failure_prefix(t_strdup_printf("doveadm(%s): ", input->username));
195
195
 
 
196
        /* see if we want to execute this command via (another)
 
197
           doveadm server */
 
198
        ret = doveadm_mail_server_user(ctx, input, error_r);
 
199
        if (ret != 0)
 
200
                return ret;
 
201
 
196
202
        ret = mail_storage_service_lookup(ctx->storage_service, input,
197
203
                                          &service_user, &error);
198
204
        if (ret <= 0) {
203
209
                return ret;
204
210
        }
205
211
 
206
 
        if (doveadm_settings->doveadm_worker_count > 0 && !doveadm_server) {
207
 
                /* execute this command via doveadm server */
208
 
                ret = doveadm_mail_server_user(ctx, service_user, error_r);
209
 
                mail_storage_service_user_free(&service_user);
210
 
                return ret < 0 ? -1 : 1;
211
 
        }
212
 
 
213
212
        ret = mail_storage_service_next(ctx->storage_service, service_user,
214
213
                                        &ctx->cur_mail_user);
215
214
        if (ret < 0) {
224
223
        return 1;
225
224
}
226
225
 
227
 
void doveadm_mail_single_user(struct doveadm_mail_cmd_context *ctx,
228
 
                              char *argv[], const char *username,
 
226
void doveadm_mail_single_user(struct doveadm_mail_cmd_context *ctx, char *argv[],
 
227
                              const struct mail_storage_service_input *input,
229
228
                              enum mail_storage_service_flags service_flags)
230
229
{
231
 
        struct mail_storage_service_input input;
232
230
        const char *error;
233
231
        int ret;
234
232
 
235
 
        if (username == NULL)
236
 
                i_fatal("USER environment is missing and -u option not used");
237
 
 
238
 
        memset(&input, 0, sizeof(input));
239
 
        input.username = username;
 
233
        i_assert(input->username != NULL);
240
234
 
241
235
        ctx->storage_service = mail_storage_service_init(master_service, NULL,
242
236
                                                         service_flags);
244
238
        if (hook_doveadm_mail_init != NULL)
245
239
                hook_doveadm_mail_init(ctx);
246
240
 
247
 
        ret = doveadm_mail_next_user(ctx, &input, &error);
 
241
        ret = doveadm_mail_next_user(ctx, input, &error);
248
242
        if (ret < 0)
249
243
                i_fatal("%s", error);
250
244
        else if (ret == 0)
273
267
 
274
268
        ctx->storage_service = mail_storage_service_init(master_service, NULL,
275
269
                                                         service_flags);
276
 
        lib_signals_set_handler(SIGINT, FALSE, sig_die, NULL);
277
 
        lib_signals_set_handler(SIGTERM, FALSE, sig_die, NULL);
 
270
        lib_signals_set_handler(SIGINT, 0, sig_die, NULL);
 
271
        lib_signals_set_handler(SIGTERM, 0, sig_die, NULL);
278
272
 
279
273
        ctx->v.init(ctx, (const void *)argv);
280
274
        if (hook_doveadm_mail_init != NULL)
340
334
}
341
335
 
342
336
struct doveadm_mail_cmd_context *
343
 
doveadm_mail_cmd_init(const struct doveadm_mail_cmd *cmd)
 
337
doveadm_mail_cmd_init(const struct doveadm_mail_cmd *cmd,
 
338
                      const struct doveadm_settings *set)
344
339
{
345
340
        struct doveadm_mail_cmd_context *ctx;
346
341
 
347
342
        ctx = cmd->alloc();
 
343
        ctx->set = set;
348
344
        ctx->cmd = cmd;
349
345
        if (ctx->v.init == NULL)
350
346
                ctx->v.init = doveadm_mail_cmd_init_noop;
369
365
        if (doveadm_debug)
370
366
                service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
371
367
 
372
 
        ctx = doveadm_mail_cmd_init(cmd);
 
368
        ctx = doveadm_mail_cmd_init(cmd, doveadm_settings);
373
369
 
374
370
        getopt_args = t_strconcat("AS:u:", ctx->getopt_args, NULL);
375
371
        username = getenv("USER");
414
410
        }
415
411
 
416
412
        if (ctx->iterate_single_user) {
417
 
                doveadm_mail_single_user(ctx, argv, username, service_flags);
 
413
                struct mail_storage_service_input input;
 
414
 
 
415
                if (username == NULL)
 
416
                        i_fatal("USER environment is missing and -u option not used");
 
417
 
 
418
                memset(&input, 0, sizeof(input));
 
419
                input.service = "doveadm";
 
420
                input.username = username;
 
421
                doveadm_mail_single_user(ctx, argv, &input, service_flags);
418
422
        } else {
419
423
                service_flags |= MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP;
420
424
                doveadm_mail_all_users(ctx, argv, wildcard_user, service_flags);