~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to src/lib-storage/index/shared/shared-list.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
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) 2008-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2008-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "imap-match.h"
 
5
#include "mailbox-tree.h"
5
6
#include "mailbox-list-private.h"
6
7
#include "index-storage.h"
7
8
#include "shared-storage.h"
43
44
        const char *name;
44
45
 
45
46
        name = mailbox_list_get_storage_name(*list, vname);
 
47
        if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
 
48
                /* trying to access the shared/ prefix itself */
 
49
                *storage_r = ns->storage;
 
50
                return 0;
 
51
        }
 
52
 
46
53
        if (shared_storage_get_namespace(&ns, &name) < 0)
47
54
                return -1;
48
55
        *list = ns->list;
49
 
        *storage_r = ns->storage;
50
 
        return 0;
51
 
}
52
 
 
53
 
static bool
54
 
shared_is_valid_pattern(struct mailbox_list *list, const char *pattern)
55
 
{
56
 
        struct mail_namespace *ns = list->ns;
57
 
 
58
 
        if (shared_storage_get_namespace(&ns, &pattern) < 0)
59
 
                return FALSE;
60
 
        return mailbox_list_is_valid_pattern(ns->list, pattern);
61
 
}
62
 
 
63
 
static bool
64
 
shared_is_valid_existing_name(struct mailbox_list *list, const char *name)
65
 
{
66
 
        struct mail_namespace *ns = list->ns;
67
 
 
68
 
        if (shared_storage_get_namespace(&ns, &name) < 0)
69
 
                return FALSE;
70
 
        return mailbox_list_is_valid_existing_name(ns->list, name);
71
 
}
72
 
 
73
 
static bool
74
 
shared_is_valid_create_name(struct mailbox_list *list, const char *name)
75
 
{
76
 
        struct mail_namespace *ns = list->ns;
77
 
 
78
 
        if (shared_storage_get_namespace(&ns, &name) < 0)
79
 
                return FALSE;
80
 
        return mailbox_list_is_valid_create_name(ns->list, name);
 
56
        return mailbox_list_get_storage(list, vname, storage_r);
81
57
}
82
58
 
83
59
static char shared_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED)
85
61
        return '/';
86
62
}
87
63
 
88
 
static const char *
 
64
static int
89
65
shared_list_get_path(struct mailbox_list *list, const char *name,
90
 
                     enum mailbox_list_path_type type)
 
66
                     enum mailbox_list_path_type type, const char **path_r)
91
67
{
92
68
        struct mail_namespace *ns = list->ns;
93
69
 
94
 
        if (list->ns->storage == NULL || name == NULL ||
 
70
        if (mail_namespace_get_default_storage(list->ns) == NULL ||
 
71
            name == NULL ||
95
72
            shared_storage_get_namespace(&ns, &name) < 0) {
96
 
                switch (type) {
97
 
                case MAILBOX_LIST_PATH_TYPE_DIR:
98
 
                case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
99
 
                case MAILBOX_LIST_PATH_TYPE_MAILBOX:
100
 
                case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
101
 
                case MAILBOX_LIST_PATH_TYPE_CONTROL:
102
 
                        break;
103
 
                case MAILBOX_LIST_PATH_TYPE_INDEX:
104
 
                        /* we can safely say we don't use indexes */
105
 
                        return "";
106
 
                }
107
73
                /* we don't have a directory we can use. */
108
 
                return NULL;
 
74
                *path_r = NULL;
 
75
                return 0;
109
76
        }
110
 
        return mailbox_list_get_path(ns->list, name, type);
 
77
        return mailbox_list_get_path(ns->list, name, type, path_r);
111
78
}
112
79
 
113
80
static const char *
131
98
        else
132
99
                ns_ref = NULL;
133
100
 
134
 
        if (ns_ref != NULL && shared_storage_get_namespace(&ns, &ns_ref) == 0)
 
101
        if (ns_ref != NULL && *ns_ref != '\0' &&
 
102
            shared_storage_get_namespace(&ns, &ns_ref) == 0)
135
103
                return mailbox_list_join_refpattern(ns->list, ref, pattern);
136
104
 
137
105
        /* fallback to default behavior */
144
112
shared_list_create_missing_namespaces(struct mailbox_list *list,
145
113
                                      const char *const *patterns)
146
114
{
 
115
        struct mail_namespace *ns;
147
116
        char sep = mail_namespace_get_sep(list->ns);
148
117
        const char *list_pat, *name;
149
118
        unsigned int i;
166
135
                                last = p;
167
136
                }
168
137
                if (last != NULL) {
 
138
                        ns = list->ns;
169
139
                        name = t_strdup_until(list_pat, last);
170
 
                        (void)mailbox_list_is_valid_existing_name(list, name);
 
140
                        (void)shared_storage_get_namespace(&ns, &name);
171
141
                }
172
142
        }
