dovecot-2.2: lib-storage: Use stat_first_parent() instead of doi...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 5 01:14:35 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/c0ad6afa4128
changeset: 15556:c0ad6afa4128
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Dec 13 12:14:03 2012 +0200
description:
lib-storage: Use stat_first_parent() instead of doing it ourself.

diffstat:

 src/lib-storage/mailbox-list.c |  26 +++-----------------------
 1 files changed, 3 insertions(+), 23 deletions(-)

diffs (44 lines):

diff -r 40f9e2e339a6 -r c0ad6afa4128 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Thu Dec 13 12:13:42 2012 +0200
+++ b/src/lib-storage/mailbox-list.c	Thu Dec 13 12:14:03 2012 +0200
@@ -765,27 +765,6 @@
 	}
 }
 
-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)
@@ -873,9 +852,10 @@
 		/* 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 &&


More information about the dovecot-cvs mailing list