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

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


details:   http://hg.dovecot.org/dovecot/rev/49412bd6b931
changeset: 5694:49412bd6b931
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 12 02:01:28 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, 24 insertions(+), 8 deletions(-)
src/plugins/acl/acl-backend-vfile.c |   32 ++++++++++++++++++++++++--------

diffs (49 lines):

diff -r 5845fccd55da -r 49412bd6b931 src/plugins/acl/acl-backend-vfile.c
--- 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 @@ acl_object_vfile_parse_line(struct acl_o
 	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 @@ acl_backend_vfile_read(struct acl_object
 		if (errno == ENOENT) {
 			if (aclobj->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;
-		}
-		i_error("open(%s) failed: %m", path);
-		return -1;
+		} else if (errno == EACCES) {
+			if (aclobj->aclobj.backend->debug)
+				i_info("acl vfile: no access to file %s", path);
+
+			acl_backend_remove_all_access(&aclobj->aclobj);
+		} else {
+			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) {


More information about the dovecot-cvs mailing list