Split main.py in four.
[invirt/packages/invirt-web.git] / templates / getafsgroups.py
index c98f708..2086ccb 100644 (file)
@@ -39,7 +39,10 @@ def checkAfsGroup(user, group, cell):
 
 def checkLockerOwner(user, locker, verbose=False):
     """
-    checkLockerOwner(user, locker) returns True if and only if user administers locker
+    checkLockerOwner(user, locker) returns True if and only if user administers locker.
+
+    If verbose is true, instead return the reason for failure, or None
+    if there is no failure.
     """
     p = subprocess.Popen(["fs", "whichcell", "/mit/" + locker], 
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -61,6 +64,8 @@ def checkLockerOwner(user, locker, verbose=False):
         if entry[1] == "rlidwka":
             if entry[0] == user or (entry[0][0:6] == "system" and 
                                     checkAfsGroup(user, entry[0], cell)):
+                if verbose:
+                    return None
                 return True
     if verbose:
         return "You don't have admin bits on /mit/" + locker