173
143
}
208
178
}
209
179
 
210
180
static int
211
 
shared_list_subscriptions_refresh(struct mailbox_list *src_list ATTR_UNUSED,
212
 
                                  struct mailbox_list *dest_list ATTR_UNUSED)
 
181
shared_list_subscriptions_refresh(struct mailbox_list *src_list,
 
182
                                  struct mailbox_list *dest_list)
213
183
{
 
184
        char sep;
 
185
 
 
186
        if (dest_list->subscriptions == NULL) {
 
187
                sep = mail_namespace_get_sep(src_list->ns);
 
188
                dest_list->subscriptions = mailbox_tree_init(sep);
 
189
        }
214
190
        return 0;
215
191
}
216
192
 
229
205
}
230
206
 
231
207
static int
232
 
shared_list_create_mailbox_dir(struct mailbox_list *list, const char *name,
233
 
                               enum mailbox_dir_create_type type)
234
 
{
235
 
        struct mail_namespace *ns = list->ns;
236
 
        int ret;
237
 
 
238
 
        if (shared_storage_get_namespace(&ns, &name) < 0)
239
 
                return -1;
240
 
        ret = ns->list->v.create_mailbox_dir(ns->list, name, type);
241
 
        if (ret < 0)
242
 
                shared_list_copy_error(list, ns);
243
 
        return ret;
244
 
}
245
 
 
246
 
static int
247
208
shared_list_delete_mailbox(struct mailbox_list *list, const char *name)
248
209
{
249
210
        struct mail_namespace *ns = list->ns;
307
268
 
308
269
static int
309
270
shared_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname,
310
 
                           struct mailbox_list *newlist, const char *newname,
311
 
                           bool rename_children)
 
271
                           struct mailbox_list *newlist, const char *newname)
312
272
{
313
273
        struct mail_namespace *ns;
314
274
        int ret;
317
277
                                      newlist, &newname, &ns) < 0)
318
278
                return -1;
319
279
 
320
 
        ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname,
321
 
                                         rename_children);
 
280
        ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname);
322
281
        if (ret < 0)
323
282
                shared_list_copy_error(oldlist, ns);
324
283
        return ret;
331
290
 
332
291
        {
333
292
                shared_list_alloc,
 
293
                NULL,
334
294
                shared_list_deinit,
335
295
                shared_get_storage,
336
 
                shared_is_valid_pattern,
337
 
                shared_is_valid_existing_name,
338
 
                shared_is_valid_create_name,
339
296
                shared_list_get_hierarchy_sep,
340
297
                mailbox_list_default_get_vname,
341
298
                mailbox_list_default_get_storage_name,
349
306
                NULL,
350
307
                shared_list_subscriptions_refresh,
351
308
                shared_list_set_subscribed,
352
 
                shared_list_create_mailbox_dir,
353
309
                shared_list_delete_mailbox,
354
310
                shared_list_delete_dir,
355
311
                shared_list_delete_symlink,
356
 
                shared_list_rename_mailbox
 
312
                shared_list_rename_mailbox,
 
313
                NULL, NULL, NULL, NULL
357
314
        }
358
315
};