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

« back to all changes in this revision

Viewing changes to src/lib-storage/index/dbox-single/sdbox-file.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
#include "lib.h"
4
4
#include "eacces-error.h"
25
25
        file->file.primary_path =
26
26
                i_strdup_printf("%s/%s", mailbox_get_path(box), fname);
27
27
 
28
 
        alt_path = mailbox_list_get_path(box->list, box->name,
29
 
                                         MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
30
 
        if (alt_path != NULL)
 
28
        if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX,
 
29
                                &alt_path) > 0)
31
30
                file->file.alt_path = i_strdup_printf("%s/%s", alt_path, fname);
32
31
}
33
32
 
127
126
static int sdbox_file_rename_attachments(struct sdbox_file *file)
128
127
{
129
128
        struct dbox_storage *storage = file->file.storage;
 
129
        struct fs_file *src_file, *dest_file;
130
130
        const char *const *pathp, *src, *dest;
131
131
        int ret = 0;
132
132
 
134
134
                src = t_strdup_printf("%s/%s", storage->attachment_dir, *pathp);
135
135
                dest = t_strdup_printf("%s/%s", storage->attachment_dir,
136
136
                                sdbox_file_attachment_relpath(file, *pathp));
137
 
                if (fs_rename(storage->attachment_fs, src, dest) < 0) {
 
137
                src_file = fs_file_init(storage->attachment_fs, src,
 
138
                                        FS_OPEN_MODE_READONLY);
 
139
                dest_file = fs_file_init(storage->attachment_fs, dest,
 
140
                                        FS_OPEN_MODE_READONLY);
 
141
                if (fs_rename(src_file, dest_file) < 0) {
138
142
                        mail_storage_set_critical(&storage->storage, "%s",
139
143
                                fs_last_error(storage->attachment_fs));
140
144
                        ret = -1;
141
145
                }
 
146
                fs_file_deinit(&src_file);
 
147
                fs_file_deinit(&dest_file);
142
148
        } T_END;
143
149
        return ret;
144
150
}
182
188
{
183
189
        struct dbox_storage *storage = file->file.storage;
184
190
        struct fs *fs = storage->attachment_fs;
 
191
        struct fs_file *fs_file;
185
192
        const char *const *pathp, *path;
186
193
        int ret = 0;
187
194
 
192
199
                   attachment paths), so it's safe to delete them. */
193
200
                path = t_strdup_printf("%s/%s", storage->attachment_dir,
194
201
                                       *pathp);
195
 
                if (fs_unlink(fs, path) < 0 &&
 
202
                fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
 
203
                if (fs_delete(fs_file) < 0 &&
196
204
                    errno != ENOENT) {
197
205
                        mail_storage_set_critical(&storage->storage, "%s",
198
206
                                                  fs_last_error(fs));
199
207
                        ret = -1;
200
208
                }
 
209
                fs_file_deinit(&fs_file);
 
210
 
201
211
                path = t_strdup_printf("%s/%s", storage->attachment_dir,
202
212
                                sdbox_file_attachment_relpath(file, *pathp));
203
 
                if (fs_unlink(fs, path) < 0 &&
 
213
                fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
 
214
                if (fs_delete(fs_file) < 0 &&
204
215
                    errno != ENOENT) {
205
216
                        mail_storage_set_critical(&storage->storage, "%s",
206
217
                                                  fs_last_error(fs));
207
218
                        ret = -1;
208
219
                }
 
220
                fs_file_deinit(&fs_file);
209
221
        } T_END;
210
222
        return ret;
211
223
}
310
322
        output = o_stream_create_fd_file(out_fd, 0, FALSE);
311
323
        i_stream_seek(file->input, 0);
312
324
        while ((ret = o_stream_send_istream(output, file->input)) > 0) ;
313
 
        if (ret == 0)
314
 
                ret = o_stream_flush(output);
315
 
        if (output->stream_errno != 0) {
316
 
                errno = output->stream_errno;
 
325
        if (o_stream_nfinish(output) < 0) {
317
326
                mail_storage_set_critical(storage, "write(%s) failed: %m",
318
327
                                          temp_path);
319
328
                ret = -1;
427
436
 
428
437
        pool = pool_alloconly_create("sdbox attachments unlink", 1024);
429
438
        p_array_init(&extrefs, pool, 16);
430
 
        if (!dbox_attachment_parse_extref(extrefs_line, pool, &extrefs)) {
 
439
        if (!index_attachment_parse_extrefs(extrefs_line, pool, &extrefs)) {
431
440
                i_warning("%s: Ignoring corrupted extref: %s",
432
441
                          sfile->file.cur_path, extrefs_line);
433
442
                array_clear(&extrefs);