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

« back to all changes in this revision

Viewing changes to src/lib-storage/mailbox-list.h

  • 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:
1
1
#ifndef MAILBOX_LIST_H
2
2
#define MAILBOX_LIST_H
3
3
 
4
 
#include "mail-types.h"
 
4
#include "guid.h"
5
5
#include "mail-error.h"
6
6
 
7
7
#ifdef PATH_MAX
24
24
        /* no support for \noselect directories, only mailboxes */
25
25
        MAILBOX_LIST_PROP_NO_NOSELECT           = 0x04,
26
26
        /* mail root directory isn't required */
27
 
        MAILBOX_LIST_PROP_NO_ROOT               = 0x08
 
27
        MAILBOX_LIST_PROP_NO_ROOT               = 0x08,
 
28
        /* Automatically create mailbox directories when needed */
 
29
        MAILBOX_LIST_PROP_AUTOCREATE_DIRS       = 0x10
28
30
};
29
31
 
30
32
enum mailbox_list_flags {
31
33
        /* Mailboxes are files, not directories. */
32
 
        MAILBOX_LIST_FLAG_MAILBOX_FILES         = 0x01
 
34
        MAILBOX_LIST_FLAG_MAILBOX_FILES         = 0x01,
 
35
        /* Namespace already has a mailbox list, don't assign this
 
36
           mailbox list to it. */
 
37
        MAILBOX_LIST_FLAG_SECONDARY             = 0x02
33
38
};
34
39
 
35
40
enum mailbox_info_flags {
48
53
        MAILBOX_MATCHED                 = 0x40000000
49
54
};
50
55
 
51
 
enum mailbox_name_status {
52
 
        /* name points to a selectable mailbox */
53
 
        MAILBOX_NAME_EXISTS_MAILBOX,
54
 
        /* name points to non-selectable mailbox */
55
 
        MAILBOX_NAME_EXISTS_DIR,
56
 
        MAILBOX_NAME_VALID,
57
 
        MAILBOX_NAME_INVALID,
58
 
        MAILBOX_NAME_NOINFERIORS
59
 
};
60
 
 
61
56
enum mailbox_list_iter_flags {
62
57
        /* Ignore index file and ACLs (used by ACL plugin internally) */
63
58
        MAILBOX_LIST_ITER_RAW_LIST              = 0x000001,
65
60
           (maybe \noselect), have LIST also return "foo/" in the replies.
66
61
           This is needed by IMAP, but messes up internal code. */
67
62
        MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT  = 0x000002,
68
 
        /* Don't list INBOX unless it actually exists */
69
 
        MAILBOX_LIST_ITER_NO_AUTO_INBOX         = 0x000004,
 
63
        /* Don't list autocreated mailboxes (e.g. INBOX) unless they
 
64
           physically exist */
 
65
        MAILBOX_LIST_ITER_NO_AUTO_BOXES         = 0x000004,
70
66
 
71
67
        /* For mailbox_list_iter_init_namespaces(): Skip namespaces that
72
68
           have alias_for set. */
83
79
        /* Return MAILBOX_CHILD_* if mailbox's children match selection
84
80
           criteria, even if the mailbox itself wouldn't match. */
85
81
        MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000200,
 
82
        /* Return only mailboxes that have special use flags */
 
83
        MAILBOX_LIST_ITER_SELECT_SPECIALUSE     = 0x000400,
86
84
 
87
85
        /* Don't return any flags unless it can be done without cost */
88
86
        MAILBOX_LIST_ITER_RETURN_NO_FLAGS       = 0x001000,
89
87
        /* Return MAILBOX_SUBSCRIBED flag */
90
88
        MAILBOX_LIST_ITER_RETURN_SUBSCRIBED     = 0x002000,
91
89
        /* Return children flags */
92
 
        MAILBOX_LIST_ITER_RETURN_CHILDREN       = 0x004000
 
90
        MAILBOX_LIST_ITER_RETURN_CHILDREN       = 0x004000,
 
91
        /* Return IMAP special use flags */
 
92
        MAILBOX_LIST_ITER_RETURN_SPECIALUSE     = 0x008000
93
93
};
94
94
 
95
95
enum mailbox_list_path_type {
138
138
        /* if set, store mailboxes under root_dir/mailbox_dir_name/.
139
139
           this setting contains either "" or "dir/". */
140
140
        const char *mailbox_dir_name;
 
141
 
 
142
        /* Encode "bad" characters in mailbox names as <escape_char><hex> */
 
143
        char escape_char;
 
144
        /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
 
145
        bool utf8;
141
146
};
142
147
 
143
148
struct mailbox_info {
144
149
        const char *name;
 
150
        const char *special_use;
145
151
        enum mailbox_info_flags flags;
 
152
 
146
153
        struct mail_namespace *ns;
147
154
};
148
155
 
 
156
struct mailbox_permissions {
 
157
        /* The actual uid/gid of the mailbox */
 
158
        uid_t file_uid;
 
159
        gid_t file_gid;
 
160
 
 
161
        /* mode and GID to use for newly created files/dirs.
 
162
           (gid_t)-1 is used if the default GID can be used. */
 
163
        mode_t file_create_mode, dir_create_mode;
 
164
        gid_t file_create_gid;
 
165
        /* origin (e.g. path) where the file_create_gid was got from */
 
166
        const char *file_create_gid_origin;
 
167
 
 
168
        bool mail_index_permissions_set;
 
169
};
 
170
 
149
171
/* register all drivers */
150
172
void mailbox_list_register_all(void);
151
173
 
158
180
/* Returns 0 if ok, -1 if driver was unknown. */
159
181
int mailbox_list_create(const char *driver, struct mail_namespace *ns,
160
182
                        const struct mailbox_list_settings *set,
161
 
                        enum mailbox_list_flags flags, const char **error_r);
 
