changeset 12854:46d46fa3929f

eacces_error_get*(): Handle errors to / directory better.
author Timo Sirainen <tss@iki.fi>
date Wed, 16 Mar 2011 18:37:14 +0200
parents 7d9db422549a
children 310f2784de31
files src/lib/eacces-error.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/eacces-error.c	Wed Mar 16 18:20:47 2011 +0200
+++ b/src/lib/eacces-error.c	Wed Mar 16 18:37:14 2011 +0200
@@ -126,13 +126,14 @@
 
 	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 {