changeset 12050:8db227a70bec

access_get_error(): Fixed to give better error messages with relative paths.
author Timo Sirainen <tss@iki.fi>
date Tue, 31 Aug 2010 20:04:10 +0100
parents f90590836165
children 1d895c7a753d
files src/lib/eacces-error.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/eacces-error.c	Tue Aug 31 19:33:21 2010 +0100
+++ b/src/lib/eacces-error.c	Tue Aug 31 20:04:10 2010 +0100
@@ -95,9 +95,14 @@
 	orig_errno = errno;
 	errmsg = t_str_new(256);
 	str_printfa(errmsg, "%s(%s)", func, path);
+	dir = "/";
 	if (*path != '/') {
 		if (t_get_current_dir(&dir) == 0)
 			str_printfa(errmsg, " in directory %s", dir);
+		if (strchr(path, '/') == NULL) {
+			/* we have no path. do the file access checks anyway. */
+			ret = 0;
+		}
 	}
 	str_printfa(errmsg, " failed: Permission denied (euid=%s",
 		    dec2str(geteuid()));
@@ -119,7 +124,7 @@
 		str_append(errmsg, "(<unknown>)");
 	}
 
-	dir = "/"; memset(&dir_st, 0, sizeof(dir_st));
+	memset(&dir_st, 0, sizeof(dir_st));
 	while ((p = strrchr(prev_path, '/')) != NULL) {
 		dir = t_strdup_until(prev_path, p);
 		ret = stat(dir, &st);