]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
eacces_error_get*(): Handle errors to / directory better.
authorTimo Sirainen <tss@iki.fi>
Wed, 16 Mar 2011 16:37:14 +0000 (18:37 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 16 Mar 2011 16:37:14 +0000 (18:37 +0200)
src/lib/eacces-error.c

index 5128c520d43a7b3559fc13c1a46d86a3be05add8..2fd49fa349ba2a100f29078f47ff64680020c55e 100644 (file)
@@ -126,13 +126,14 @@ eacces_error_get_full(const char *func, const char *path, bool creating)
 
        memset(&dir_st, 0, sizeof(dir_st));
        while ((p = strrchr(prev_path, '/')) != NULL) {
-               dir = t_strdup_until(prev_path, p);
+               dir = p == prev_path ? "/" : t_strdup_until(prev_path, p);
                ret = stat(dir, &st);
                if (ret == 0)
                        break;
-               if (errno == EACCES) {
+               if (errno == EACCES && strcmp(dir, "/") != 0) {
                        /* see if we have access to parent directory */
-               } else if (errno == ENOENT && creating) {
+               } else if (errno == ENOENT && creating &&
+                          strcmp(dir, "/") != 0) {
                        /* probably mkdir_parents() failed here, find the first
                           parent directory we couldn't create */
                } else {