~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002110912

« back to all changes in this revision

Viewing changes to src/imap/cmd-subscribe.c

  • Committer: Bazaar Package Importer
  • Author(s): CHuck Short, Chuck Short
  • Date: 2009-11-06 00:47:29 UTC
  • mfrom: (4.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106004729-i39n7v9e7d4h51f6
Tags: 1:1.2.6-1ubuntu1
* Merge from debian testing, remaining changes:
  Add new binary pkg dovecot-postfix that integrates postfix and dovecot
  automatically: (LP: #164837)
  + debian/control:
    - add new binary with short description
    - set Architecture all for dovecot-postfix (LP: #329878)
  + debian/dovecot-postfix.postinst:
    - create initial certificate symlinks to snakeoil.
    - set up postfix with postconf to:
      - use Maildir/ as the default mailbox.
      - use dovecot as the sasl authentication server.
      - use dovecot LDA (deliver).
      - use tls for smtp{d} services.
    - fix certificates paths in postfix' main.cf
    - add reject_unauth_destination to postfix' recipient restrictions
    - add reject_unknown_sender_domain to postfix' sender restrictions
    - rename configuration name on remove, delete on purge
    - restart dovecot after linking certificates
    - handle use case when postfix is unconfigurated
   + debian/dovecot-postfix.dirs: create backup directory for postfix's configuration
   + restart postfix and dovecot.
   + debian/dovecot-postfix.postrm:
     - remove all dovecot related configuration from postfix.
     - restart postfix and dovecot.
   + debian/dovecot-common.init:
     - check if /etc/dovecot/dovecot-postfix.conf exists and use it
       as the configuration file if so.
   + debian/patches/warning-ubuntu-postfix.dpatch
     - add warning about dovecot-postfix.conf in dovecot default 
       configuration file
   + debian/patches/dovecot-postfix.conf.diff:
     - Ubuntu server custom changes to the default dovecot configuration for
       better interfation with postfix
     - enable sieve plugin
   + debian/patches/dovecot-postfix.conf.diff:
     + Ubuntu server custom changes to the default dovecot configuration for
       better integration with postfix:
       - enable imap, pop3, imaps, pop3s and managesieve by default.
       - enable dovecot LDA (deliver).
       - enable SASL auth socket in postfix private directory.
   + debian/rules:
     - copy, patch and install dovecot-postfix.conf in /etc/dovecot/.
     - build architecure independent packages too
   + Use Snakeoil SSL certificates 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.
   + Add autopkgtest to debian/tests/*.
   + Fast TearDown: Update the lsb init header to not stop in level 6.
   + Add ufw integration:
     - Created debian/dovecot-common.ufw.profile.
     - debian/rules:
       + install profile
     - debian/control:
       + Suggest ufw
   + debian/{control,rules}: enable PIE hardening.
   + dovecot-imapd, dovecot-pop3: Replaces dovecot-common (<< 1:1.1). LP: #254721
   + debian/control:
     - Update Vcs-* headers.
   + debian/rules:
     - Create emtpy stamp.h.in files in dovecot-sieve/ and dovecot-managesieve/
       if they're not there since empty files are not included in the diff.gz 
       file.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
   + Dropped:
     - debian/patches/security-CVE-2009-3235: Applied upstream.
     - debian/patches/fix-pop3-assertion.dpatch: Applied upstream.
     - dovecot-sieve and dovecot-managesieve: Use the debian patches instead.

  [Chuck Short]
  - Updated dovecot-sieve to 0.1.13.
  - Updated dovecot-managesieve to 0.11.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        unsigned int name_len = strlen(name);
11
11
 
12
12
        for (; ns != NULL; ns = ns->next) {
13
 
                if ((ns->flags & NAMESPACE_FLAG_LIST) == 0)
 
13
                if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
 
14
                                  NAMESPACE_FLAG_LIST_CHILDREN)) == 0)
14
15
                        continue;
15
16
 
16
17
                if (ns->prefix_len <= name_len)
27
28
 
28
29
bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
29
30
{
30
 
        struct mail_namespace *ns;
31
 
        const char *mailbox, *verify_name;
 
31
        struct mail_namespace *ns, *real_ns;
 
32
        struct mail_storage *storage;
 
33
        const char *mailbox, *mailbox2 = NULL, *verify_name, *real_name;
 
34
        bool unsubscribed_mailbox2;
32
35
 
33
36
        /* <mailbox> */
34
37
        if (!client_read_string_args(cmd, 1, &mailbox))
35
38
                return FALSE;
36
 
 
37
39
        verify_name = mailbox;
38
 
        ns = mail_namespace_find_subscribable(cmd->client->namespaces,
 
40
 
 
41
        real_name = mailbox;
 
42
        ns = client_find_namespace(cmd, &real_name);
 
43
        if (ns == NULL)
 
44
                return TRUE;
 
45
        storage = ns->storage;
 
46
 
 
47
        /* now find a namespace where the subscription can be added to */
 
48
        ns = mail_namespace_find_subscribable(cmd->client->user->namespaces,
39
49
                                              &mailbox);
40
50
        if (ns == NULL) {
41
 
                client_send_tagline(cmd, "NO Unknown namespace.");
 
51
                client_send_tagline(cmd, "NO Unknown subscription namespace.");
42
52
                return TRUE;
43
53
        }
44
54
 
 
55
        real_ns = mail_storage_get_namespace(storage);
 
56
        if (ns != real_ns) {
 
57
                /* subscription is being written to a different namespace
 
58
                   than where the mailbox exists. */
 
59
                mailbox = t_strconcat(real_ns->prefix, real_name, NULL);
 
60
                /* drop the common prefix */
 
61
                i_assert(strncmp(ns->prefix, mailbox, strlen(ns->prefix)) == 0);
 
62
                mailbox += strlen(ns->prefix);
 
63
        }
 
64
 
45
65
        if ((client_workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
46
66
            *mailbox != '\0' && mailbox[strlen(mailbox)-1] ==
47
67
            mail_storage_get_hierarchy_sep(ns->storage)) {
48
68
                /* verify the validity without the trailing '/' */
49
69
                verify_name = t_strndup(verify_name, strlen(verify_name)-1);
 
70
                mailbox2 = mailbox;
 
71
                mailbox = t_strndup(mailbox, strlen(mailbox)-1);
50
72
        }
51
73
 
52
 
        if (have_listable_namespace_prefix(cmd->client->namespaces,
 
74
        if (have_listable_namespace_prefix(cmd->client->user->namespaces,
53
75
                                           verify_name)) {
54
76
                /* subscribing to a listable namespace prefix, allow it. */
 
77
        } else if (subscribe) {
 
78
                if (!client_verify_mailbox_name(cmd, verify_name,
 
79
                                        CLIENT_VERIFY_MAILBOX_SHOULD_EXIST))
 
80
                        return TRUE;
55
81
        } else {
56
82
                if (!client_verify_mailbox_name(cmd, verify_name,
57
 
                                                subscribe, FALSE))
 
83
                                                CLIENT_VERIFY_MAILBOX_NAME))
58
84
                        return TRUE;
59
85
        }
60
86
 
61
 
        if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0)
 
87
        unsubscribed_mailbox2 = FALSE;
 
88
        if (!subscribe && mailbox2 != NULL) {
 
89
                /* try to unsubscribe both "box" and "box/" */
 
90
                if (mailbox_list_set_subscribed(ns->list, mailbox2, FALSE) == 0)
 
91
                        unsubscribed_mailbox2 = TRUE;
 
92
        }
 
93
 
 
94
        if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0 &&
 
95
            !unsubscribed_mailbox2) {
62
96
                client_send_list_error(cmd, ns->list);
63
 
        else {
 
97
        } else {
64
98
                client_send_tagline(cmd, subscribe ?
65
99
                                    "OK Subscribe completed." :
66
100
                                    "OK Unsubscribe completed.");