]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
- use fnmatch for privs
authorMichal Moskal <michal@moskal.me>
Wed, 11 Jun 2003 23:56:26 +0000 (23:56 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    PLD_Builder/acl.py -> 1.9

PLD_Builder/acl.py

index 2407141e3c9f8ba452fc13bb0a5a105e813bc814..4e1d8421b1ce8e12db7ff4fa3c84ae6981db9545 100644 (file)
@@ -1,5 +1,6 @@
 import ConfigParser
 import string
+import fnmatch
 
 import path
 import log
@@ -24,22 +25,20 @@ class User:
         if len(l) != 2 or l[0] == "" or l[1] == "":
           log.alert("acl: invalid priv format: '%s' [%s]" % (p, login))
         else:
-          self.privs.append((l[0], l[1]))
+          self.privs.append(p)
     else:
       log.alert("acl: [%s] has no privs" % login)
 
   def can_do(self, what, where):
-    # TODO: use fnmatch
-    for (pwhat, pwhere) in self.privs:
-      if pwhat[0] == "!":
+    action = "%s:%s" % (what, where)
+    for priv in self.privs:
+      if priv[0] == "!":
         ret = 0
-        pwhat = pwhat[1:]
+        priv = priv[1:]
       else:
         ret = 1
-      if pwhat == "*" or pwhat == what:
-        if pwhere == "*" or pwhere == where:
-          return ret
-
+      if fnmatch.fnmatch(action, priv):
+        return ret
     return 0
 
   def mail_to(self):
This page took 0.163503 seconds and 4 git commands to generate.