~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to dovecot-sieve/src/sieve-cmu.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-05-26 09:51:01 UTC
  • mfrom: (1.10.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080526095101-y0zxqc8ofd9j1aa5
Tags: 1:1.0.13-4ubuntu1
* Merge from debian unstable, remaining changes:
  - DebainMaintainerField
  - Use Snakeoil SSL certificate by default.
    + debian/control: Depend on ssl-cert
    + debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert paths
      to snakeoil.
    + debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  - Fast TearDown:
    + debian/rules: Call dh_installinit in 'multiuser' mode.
    + debian/control: Depend on newer sysv-rc for this.
    + debian/dovecot-common.postinst: Remove stp script symlinks from rc0 and rc6 on upgrades.
      Need to be kept unil next LTS release.
  - Add autopkgtest in debian/tests/*.
  - Don't fail in postinst if dovecot-{sql,ldap} is missing. (LP: #153161)
  - Dropped upstream-mail-group-fixes.dpatch. No longer needed.
  - Dropped upstream-invalid-password-fixes.dpatch. No longer needed.
  - debian/dovecot-common.init: Check to see if there is an /etc/inetd.conf. (LP: #208411)
  - debian/patches/login-max-processes-count-warning.dpatch: Tell the user
    that they have reached the maxium number of processes count. (LP: #189616)

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        const char *temp[10];
40
40
} sieve_msgdata_t;
41
41
 
 
42
static const char *unfold_header(const char *str)
 
43
{
 
44
        char *new_str;
 
45
        unsigned int i, j;
 
46
 
 
47
        for (i = 0; str[i] != '\0'; i++) {
 
48
                if (str[i] == '\n')
 
49
                        break;
 
50
        }
 
51
        if (str[i] == '\0')
 
52
                return str;
 
53
 
 
54
        /* @UNSAFE */
 
55
        new_str = t_malloc(i + strlen(str+i) + 1);
 
56
        memcpy(new_str, str, i);
 
57
        for (j = i; str[i] != '\0'; i++) {
 
58
                if (str[i] == '\n') {
 
59
                        new_str[j++] = ' ';
 
60
                        i++;
 
61
                        i_assert(str[i] == ' ' || str[i] == '\t');
 
62
                } else {
 
63
                        new_str[j++] = str[i];
 
64
                }
 
65
        }
 
66
        new_str[j] = '\0';
 
67
        return new_str;
 
68
}
 
69
 
 
70
static const char *const *
 
71
unfold_multiline_headers(const char *const *headers)
 
72
{
 
73
        const char **new_headers;
 
74
        unsigned int i;
 
75
 
 
76
        /* see if there are any multiline headers */
 
77
        for (i = 0; headers[i] != NULL; i++) {
 
78
                if (strchr(headers[i], '\n') != NULL)
 
79
                        break;
 
80
        }
 
81
        if (headers[i] == NULL) {
 
82
                /* no multilines */
 
83
                return headers;
 
84
        }
 
85
 
 
86
        /* @UNSAFE */
 
87
        for (; headers[i] != NULL; i++) ;
 
88
        new_headers = t_new(const char *, i + 1);
 
89
        for (i = 0; headers[i] != NULL; i++)
 
90
                new_headers[i] = unfold_header(headers[i]);
 
91
        return new_headers;
 
92
}
 
93
 
42
94
/* gets the header "head" from msg. */
43
95
static int getheader(void *v, const char *phead, const char ***body)
44
96
{
45
97
    sieve_msgdata_t *m = v;
 
98
    const char *const *headers;
46
99
 
47
100
    if (phead==NULL) return SIEVE_FAIL;
48
 
    *body = (const char **)mail_get_headers(m->mail, phead);
 
101
    headers = mail_get_headers(m->mail, phead);
 
102
    if (headers != NULL)
 
103
            headers = unfold_multiline_headers(headers);
 
104
    *body = (const char **)headers;
49
105
 
50
106
    if (*body) {
51
107
        return SIEVE_OK;
346
402
static int autorespond(void *ac, 
347
403
                       void *ic __attr_unused__,
348
404
                       void *sc,
349
 
                       void *mc __attr_unused__,
 
405
                       void *mc,
350
406
                       const char **errmsg __attr_unused__)
351
407
{
352
408
    sieve_autorespond_context_t *arc = (sieve_autorespond_context_t *) ac;
353
409
    script_data_t *sd = (script_data_t *) sc;
354
 
    int ret;
 
410
    sieve_msgdata_t *md = mc;
355
411
 
356
412
    /* ok, let's see if we've responded before */
357
 
    ret = duplicate_check(arc->hash, arc->len,  sd->username) ?
358
 
            SIEVE_DONE : SIEVE_OK;
359
 
 
360
 
    if (ret == SIEVE_OK) {
361
 
        duplicate_mark(arc->hash, arc->len, sd->username,
362
 
                       ioloop_time + arc->days * (24 * 60 * 60));
 
413
    if (duplicate_check(arc->hash, arc->len,  sd->username)) {
 
414
        i_info("msgid=%s: discarded duplicate vacation response to <%s>",
 
415
               md->id == NULL ? "" : str_sanitize(md->id, 80),
 
416
               str_sanitize(md->return_path, 80));
 
417
        return SIEVE_DONE;
363
418
    }
364
419
 
365
 
    return ret;
 
420
    duplicate_mark(arc->hash, arc->len, sd->username,
 
421
                   ioloop_time + arc->days * (24 * 60 * 60));
 
422
 
 
423
    return SIEVE_OK;
366
424
}
367
425
 
368
426
static int send_response(void *ac, 
409
467
    if (smtp_client_close(smtp_client) == 0) {
410
468
        duplicate_mark(outmsgid, strlen(outmsgid),
411
469
                       sdata->username, ioloop_time + DUPLICATE_DEFAULT_KEEP);
 
470
        i_info("msgid=%s: sent vacation response to <%s>",
 
471
               md->id == NULL ? "" : str_sanitize(md->id, 80),
 
472
               str_sanitize(md->return_path, 80));
412
473
        return SIEVE_OK;
413
474
    } else {
414
475
        *errmsg = "Error sending mail";
533
594
                        return -1;
534
595
                }
535
596
        } else {
536
 
                if (st.st_mtime < st2.st_mtime)
 
597
                if (st.st_mtime <= st2.st_mtime)
537
598
                        return 1;
538
599
        }
539
600