[dovecot-cvs] dovecot-1.0: If dovecot-acl file can't be opened because of perm...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 12 02:01:32 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/69ab5669855a
changeset: 5293:69ab5669855a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 12 02:01:27 2007 +0300
description:
If dovecot-acl file can't be opened because of permission problems, treat it
as if no-one has access to the mailbox.

diffstat:

1 file changed, 25 insertions(+), 8 deletions(-)
src/plugins/acl/acl-backend-vfile.c |   33 +++++++++++++++++++++++++--------

diffs (50 lines):

diff -r 9110ef0d8937 -r 69ab5669855a src/plugins/acl/acl-backend-vfile.c
--- a/src/plugins/acl/acl-backend-vfile.c	Mon Jun 11 22:55:13 2007 +0300
+++ b/src/plugins/acl/acl-backend-vfile.c	Tue Jun 12 02:01:27 2007 +0300
@@ -256,6 +256,16 @@ acl_object_vfile_parse_line(struct acl_o
 	return 0;
 }
 
+static void acl_backend_remove_all_access(struct acl_object *aclobj)
+{
+	struct acl_rights rights;
+
+	memset(&rights, 0, sizeof(rights));
+	rights.id_type = ACL_ID_ANYONE;
+	rights.modify_mode = ACL_MODIFY_MODE_REPLACE;
+	acl_cache_update(aclobj->backend->cache, aclobj->name, &rights);
+}
+
 static int
 acl_backend_vfile_read(struct acl_object *aclobj, const char *path,
 		       struct acl_vfile_validity *validity, bool try_retry,
@@ -275,14 +285,21 @@ acl_backend_vfile_read(struct acl_object
 		if (errno == ENOENT) {
 			if (aclobj->backend->debug)
 				i_info("acl vfile: file %s not found", path);
-
-			validity->last_size = 0;
-			validity->last_mtime = 0;
-			validity->last_read_time = ioloop_time;
-			return 1;
-		}
-		mail_storage_set_critical(storage, "open(%s) failed: %m", path);
-		return -1;
+		} else if (errno == EACCES) {
+			if (aclobj->backend->debug)
+				i_info("acl vfile: no access to file %s", path);
+
+			acl_backend_remove_all_access(aclobj);
+		} else {
+			mail_storage_set_critical(storage,
+						  "open(%s) failed: %m", path);
+			return -1;
+		}
+
+		validity->last_size = 0;
+		validity->last_mtime = 0;
+		validity->last_read_time = ioloop_time;
+		return 1;
 	}
 
 	if (fstat(fd, &st) < 0) {


More information about the dovecot-cvs mailing list