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

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/include/ext-include-common.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:
462
462
 * Including a script during code generation 
463
463
 */
464
464
 
465
 
bool ext_include_generate_include
 
465
int ext_include_generate_include
466
466
(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd,
467
467
        enum ext_include_script_location location, struct sieve_script *script, 
468
468
        const struct ext_include_script_info **included_r, bool once)
470
470
        const struct sieve_extension *this_ext = cmd->ext;
471
471
        struct ext_include_context *ext_ctx =
472
472
                (struct ext_include_context *)this_ext->context;
473
 
        bool result = TRUE;
 
473
        int result = 1;
474
474
        struct sieve_ast *ast;
475
475
        struct sieve_binary *sbin = cgenv->sbin;
476
476
        struct sieve_generator *gentr = cgenv->gentr;
488
488
         * already. 
489
489
         */
490
490
        if ( sieve_get_errors(ehandler) > 0 )
491
 
                return FALSE;
 
491
                return -1;
492
492
                
493
493
        /* Limit nesting level */
494
494
        if ( ctx->nesting_depth >= ext_ctx->max_nesting_depth ) {
495
495
                sieve_command_generate_error
496
496
                        (gentr, cmd, "cannot nest includes deeper than %d levels",
497
497
                                ext_ctx->max_nesting_depth);
498
 
                return FALSE;
 
498
                return -1;
499
499
        }
500
500
        
501
501
        /* Check for circular include */
503
503
                pctx = ctx;
504
504
                while ( pctx != NULL ) {
505
505
                        if ( sieve_script_equals(pctx->script, script) ) {
 
506
                                /* Just drop circular include when uploading inactive script;
 
507
                                 * not an error
 
508
                                 */
 
509
                                if ( (cgenv->flags & SIEVE_COMPILE_FLAG_UPLOADED) != 0 && 
 
510
                                        (cgenv->flags & SIEVE_COMPILE_FLAG_ACTIVATED) == 0 ) {
 
511
                                        sieve_command_generate_warning
 
512
                                                (gentr, cmd, "circular include (ignored during upload)");
 
513
                                        return 0;
 
514
                                }
 
515
 
506
516
                                sieve_command_generate_error(gentr, cmd, "circular include");
507
 
                                
508
 
                                return FALSE;
 
517
                                return -1;
509
518
                        }
510
519
                
511
520
                        pctx = pctx->parent;
520
529
        {       
521
530
                struct sieve_binary_block *inc_block;
522
531
                const char *script_name = sieve_script_name(script);
 
532
                enum sieve_compile_flags cpflags = cgenv->flags;
523
533
 
524
534
                /* Check whether include limit is exceeded */
525
535
                if ( ext_include_binary_script_get_count(binctx) >= 
527
537
                        sieve_command_generate_error(gentr, cmd, 
528
538
                                "failed to include script '%s': no more than %u includes allowed", 
529
539
                                str_sanitize(script_name, 80), ext_ctx->max_includes);
530
 
                        return FALSE;                   
 
540
                        return -1;
531
541
                }
532
542
                
533
543
                /* No, allocate a new block in the binary and mark the script as included.
540
550
                if ( (ast = sieve_parse(script, ehandler, NULL)) == NULL ) {
541
551
                        sieve_command_generate_error(gentr, cmd, 
542
552
                                "failed to parse included script '%s'", str_sanitize(script_name, 80));
543
 
                        return FALSE;
 
553
                        return -1;
544
554
                }
545
555
                
546
556
                /* Included scripts inherit global variable scope */
547
557
                (void)ext_include_create_ast_context(this_ext, ast, cmd->ast_node->ast);
548
558
 
 
559
                if ( location == EXT_INCLUDE_LOCATION_GLOBAL )
 
560
                                cpflags &= ~SIEVE_RUNTIME_FLAG_NOGLOBAL;
 
561
                else
 
562
                                cpflags |= SIEVE_RUNTIME_FLAG_NOGLOBAL;
 
563
 
549
564
                /* Validate */
550
 
                if ( !sieve_validate(ast, ehandler, NULL) ) {
 
565
                if ( !sieve_validate(ast, ehandler, cpflags, NULL) ) {
551
566
                        sieve_command_generate_error(gentr, cmd, 
552
567
                                "failed to validate included script '%s'", 
553
568
                                str_sanitize(script_name, 80));
554
569
                        sieve_ast_unref(&ast);
555
 
                        return FALSE;
 
570
                        return -1;
556
571
                }
557
572
 
558
573
                /* Generate 
560
575
                 * FIXME: It might not be a good idea to recurse code generation for 
561
576
                 * included scripts.
562
577
                 */
563
 
                subgentr = sieve_generator_create(ast, ehandler);                       
 
578
                subgentr = sieve_generator_create(ast, ehandler, cpflags);                      
564
579
                ext_include_initialize_generator_context(cmd->ext, subgentr, ctx, script);
565
580
                        
566
581
                if ( sieve_generator_run(subgentr, &inc_block) == NULL ) {
567
582
                        sieve_command_generate_error(gentr, cmd, 
568
583
                                "failed to generate code for included script '%s'", 
569
584
                                str_sanitize(script_name, 80));
570
 
                        result = FALSE;
 
585
                        result = -1;
571
586
                }
572
587
                
573
588
                sieve_generator_free(&subgentr);
576
591
                sieve_ast_unref(&ast);          
577
592
        } 
578
593
 
579
 
        if ( result ) *included_r = included;
 
594
        if ( result > 0 ) *included_r = included;
580
595
        
581
596
        return result;
582
597
}
681
696
                /* We are the top-level interpreter instance */ 
682
697
                
683
698
                if ( result == SIEVE_EXEC_OK ) {
 
699
                        enum sieve_runtime_flags rtflags = 0;
 
700
        
 
701
                        if ( included->location != EXT_INCLUDE_LOCATION_GLOBAL )
 
702
                                rtflags |= SIEVE_RUNTIME_FLAG_NOGLOBAL;
 
703
 
684
704
                        /* Create interpreter for top-level included script
685
705
                         * (first sub-interpreter) 
686
706
                         */
687
707
                        subinterp = sieve_interpreter_create_for_block
688
708
                                (included->block, included->script, renv->msgdata, renv->scriptenv, 
689
 
                                        ehandler);
 
709
                                        ehandler, rtflags);
690
710
 
691
711
                        if ( subinterp != NULL ) {                      
692
712
                                curctx = ext_include_interpreter_context_init_child
734
754
                                        result = ( sieve_interpreter_continue(subinterp, &interrupted) == 1 );
735
755
                                } else {
736
756
                                        if ( curctx->include != NULL ) {
737
 
 
738
757
                                                /* Sub-include requested */
739
758
                                                                                                                                        
740
759
                                                if ( result == SIEVE_EXEC_OK ) {
 
760
                                                        enum sieve_runtime_flags rtflags = 0;
 
761
        
 
762
                                                        if ( curctx->include->location != EXT_INCLUDE_LOCATION_GLOBAL )
 
763
                                                                rtflags |= SIEVE_RUNTIME_FLAG_NOGLOBAL;
 
764
 
741
765
                                                        /* Create sub-interpreter */
742
766
                                                        subinterp = sieve_interpreter_create_for_block
743
767
                                                                (curctx->include->block, curctx->include->script, renv->msgdata,
744
 
                                                                        renv->scriptenv, ehandler);                     
 
768
                                                                        renv->scriptenv, ehandler, rtflags);                    
745
769
 
746
770
                                                        if ( subinterp != NULL ) {
747
771
                                                                curctx = ext_include_interpreter_context_init_child