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

« back to all changes in this revision

Viewing changes to src/plugins/acl/acl-backend-vfile.c

  • 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
 
/* Copyright (c) 2006-2011 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2006-2012 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "ioloop.h"
11
11
#include "file-dotlock.h"
12
12
#include "nfs-workarounds.h"
13
13
#include "mail-storage-private.h"
 
14
#include "mailbox-list-private.h"
14
15
#include "mail-namespace.h"
15
16
#include "acl-cache.h"
16
17
#include "acl-backend-vfile.h"
127
128
static const char *
128
129
acl_backend_vfile_get_local_dir(struct acl_backend *backend, const char *name)
129
130
{
130
 
        struct mail_namespace *ns;
 
131
        struct mail_namespace *ns = mailbox_list_get_namespace(backend->list);
131
132
        const char *dir, *inbox;
132
133
 
133
134
        if (*name == '\0')
134
135
                name = NULL;
 
136
        else if (!mailbox_list_is_valid_existing_name(ns->list, name))
 
137
                return NULL;
135
138
 
136
 
        ns = mailbox_list_get_namespace(backend->list);
137
139
        if (mail_storage_is_mailbox_file(ns->storage)) {
138
140
                dir = mailbox_list_get_path(ns->list, name,
139
141
                                            MAILBOX_LIST_PATH_TYPE_CONTROL);
161
163
        struct acl_backend_vfile *backend =
162
164
                (struct acl_backend_vfile *)_backend;
163
165
        struct acl_object_vfile *aclobj;
164
 
        const char *dir;
 
166
        const char *dir, *vname;
165
167
 
166
168
        aclobj = i_new(struct acl_object_vfile, 1);
167
169
        aclobj->aclobj.backend = _backend;
168
170
        aclobj->aclobj.name = i_strdup(name);
169
171
 
170
172
        if (backend->global_dir != NULL) T_BEGIN {
171
 
                struct mail_namespace *ns =
172
 
                        mailbox_list_get_namespace(_backend->list);
173
 
                string_t *vname;
174
 
 
175
 
                vname = t_str_new(128);
176
 
                mail_namespace_get_vname(ns, vname, name);
 
173
                vname = mailbox_list_get_vname(backend->backend.list, name);
177
174
                aclobj->global_path = i_strconcat(backend->global_dir, "/",
178
 
                                                  str_c(vname), NULL);
 
175
                                                  vname, NULL);
179
176
        } T_END;
180
177
 
181
178
        dir = acl_backend_vfile_get_local_dir(_backend, name);
187
184
static const char *
188
185
get_parent_mailbox(struct acl_backend *backend, const char *name)
189
186
{
190
 
        struct mail_namespace *ns = mailbox_list_get_namespace(backend->list);
191
187
        const char *p;
192
188
 
193
 
        p = strrchr(name, ns->real_sep);
 
189
        p = strrchr(name, mailbox_list_get_hierarchy_sep(backend->list));
194
190
        return p == NULL ? NULL : t_strdup_until(name, p);
195
191
}
196
192
 
867
863
                                          struct dotlock **dotlock_r)
868
864
{
869
865
        struct acl_object *_aclobj = &aclobj->aclobj;
870
 
        const char *gid_origin;
871
 
        mode_t mode;
872
 
        gid_t gid;
 
866
        struct mailbox_permissions perm;
873
867
        int fd;
874
868
 
875
869
        if (aclobj->local_path == NULL) {
879
873
        }
880
874
 
881
875
        /* first lock the ACL file */
882
 
        mailbox_list_get_permissions(_aclobj->backend->list, _aclobj->name,
883
 
                                     &mode, &gid, &gid_origin);
 
876
        mailbox_list_get_permissions(_aclobj->backend->list,
 
877
                                     _aclobj->name, &perm);
884
878
        fd = file_dotlock_open_group(&dotlock_set, aclobj->local_path, 0,
885
 
                                     mode, gid, gid_origin, dotlock_r);
 
879
                                     perm.file_create_mode,
 
880
                                     perm.file_create_gid,
 
881
                                     perm.file_create_gid_origin, dotlock_r);
886
882
        if (fd == -1) {
887
883
                i_error("file_dotlock_open(%s) failed: %m", aclobj->local_path);
888
884
                return -1;