changeset 19516:c986b91115d7

lib-dict: Improve EACCES error logging for dict-file.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 16 Dec 2015 11:29:36 +0200
parents 74b03ecb79fd
children d2ffe96b5286
files src/lib-dict/dict-file.c
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict-file.c	Tue Dec 15 17:32:09 2015 +0200
+++ b/src/lib-dict/dict-file.c	Wed Dec 16 11:29:36 2015 +0200
@@ -7,6 +7,7 @@
 #include "strescape.h"
 #include "home-expand.h"
 #include "mkdir-parents.h"
+#include "eacces-error.h"
 #include "file-lock.h"
 #include "file-dotlock.h"
 #include "nfs-workarounds.h"
@@ -153,7 +154,10 @@
 	if (dict->fd == -1) {
 		if (errno == ENOENT)
 			return 0;
-		i_error("open(%s) failed: %m", dict->path);
+		if (errno == EACCES)
+			i_error("%s", eacces_error_get("open", dict->path));
+		else
+			i_error("open(%s) failed: %m", dict->path);
 		return -1;
 	}
 	dict->refreshed = FALSE;
@@ -445,7 +449,10 @@
 	path = t_strdup_until(dict->path, p);
 
 	if (stat_first_parent(path, &root, &st) < 0) {
-		i_error("stat(%s) failed: %m", root);
+		if (errno == EACCES)
+			i_error("%s", eacces_error_get("stat", root));
+		else
+			i_error("stat(%s) failed: %m", root);
 		return -1;
 	}
 	if ((st.st_mode & S_ISGID) != 0) {
@@ -454,7 +461,10 @@
 	}
 
 	if (mkdir_parents(path, mode) < 0 && errno != EEXIST) {
-		i_error("mkdir_parents(%s) failed: %m", path);
+		if (errno == EACCES)
+			i_error("%s", eacces_error_get("mkdir_parents", path));
+		else
+			i_error("mkdir_parents(%s) failed: %m", path);
 		return -1;
 	}
 	return 0;
@@ -477,7 +487,10 @@
 			dict->fd = open(dict->path, O_CREAT | O_RDWR, 0600);
 		}
 		if (dict->fd == -1) {
-			i_error("creat(%s) failed: %m", dict->path);
+			if (errno == EACCES)
+				i_error("%s", eacces_error_get("creat", dict->path));
+			else
+				i_error("creat(%s) failed: %m", dict->path);
 			return -1;
 		}
 		(void)fd_copy_parent_dir_permissions(dict->path, dict->fd,