"Fossies" - the Fresh Open Source Software Archive

Member "svnchecker-0.3/checks/AccessRights.py" (12 Mar 2008, 1522 Bytes) of package /linux/privat/old/svnchecker-0.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "AccessRights.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2008 German Aerospace Center (DLR)
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License");
    4 # you may not use this file except in compliance with the License.
    5 # You may obtain a copy of the License at
    6 #
    7 #     http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS,
   11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12 # See the License for the specific language governing permissions and
   13 # limitations under the License.
   14 
   15 """ Check access rights on files. """
   16 
   17 def run(transaction, config):
   18 
   19     rules = config.getArray("AccessRights.Rules")
   20     failure = []
   21     
   22     for rule in rules:
   23 
   24         check = config.getArray("AccessRights.%s.CheckFiles" % rule, [".*"])
   25         ignore = config.getArray("AccessRights.%s.IgnoreFiles" % rule, [])
   26         files = transaction.getFiles(check, ignore)
   27     
   28         allows = config.getArray("AccessRights.%s.AllowUsers" % rule, [])
   29         denies = config.getArray("AccessRights.%s.DenyUsers" % rule, [])
   30 
   31         for filename in files.keys():
   32             if allows and transaction.getUserID() not in allows:
   33                 failure.append(filename)
   34             if denies and transaction.getUserID() in denies:
   35                 failure.append(filename)
   36   
   37     if failure:
   38         msg = "You don't have rights to edit these files: \n"
   39         msg += "\n".join(failure)
   40         return (msg, 1)
   41 
   42     return ("", 0)