changeset 5694:49412bd6b931 HEAD

If dovecot-acl file can't be opened because of permission problems, treat it as if no-one has access to the mailbox.
author Timo Sirainen <tss@iki.fi>
date Tue, 12 Jun 2007 02:01:28 +0300
parents 5845fccd55da
children 54c7e74ec973
files src/plugins/acl/acl-backend-vfile.c
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/acl/acl-backend-vfile.c	Mon Jun 11 22:55:12 2007 +0300
+++ b/src/plugins/acl/acl-backend-vfile.c	Tue Jun 12 02:01:28 2007 +0300
@@ -277,6 +277,16 @@
 	return 0;
 }
 
+static void acl_backend_remove_all_access(struct acl_object *aclobj)
+{
+	struct acl_rights_update rights;
+
+	memset(&rights, 0, sizeof(rights));
+	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_vfile *aclobj, const char *path,
 		       struct acl_vfile_validity *validity, bool try_retry,
@@ -295,14 +305,20 @@
 		if (errno == ENOENT) {
 			if (aclobj->aclobj.backend->debug)
 				i_info("acl vfile: file %s not found", path);
+		} else if (errno == EACCES) {
+			if (aclobj->aclobj.backend->debug)
+				i_info("acl vfile: no access to file %s", path);
 
-			validity->last_size = 0;
-			validity->last_mtime = 0;
-			validity->last_read_time = ioloop_time;
-			return 1;
+			acl_backend_remove_all_access(&aclobj->aclobj);
+		} else {
+			i_error("open(%s) failed: %m", path);
+			return -1;
 		}
-		i_error("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) {