]> err.no Git - pwstore/commitdiff
Fix up GROUP_PATTERN support so it allows multiple access items on a line
authorTollef Fog Heen <tfheen@err.no>
Mon, 29 Jul 2013 09:16:56 +0000 (11:16 +0200)
committerTollef Fog Heen <tfheen@err.no>
Mon, 29 Jul 2013 09:16:56 +0000 (11:16 +0200)
pws

diff --git a/pws b/pws
index 1d222cb0508bed545e039b9ca4ccf664c1f783f1..7be90b436cc1598de75779d5148963bc74559203 100755 (executable)
--- a/pws
+++ b/pws
@@ -32,6 +32,7 @@ Thread.abort_on_exception = true
 
 GNUPG = "/usr/bin/gpg"
 GROUP_PATTERN = "@[a-zA-Z0-9-]+"
+USER_PATTERN = "[a-zA-Z0-9:-]+"
 $program_name = File.basename($0, '.*')
 
 $editor = ENV['EDITOR']
@@ -289,7 +290,7 @@ class GroupConfig
       lno = lno+1
       next if line =~ /^$/
       next if line =~ /^#/
-      if (m = /^([a-zA-Z0-9:-]+)\s*=\s*([0-9A-Fa-f]{40})\s*$/.match line)
+      if (m = /^(#{USER_PATTERN})\s*=\s*([0-9A-Fa-f]{40})\s*$/.match line)
         user = m[1]
         fpr = m[2]
         if @users.has_key?(user)
@@ -414,7 +415,7 @@ class EncryptedFile
       if /^#/.match line
         next
       end
-      m = /^access: "?(#{GROUP_PATTERN})"?/.match line
+      m = /^access: "?((?:(?:#{GROUP_PATTERN}|#{USER_PATTERN}),?\s*)+)"?/.match line
       return [] unless m
       return m[1].strip.split(/[\t ,]+/)
     end