]> git.plutz.net Git - shellwiki/blobdiff - acl.sh
allow attachment revisioning
[shellwiki] / acl.sh
diff --git a/acl.sh b/acl.sh
index 9ec2597dc40eeac263f7bccbd49a0b297e3252b6..0ba66631d40c6709e1b59ee2e41f6dfde4167cc0 100755 (executable)
--- a/acl.sh
+++ b/acl.sh
@@ -1,7 +1,10 @@
 #!/bin/sh
 
+[ "$include_acl" ] && return 0
+include_acl="$0"
+
 # 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 +37,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;
+
+      :ACL
+      s;(%(acl)?)?[\t ]*;;
+      p; n; s;\r$;;;
+      /^(%[ \t]+|%acl[ \t]+|[ \t]+)[^ \t\r]+$/bACL;
+      /^(%[ \t]*|%acl[ \t]*)$/bACL;
+    ' <"$pagefile")"
 
-      n="$((n - 1))"
-      [ "$n" -eq 0 ] && break
-    done <"$pagefile"
+    printf %s\\n "${acl}"
+    acl_collection="${acl_collection}${acl}${BR}"
   done
 
   printf '%s\n' "$ACL_DEFAULT"
@@ -64,10 +72,10 @@ acl_read(){
        "Known:")     return 1;;
       "+Known:read") return 0;;
       "-Known:read") return 1;;
-       "${USER_NAME}:read") return 0;;
-       "${USER_NAME}:")      return 1;;
-      "+{$USER_NAME}:read") return 0;;
-      "-{$USER_NAME}:read") return 1;;
+       "@${USER_NAME}:read") return 0;;
+       "@${USER_NAME}:")      return 1;;
+      "+@{$USER_NAME}:read") return 0;;
+      "-@{$USER_NAME}:read") return 1;;
     esac
     case $acl in
        "All:read") return 0;;
@@ -96,10 +104,10 @@ acl_write(){
        "Known:")      return 1;;
       "+Known:write") return 0;;
       "-Known:write") return 1;;
-       "${USER_NAME}:write") return 0;;
-       "${USER_NAME}:")      return 1;;
-      "+{$USER_NAME}:write") return 0;;
-      "-{$USER_NAME}:write") return 1;;
+       "@${USER_NAME}:write") return 0;;
+       "@${USER_NAME}:")      return 1;;
+      "+@{$USER_NAME}:write") return 0;;
+      "-@{$USER_NAME}:write") return 1;;
     esac
     case $acl in
        "All:write") return 0;;