]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-posix: Code cleanup - don't store dir_mode permanently.
authorTimo Sirainen <tss@iki.fi>
Thu, 19 Nov 2015 15:19:19 +0000 (17:19 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 19 Nov 2015 15:19:19 +0000 (17:19 +0200)
Cleanup in preparation for mode=auto.

src/lib-fs/fs-posix.c

index 420c2341b5f9d8f8ec8aa06004d7abb5f1b1343f..0eca6e568368817ff18b520dcf650d524e757e0b 100644 (file)
@@ -33,7 +33,7 @@ struct posix_fs {
        char *temp_file_prefix, *root_path, *path_prefix;
        unsigned int temp_file_prefix_len;
        enum fs_posix_lock_method lock_method;
-       mode_t mode, dir_mode;
+       mode_t mode;
 };
 
 struct posix_fs_file {
@@ -118,10 +118,6 @@ fs_posix_init(struct fs *_fs, const char *args, const struct fs_settings *set)
                        return -1;
                }
        }
-       fs->dir_mode = fs->mode;
-       if ((fs->dir_mode & 0600) != 0) fs->dir_mode |= 0100;
-       if ((fs->dir_mode & 0060) != 0) fs->dir_mode |= 0010;
-       if ((fs->dir_mode & 0006) != 0) fs->dir_mode |= 0001;
        return 0;
 }
 
@@ -147,12 +143,19 @@ static enum fs_properties fs_posix_get_properties(struct fs *fs ATTR_UNUSED)
 static int fs_posix_mkdir_parents(struct posix_fs *fs, const char *path)
 {
        const char *dir, *fname;
+       mode_t dir_mode;
 
        fname = strrchr(path, '/');
        if (fname == NULL)
                return 1;
+
+       dir_mode = fs->mode;
+       if ((dir_mode & 0600) != 0) dir_mode |= 0100;
+       if ((dir_mode & 0060) != 0) dir_mode |= 0010;
+       if ((dir_mode & 0006) != 0) dir_mode |= 0001;
+
        dir = t_strdup_until(path, fname);
-       if (mkdir_parents(dir, fs->dir_mode) == 0)
+       if (mkdir_parents(dir, dir_mode) == 0)
                return 0;
        else if (errno == EEXIST)
                return 1;