Esempio n. 1
0
 def __call__(self, marks, current):
     try:
         return self.do_auth(marks, current)
     except self._dbh.DBError, e:
         logging.warning("Database exception: %s: %s" %
                         (e.message, e.reason))
         return False
Esempio n. 2
0
 def __init__(self):
     self.__runner = Runner.get()
     self.__server = Server.get()
     if self.__server.startOnLoad():
         try:
             self.__runner.start()
         except RuntimeError, e:
             logging.warning(str(e))
Esempio n. 3
0
 def __init__(self, dbh, groups):
     self._dbh = dbh
     self._groups = self.make_groups(groups)
     if len(groups) != len(self._groups):
         logging.warning("%s of %s groups not found in database "
                         "and will be ignored by ssl verifier" %
                         (len(groups) - len(self._groups), len(groups)))
     ps = '(' + ', '.join(('%s' for x in self._groups)) + ')'
     self._query = _query + ps
Esempio n. 4
0
 def locate(self, current):
     try:
         if self._authorize(self._marks, current):
             return self._obj
     except C.PermissionError:
         raise
     except Exception, e:
         c = current.adapter.getCommunicator()
         logging.warning("Refusing permission because of exception. "
                         "Object: %s. Operation: %s. Exception %s: %s." %
                         (c.identityToString(current.id), current.operation,
                          type(e).__name__, e))
         return None
Esempio n. 5
0
 def wrapper(self, *pargs, **kwargs):
     h = self._dbh
     try:
         return method(self, h.get_connection(), *pargs, **kwargs)
     except h.Error, e:
         if msg:
             message = "Database failure while " + msg
         else:
             message = "Database failure"
         if h.trace > 8:
             logging.warning("FAILED: %s: %s: %s: %s" %
                             (h.options['database'], type(e).__name__,
                              message, e.message))
         raise h.DBError(message, e.message)
Esempio n. 6
0
 def locate(self, current):
     try:
         obj = self.__locator.locate(current)
         marks = getattr(obj, 'marks', None) or auth_marks(obj)
         if self._authorize(marks, current):
             return obj
     except Ice.ObjectNotExistException:
         return None
     except C.PermissionError:
         raise
     except Exception, e:
         c = current.adapter.getCommunicator()
         logging.warning("Refusing permission because of exception. "
                         "Object: %s. Operation: %s. Exception %s: %s." %
                         (c.identityToString(current.id), current.operation,
                          type(e).__name__, e))
         return None
Esempio n. 7
0
def update_module_path():
    #if no value specified yet, append the default
    global path
    if len(path) == 0:
        p = os.path.join(sys.prefix, 'lib', 'Tartarus', 'modules')
        if os.path.isdir(p):
            path.append(p)
        p = os.path.join(sys.prefix, 'lib64', 'Tartarus', 'modules')
        if os.path.isdir(p):
            path.append(p)

    #update module search path
    for p in path:
        if not os.path.isdir(p):
            logging.warning("Module path not found: %s" % p, trace)
            continue
        if p not in Tartarus.__path__:
            Tartarus.__path__.append(p)
Esempio n. 8
0
def load_config(props, cfg_path):
    if len(cfg_path) == 0:
        logging.warning("Tartarus configuration path not specified")
        return
    logging.trace(__name__, "Loading configuration from %s" % cfg_path, trace)
    if not os.path.isdir(cfg_path):
        logging.error("Invalid cfg_path to configuration files: %s" % cfg_path)
        return

    for fi in os.listdir(cfg_path):
        f = os.path.join(cfg_path, fi)
        if not os.path.isfile(f):
            continue
        if not (f.endswith('.conf') or f.endswith('.config')):
            continue
        try:
            props.load(f)
        except Exception:
            logging.error("Failed to load configuration file: %s" % f)