183
                        enum mailbox_list_flags flags,
 
184
                        struct mailbox_list **list_r, const char **error_r);
162
185
void mailbox_list_destroy(struct mailbox_list **list);
163
186
 
164
187
const char *
169
192
mailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
170
193
struct mail_user *
171
194
mailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE;
172
 
int mailbox_list_get_storage(struct mailbox_list **list, const char **name,
 
195
int mailbox_list_get_storage(struct mailbox_list **list, const char *vname,
173
196
                             struct mail_storage **storage_r);
174
197
void mailbox_list_get_closest_storage(struct mailbox_list *list,
175
198
                                      struct mail_storage **storage);
 
199
char mailbox_list_get_hierarchy_sep(struct mailbox_list *list);
176
200
 
177
 
/* Returns the mode and GID that should be used when creating new files to
178
 
   the specified mailbox, or to mailbox list root if name is NULL. (gid_t)-1 is
179
 
   returned if it's not necessary to change the default gid. */
180
 
void mailbox_list_get_permissions(struct mailbox_list *list,
181
 
                                  const char *name,
182
 
                                  mode_t *mode_r, gid_t *gid_r,
183
 
                                  const char **gid_origin_r);
184
 
/* Like mailbox_list_get_permissions(), but add execute-bits for mode
185
 
   if either read or write bit is set (e.g. 0640 -> 0750). */
186
 
void mailbox_list_get_dir_permissions(struct mailbox_list *list,
187
 
                                      const char *name,
188
 
                                      mode_t *mode_r, gid_t *gid_r,
189
 
                                      const char **gid_origin_r);
190
 
/* Create path's parent directory with proper permissions. Since most
191
 
   directories are created lazily, this function can be used to easily create
192
 
   them whenever file creation fails with ENOENT. */
193
 
int mailbox_list_create_parent_dir(struct mailbox_list *list,
194
 
                                   const char *mailbox, const char *path);
 
201
/* Returns the mode and GID that should be used when creating new files and
 
202
   directories to the specified mailbox. (gid_t)-1 is returned if it's not
 
203
   necessary to change the default gid. */
 
204
void mailbox_list_get_permissions(struct mailbox_list *list, const char *name,
 
205
                                  struct mailbox_permissions *permissions_r);
 
206
/* Like mailbox_list_get_permissions(), but for creating files/dirs to the
 
207
   mail root directory (or even the root dir itself). */
 
208
void mailbox_list_get_root_permissions(struct mailbox_list *list,
 
209
                                       mode_t *file_mode_r, mode_t *dir_mode_r,
 
210
                                       gid_t *gid_r, const char **gid_origin_r);
 
211
/* Create path's directory with proper permissions. */
 
212
int mailbox_list_mkdir(struct mailbox_list *list,
 
213
                       const char *mailbox, const char *path);
 
214
/* Like mailbox_list_mkdir(), but create path's parent parent directory.
 
215
   Since most directories are created lazily, this function can be used to
 
216
   easily create them whenever file creation fails with ENOENT. */
 
217
int mailbox_list_mkdir_parent(struct mailbox_list *list,
 
218
                              const char *mailbox, const char *path);
 
219
/* mkdir() a root directory of given type with proper permissions. */
 
220
int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path,
 
221
                            enum mailbox_list_path_type type,
 
222
                            const char **error_r);
195
223
 
196
224
/* Returns TRUE if the name doesn't contain any invalid characters.
197
225
   The create name check can be more strict. */
202
230
bool mailbox_list_is_valid_create_name(struct mailbox_list *list,
203
231
                                       const char *name);
204
232
 
 
233
const char *mailbox_list_get_storage_name(struct mailbox_list *list,
 
234
                                          const char *vname);
 
235
const char *mailbox_list_get_vname(struct mailbox_list *list, const char *name);
 
236
 
205
237
/* Return full path for the given mailbox name. The name must be a valid
206
238
   existing mailbox name, or NULL to get the root directory.
207
239
   For INDEX=MEMORY it returns "" as the path. */
208
240
const char *mailbox_list_get_path(struct mailbox_list *list, const char *name,
209
241
                                  enum mailbox_list_path_type type);
210
 
/* Returns mailbox name status */
211
 
int mailbox_list_get_mailbox_name_status(struct mailbox_list *list,
212
 
                                         const char *name,
213
 
                                         enum mailbox_name_status *status);
214
242
/* Returns mailbox's change log, or NULL if it doesn't have one. */
215
243
struct mailbox_log *mailbox_list_get_changelog(struct mailbox_list *list);
216
244
/* Specify timestamp to use when writing mailbox changes to changelog.
258
286
   -1 if error. */
259
287
int mailbox_list_mailbox(struct mailbox_list *list, const char *name,
260
288
                         enum mailbox_info_flags *flags_r);
 
289
/* Returns 1 if mailbox has children, 0 if not, -1 if error. */
 
290
int mailbox_has_children(struct mailbox_list *list, const char *name);
261
291
 
262
292
/* Subscribe/unsubscribe mailbox. There should be no error when
263
293
   subscribing to already subscribed mailbox. Subscribing to
270
300
int mailbox_list_create_dir(struct mailbox_list *list, const char *name);
271
301
/* Delete a non-selectable mailbox. Fail if the mailbox is selectable. */
272
302
int mailbox_list_delete_dir(struct mailbox_list *list, const char *name);
 
303
/* Delete a symlinked mailbox. Fail if the mailbox isn't a symlink. */
 
304
int mailbox_list_delete_symlink(struct mailbox_list *list, const char *name);
273
305
 
274
306
/* Returns the error message of last occurred error. */
275
307
const char *mailbox_list_get_last_error(struct mailbox_list *list,