~ubuntu-branches/ubuntu/trusty/dovecot/trusty-updates

« back to all changes in this revision

Viewing changes to src/plugins/autocreate/autocreate-plugin.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (1.15.3) (96.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140108093549-814nkqdcxfbvgktg
Tags: 1:2.2.9-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/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.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2007-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
/* FIXME: this plugin is only for backwards compatibility. log a warning in
4
4
   v2.2 about this and in later versions remove completely */
28
28
{
29
29
        struct mail_namespace *ns;
30
30
        struct mailbox_settings *set;
 
31
        struct mail_namespace_settings tmp_ns_set;
31
32
 
32
33
        if (!uni_utf8_str_is_valid(vname)) {
33
34
                i_error("autocreate: Mailbox name isn't valid UTF-8: %s",
36
37
        }
37
38
 
38
39
        ns = mail_namespace_find(user->namespaces, vname);
39
 
        if (ns == NULL) {
 
40
        if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
40
41
                i_error("autocreate: No namespace found for mailbox: %s",
41
42
                        vname);
42
43
                return;
43
44
        }
44
45
 
45
 
        if (!array_is_created(&ns->set->mailboxes))
46
 
                p_array_init(&ns->set->mailboxes, user->pool, 16);
 
46
        if (array_is_created(&ns->set->mailboxes))
 
47
                tmp_ns_set.mailboxes = ns->set->mailboxes;
 
48
        else {
 
49
                p_array_init(&tmp_ns_set.mailboxes, user->pool, 16);
 
50
                /* work around ns->set being a const pointer. pretty ugly, but
 
51
                   this plugin is deprecated anyway. */
 
52
                memcpy((void *)&ns->set->mailboxes.arr, &tmp_ns_set.mailboxes.arr,
 
53
                       sizeof(ns->set->mailboxes.arr));
 
54
        }
47
55
 
48
56
        if (strncmp(vname, ns->prefix, ns->prefix_len) == 0)
49
57
                vname += ns->prefix_len;
53
61
                set->name = p_strdup(user->pool, vname);
54
62
                set->autocreate = MAILBOX_SET_AUTO_NO;
55
63
                set->special_use = "";
56
 
                array_append(&ns->set->mailboxes, &set, 1);
 
64
                array_append(&tmp_ns_set.mailboxes, &set, 1);
57
65
        }
58
66
        if (subscriptions)
59
67
                set->autocreate = MAILBOX_SET_AUTO_SUBSCRIBE;
66
74
                      bool subscriptions)
67
75
{
68
76
        const char *value;
69
 
        char env_name[20];
 
77
        char env_name[13+MAX_INT_STRLEN+1];
70
78
        unsigned int i = 1;
71
79
 
72
80
        value = mail_user_plugin_getenv(user, env_name_base);
73
81
        while (value != NULL) {
74
82
                add_autobox(user, value, subscriptions);
75
83
 
76
 
                i_snprintf(env_name, sizeof(env_name), "%s%d",
77
 
                           env_name_base, ++i);
 
84
                if (i_snprintf(env_name, sizeof(env_name), "%s%u",
 
85
                               env_name_base, ++i) < 0)
 
86
                        i_unreached();
78
87
                value = mail_user_plugin_getenv(user, env_name);
79
88
        }
80
89
}
92
101
 
93
102
void autocreate_plugin_init(struct module *module)
94
103
{
 
104
        i_warning("autocreate plugin is deprecated, use mailbox { auto } setting instead");
95
105
        mail_storage_hooks_add(module, &autocreate_mail_storage_hooks);
96
106
}
97
107