dovecot-1.2: eacces_error_get*(): Show current directory if path...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 8 20:50:41 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/6d7f6ea02e17
changeset: 9212:6d7f6ea02e17
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 08 13:50:32 2009 -0400
description:
eacces_error_get*(): Show current directory if path is relative.
diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
src/lib/eacces-error.c | 14 +++++++++++---
diffs (39 lines):
diff -r 219ee9858156 -r 6d7f6ea02e17 src/lib/eacces-error.c
--- a/src/lib/eacces-error.c Tue Jul 07 23:52:06 2009 -0400
+++ b/src/lib/eacces-error.c Wed Jul 08 13:50:32 2009 -0400
@@ -83,17 +83,24 @@ static const char *
static const char *
eacces_error_get_full(const char *func, const char *path, bool creating)
{
- const char *prev_path = path, *dir = "/", *p;
+ const char *prev_path = path, *dir, *p;
const struct passwd *pw;
const struct group *group;
string_t *errmsg;
struct stat st, dir_st;
+ char cwd[PATH_MAX];
int orig_errno, ret = -1;
orig_errno = errno;
errmsg = t_str_new(256);
- str_printfa(errmsg, "%s(%s) failed: Permission denied (euid=%s",
- func, path, dec2str(geteuid()));
+ str_printfa(errmsg, "%s(%s)", func, path);
+ if (*path != '/') {
+ dir = getcwd(cwd, sizeof(cwd));
+ if (dir != NULL)
+ str_printfa(errmsg, " in directory %s", dir);
+ }
+ str_printfa(errmsg, " failed: Permission denied (euid=%s",
+ dec2str(geteuid()));
pw = getpwuid(geteuid());
if (pw != NULL)
@@ -104,6 +111,7 @@ eacces_error_get_full(const char *func,
if (group != NULL)
str_printfa(errmsg, "(%s)", group->gr_name);
+ dir = "/";
while ((p = strrchr(prev_path, '/')) != NULL) {
dir = t_strdup_until(prev_path, p);
ret = stat(dir, &st);
More information about the dovecot-cvs
mailing list