]> git.plutz.net Git - shellwiki/commitdiff
acl detection in updated meta blocks
authorPaul Hänsch <paul@plutz.net>
Tue, 17 May 2022 23:22:15 +0000 (01:22 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 17 May 2022 23:22:15 +0000 (01:22 +0200)
acl.sh

diff --git a/acl.sh b/acl.sh
index 74fc8dc38419f9c556ff98e3882631ca709f6d8b..d232ea0138d4f5614ef4c61fc7d97548c0e85d4b 100755 (executable)
--- a/acl.sh
+++ b/acl.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # ACL_OVERRIDE="${ACL_OVERRIDE:-Admin:read,write}"
-ACL_DEFAULT="${ACL_DEFAULT:-All:read${BR}Known:read,write}"
+ACL_DEFAULT="${ACL_DEFAULT:-Known:read,write${BR}All:read}"
 
 acl_cachepath=''
 acl_collection=''
@@ -34,16 +34,21 @@ acl_collect(){
       continue
     fi
 
-    n=20; while read -r head acl; do
-      if [ "$head" = "%acl" ]; then
-        acl_collection="${acl%${CR}}${BR}"
-        printf "%s\n" "${acl%${CR}}"
-        n=$((n+1))
-      fi
+    acl="$(sed -En '
+      s;\r$;;;
+      /^%acl([\t ]+.*)?$/bACL;
+      20q;
+      b;
 
-      n="$((n - 1))"
-      [ "$n" -eq 0 ] && break
-    done <"$pagefile"
+      :ACL
+      s;(%(acl)?)?[\t ]*;;
+      p; n; s;\r$;;;
+      /^(%[ \t]+|%acl[ \t]+|[ \t]+)[^ \t\r]+$/bACL;
+      /^(%[ \t]*|%acl[ \t]*)$/bACL;
+    ' <"$pagefile")"
+
+    printf %s\\n "${acl}"
+    acl_collection="${acl_collection}${acl}${BR}"
   done
 
   printf '%s\n' "$ACL_DEFAULT"