From 0471a9dde7b4fb55779261460c973f85088b4b0c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 31 Aug 2010 20:04:10 +0100 Subject: [PATCH] access_get_error(): Fixed to give better error messages with relative paths. --- src/lib/eacces-error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/eacces-error.c b/src/lib/eacces-error.c index d8ba4f24b1..455233ab0b 100644 --- a/src/lib/eacces-error.c +++ b/src/lib/eacces-error.c @@ -95,9 +95,14 @@ eacces_error_get_full(const char *func, const char *path, bool creating) 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 @@ eacces_error_get_full(const char *func, const char *path, bool creating) str_append(errmsg, "()"); } - 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); -- 2.47.3