summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Varshavchik2022-01-23 20:19:38 -0500
committerSam Varshavchik2022-01-23 20:40:21 -0500
commit2c4bd3a01369b74b82fba90a3c855093590ddacc (patch)
treeeb9a27e265194792810035891b91faffba8cb396
parent956c3df8c0ba7d18a1e8c402b44a7669cde07458 (diff)
downloadcourier-libs-2c4bd3a01369b74b82fba90a3c855093590ddacc.tar.bz2
Adjust behavior of inherited ACLs, add more tests.
If ACLs were saved in the courierimaphieracl subdirectory, move it into the corresponding folder when it gets created, at the first opportunity. Add additional tests.
-rw-r--r--imap/ChangeLog7
-rw-r--r--maildir/Makefile.am2
-rw-r--r--maildir/maildiracl.c7
-rw-r--r--maildir/maildiraclt.c16
-rw-r--r--maildir/testsuite10
-rw-r--r--maildir/testsuite.txt10
6 files changed, 46 insertions, 6 deletions
diff --git a/imap/ChangeLog b/imap/ChangeLog
index f2df56d..687ce8e 100644
--- a/imap/ChangeLog
+++ b/imap/ChangeLog
@@ -1,3 +1,10 @@
+2022-01-23 Sam Varshavchik <mrsam@courier-mta.com>
+
+ * Adjust behavior of inherited ACLs. After deleting and recreating
+ a folder, have the recreated folder inherit its parent folder's ACLs,
+ normally, instead of mysteriously restoring whatever ACLs the folder
+ had when it was deleted.
+
2022-01-22 Sam Varshavchik <mrsam@courier-mta.com>
* Fixes to Makefile to workaround test suite failures related to
diff --git a/maildir/Makefile.am b/maildir/Makefile.am
index d619fb3..bd4dadc 100644
--- a/maildir/Makefile.am
+++ b/maildir/Makefile.am
@@ -144,7 +144,7 @@ clean-local:
rm -rf testmd
check-am:
- unset VALGRIND; @SHELL@ $(srcdir)/testsuite 2>&1 | cmp - $(srcdir)/testsuite.txt
+ unset VALGRIND; @SHELL@ $(srcdir)/testsuite 2>&1 | diff -U 3 $(srcdir)/testsuite.txt -
test "@PCRE_LDFLAGS@" != "" || exit 0 ; @SHELL@ $(srcdir)/testsuite2 2>&1 | cmp - $(srcdir)/testsuite2.txt
LC_ALL=C; export LC_ALL; ./maildirkwtest | cmp -s - $(srcdir)/maildirkwtest.txt
LC_ALL=C; export LC_ALL; ./maildiraclttest
diff --git a/maildir/maildiracl.c b/maildir/maildiracl.c
index 4726893..a8b6b16 100644
--- a/maildir/maildiracl.c
+++ b/maildir/maildiracl.c
@@ -194,6 +194,9 @@ int main(int argc, char *argv[])
else perror(maildir);
exit(1);
}
+
+ maildir_aclt_list_destroy(&l);
+ maildir_aclt_destroy(&a);
}
if (strcmp(cmd, deletecmd) == 0)
@@ -232,6 +235,8 @@ int main(int argc, char *argv[])
else perror(maildir);
exit(1);
}
+
+ maildir_aclt_list_destroy(&l);
}
if (strcmp(cmd, computecmd) == 0)
@@ -260,6 +265,8 @@ int main(int argc, char *argv[])
}
printf("%s\n", maildir_aclt_ascstr(&a));
+
+ maildir_aclt_list_destroy(&l);
}
return (0);
diff --git a/maildir/maildiraclt.c b/maildir/maildiraclt.c
index d4b0966..f02443a 100644
--- a/maildir/maildiraclt.c
+++ b/maildir/maildiraclt.c
@@ -441,12 +441,14 @@ static int maildir_acl_read_check(maildir_aclt_list *aclt_list,
}
fp=fopen(strcat(strcpy(q, p), "/" ACLFILE), "r");
free(p);
- free(q);
if (fp == NULL)
{
+ char *r;
+
if (strcmp(path, ".") == 0)
{
+ free(q);
/* INBOX ACL default */
if (maildir_aclt_list_add(aclt_list, "owner",
@@ -458,17 +460,21 @@ static int maildir_acl_read_check(maildir_aclt_list *aclt_list,
return 0;
}
- q=malloc(strlen(maildir)+sizeof("/" ACLHIERDIR "/") +
+ r=malloc(strlen(maildir)+sizeof("/" ACLHIERDIR "/") +
strlen(path));
- if (!q)
+ if (!r)
return -1;
- strcat(strcat(strcpy(q, maildir), "/" ACLHIERDIR "/"),
+ strcat(strcat(strcpy(r, maildir), "/" ACLHIERDIR "/"),
path+1);
+ rename(r, q);
fp=fopen(q, "r");
- free(q);
+ if (!fp)
+ fp=fopen(r, "r");
+ free(r);
}
+ free(q);
if (!fp && errno != ENOENT)
return -1;
diff --git a/maildir/testsuite b/maildir/testsuite
index d6e5d91..71b9fe2 100644
--- a/maildir/testsuite
+++ b/maildir/testsuite
@@ -39,3 +39,13 @@ $VALGRIND ./maildirkw -r md one Label1
echo ""
$VALGRIND ./maildirkw -L md | sort
rm -rf md testmd
+
+maildirmake ./testmd
+
+$VALGRIND ./maildiracl -set testmd INBOX.Folder user1 rw
+$VALGRIND ./maildiracl -list testmd INBOX.Folder | sort
+$VALGRIND ./maildiracl -list testmd INBOX.Folder.Subfolder | sort
+$VALGRIND ./maildirmake -f Folder testmd
+$VALGRIND ./maildiracl -list testmd INBOX.Folder | sort
+ls testmd/courierimaphieracl
+rm -rf testmd
diff --git a/maildir/testsuite.txt b/maildir/testsuite.txt
index 9f70b7f..ed34d92 100644
--- a/maildir/testsuite.txt
+++ b/maildir/testsuite.txt
@@ -28,3 +28,13 @@ two Label1 Label2
one
three Label3 Label4
two Label1 Label2
+administrators aceilrstwx
+owner aceilrstwx
+user1 rw
+administrators aceilrstwx
+owner aceilrstwx
+user1 rw
+administrators aceilrstwx
+owner aceilrstwx
+user1 rw
+Folder.Subfolder