~james-page/ubuntu/raring/dovecot/autopkgtest

« back to all changes in this revision

Viewing changes to pigeonhole/src/plugins/lda-sieve/lda-sieve-plugin.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 11:11:54 UTC
  • mfrom: (1.15.2) (4.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120611111154-678cwbdj6ktgsv1h
Tags: 1:2.1.7-1ubuntu1
* Merge from Debian unstable, 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/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.
  + d/patches/dovecot-drac.patch: Updated with version for dovecot >= 2.0.0.
  + d/control: Drop B-D on systemd.
* Dropped changes:
  + d/patches/fix-racey-restart.patch: part of 2.1.x, no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
{
203
203
        const char *script_path;
204
204
 
205
 
        /* Use global script path, if one exists */
206
 
        script_path = mail_user_plugin_getenv(user, "sieve_global_path");
207
 
        if (script_path == NULL) {
 
205
        /* Use default script path, if one exists */
 
206
        script_path = mail_user_plugin_getenv(user, "sieve_default");
 
207
        if ( script_path == NULL ) {
208
208
                /* For backwards compatibility */
209
 
                script_path = mail_user_plugin_getenv(user, "global_script_path");
 
209
                script_path = mail_user_plugin_getenv(user, "sieve_global_path");
210
210
        }
211
211
 
212
212
        return script_path;
266
266
 
267
267
static struct sieve_binary *lda_sieve_open
268
268
(struct lda_sieve_run_context *srctx, unsigned int script_index,
269
 
        enum sieve_error *error_r)
 
269
        enum sieve_compile_flags cpflags, enum sieve_error *error_r)
270
270
{
271
271
        struct sieve_instance *svinst = srctx->svinst;
272
272
        const char *script_path = srctx->script_files[script_index];
287
287
        sieve_error_handler_reset(ehandler);
288
288
 
289
289
        /* Open the sieve script */
290
 
        if ( (sbin=sieve_open(svinst, script_path, script_name, ehandler, error_r))
291
 
                == NULL ) {
 
290
        if ( (sbin=sieve_open
 
291
                (svinst, script_path, script_name, ehandler, cpflags, error_r)) == NULL ) {
292
292
                if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
293
293
                        if ( debug )
294
294
                                sieve_sys_debug(svinst, "script file %s is missing", script_path);
312
312
 
313
313
static struct sieve_binary *lda_sieve_recompile
314
314
(struct lda_sieve_run_context *srctx, unsigned int script_index,
315
 
        enum sieve_error *error_r)
 
315
        enum sieve_compile_flags cpflags, enum sieve_error *error_r)
316
316
{
317
317
        struct sieve_instance *svinst = srctx->svinst;
318
318
        const char *script_path = srctx->script_files[script_index];
335
335
                ehandler = srctx->master_ehandler;
336
336
 
337
337
        if ( (sbin=sieve_compile
338
 
                (svinst, script_path, script_name, ehandler, error_r)) == NULL ) {
 
338
                (svinst, script_path, script_name, ehandler, cpflags, error_r)) == NULL ) {
339
339
 
340
340
                if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
341
341
                        if ( debug )
407
407
        struct sieve_error_handler *ehandler;
408
408
        struct sieve_binary *sbin;
409
409
        bool debug = srctx->mdctx->dest_user->mail_debug;
 
410
        enum sieve_compile_flags cpflags = 0;
 
411
        enum sieve_runtime_flags rtflags = 0;
410
412
        enum sieve_error error;
411
413
        int ret;
412
414
 
 
415
        if ( user_script ) {
 
416
                cpflags |= SIEVE_COMPILE_FLAG_NOGLOBAL;
 
417
                rtflags |= SIEVE_RUNTIME_FLAG_NOGLOBAL;
 
418
                ehandler = srctx->user_ehandler;
 
419
        } else {
 
420
                ehandler = srctx->master_ehandler;
 
421
        }
 
422
 
413
423
        /* Open the script */
414
424
 
415
 
        if ( (sbin=lda_sieve_open(srctx, 0, &error)) == NULL )
 
425
        if ( (sbin=lda_sieve_open(srctx, 0, cpflags, &error)) == NULL )
416
426
                return ( error == SIEVE_ERROR_NOT_FOUND ? 0 : -1 );
417
427
 
418
428
        /* Execute */
420
430
        if ( debug )
421
431
                sieve_sys_debug(svinst, "executing script from %s", sieve_get_source(sbin));
422
432
 
423
 
        if ( user_script ) {
424
 
                ehandler = srctx->user_ehandler;
425
 
        } else {
426
 
                ehandler = srctx->master_ehandler;
427
 
        }
428
 
 
429
 
        ret = sieve_execute(sbin, srctx->msgdata, srctx->scriptenv, ehandler, NULL);
 
433
        ret = sieve_execute
 
434
                (sbin, srctx->msgdata, srctx->scriptenv, ehandler, rtflags, NULL);
430
435
 
431
436
        /* Recompile if corrupt binary */
432
437
 
437
442
 
438
443
                /* Recompile */
439
444
 
440
 
                if ( (sbin=lda_sieve_recompile(srctx, 0, &error)) == NULL )
 
445
                if ( (sbin=lda_sieve_recompile(srctx, 0, cpflags, &error)) == NULL )
441
446
                        return ( error == SIEVE_ERROR_NOT_FOUND ? 0 : -1 );
442
447
 
443
448
                /* Execute again */
446
451
                        sieve_sys_debug
447
452
                                (svinst, "executing script from %s", sieve_get_source(sbin));
448
453
 
449
 
                ret = sieve_execute(sbin, srctx->msgdata, srctx->scriptenv, ehandler, NULL);
 
454
                ret = sieve_execute
 
455
                        (sbin, srctx->msgdata, srctx->scriptenv, ehandler, rtflags, NULL);
450
456
 
451
457
                /* Save new version */
452
458
 
486
492
        for ( i = 0; i < count && more; i++ ) {
487
493
                struct sieve_binary *sbin = NULL;
488
494
                const char *script_file = scripts[i];
 
495
                enum sieve_compile_flags cpflags = 0;
 
496
                enum sieve_runtime_flags rtflags = 0;
489
497
                bool final = ( i == count - 1 );
490
498
 
491
499
                user_script = ( script_file == srctx->user_script );
492
500
                last_script = script_file;
493
501
 
494
 
                if ( user_script )
 
502
                if ( user_script ) {
 
503
                        cpflags |= SIEVE_COMPILE_FLAG_NOGLOBAL;
 
504
                        rtflags |= SIEVE_RUNTIME_FLAG_NOGLOBAL;
495
505
                        ehandler = srctx->user_ehandler;
496
 
                else
 
506
                } else {
497
507
                        ehandler = srctx->master_ehandler;
 
508
                }
498
509
 
499
510
                /* Open */
500
511
 
501
 
                if ( (sbin=lda_sieve_open(srctx, i, &error)) == NULL ) {
 
512
                if ( (sbin=lda_sieve_open(srctx, i, cpflags, &error)) == NULL ) {
502
513
                        ret = ( error == SIEVE_ERROR_NOT_FOUND ? 0 : -1 );
503
514
                        break;
504
515
                }
506
517
                /* Execute */
507
518
 
508
519
                if ( debug )
509
 
                        sieve_sys_debug(svinst, "executing script from %s", sieve_get_source(sbin));
 
520
                        sieve_sys_debug
 
521
                                (svinst, "executing script from %s", sieve_get_source(sbin));
510
522
 
511
 
                more = sieve_multiscript_run(mscript, sbin, ehandler, final);
 
523
                more = sieve_multiscript_run(mscript, sbin, ehandler, rtflags, final);
512
524
 
513
525
                if ( !more ) {
514
526
                        if ( sieve_multiscript_status(mscript) == SIEVE_EXEC_BIN_CORRUPT &&
519
531
 
520
532
                                /* Recompile */
521
533
 
522
 
                                if ( (sbin=lda_sieve_recompile(srctx, i, &error))       == NULL ) {
 
534
                                if ( (sbin=lda_sieve_recompile(srctx, i, cpflags, &error)) == NULL ) {
523
535
                                        ret = ( error == SIEVE_ERROR_NOT_FOUND ? 0 : -1 );
524
536
                                        break;
525
537
                                }
526
538
 
527
539
                                /* Execute again */
528
540
 
529
 
                                more = sieve_multiscript_run(mscript, sbin, ehandler, final);
 
541
                                more = sieve_multiscript_run(mscript, sbin, ehandler, rtflags, final);
530
542
 
531
543
                                /* Save new version */
532
544