}
}
-static int
-mailbox_list_stat_parent(const char *path, const char **root_dir_r,
- struct stat *st_r, const char **error_r)
-{
- const char *p;
-
- while (stat(path, st_r) < 0) {
- if (errno != ENOENT || strcmp(path, "/") == 0) {
- *error_r = t_strdup_printf("stat(%s) failed: %m", path);
- return -1;
- }
- p = strrchr(path, '/');
- if (p == NULL)
- path = "/";
- else
- path = t_strdup_until(path, p);
- }
- *root_dir_r = path;
- return 0;
-}
-
static const char *
get_expanded_path(const char *unexpanded_start, const char *unexpanded_stop,
const char *expanded_full)
/* up to this directory get the permissions from the first
parent directory that exists, if it has setgid bit
enabled. */
- if (mailbox_list_stat_parent(expanded, &root_dir, &st,
- error_r) < 0)
+ if (stat_first_parent(expanded, &root_dir, &st) < 0) {
+ *error_r = t_strdup_printf("stat(%s) failed: %m", root_dir);
return -1;
+ }
if ((st.st_mode & S_ISGID) != 0 && root_dir != expanded) {
if (mkdir_parents_chgrp(expanded, st.st_mode,
(gid_t)-1, root_dir) < 0 &&