Changeset e062282 for fedd/federation


Ignore:
Timestamp:
Jul 7, 2012 5:42:28 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, master
Children:
7718539
Parents:
cd5b279 (diff), d064566 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of tardis.deterlab.net:/var/local/git/fedd

Location:
fedd/federation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/authorizer.py

    rcd5b279 re062282  
    2121import os, os.path
    2222import re
     23import fcntl
    2324
    2425class authorizer_base:
     
    208209    class bad_cert_error(RuntimeError): pass
    209210
    210     def __init__(self, certs=None, me=None, key=None, load=None, save=None):
     211    def __init__(self, certs=None, me=None, key=None, load=None, save=None,
     212            update=None):
    211213        self.creddy_id = None
    212214        self.globals = set()
     
    215217        self.save_dir = load or save
    216218        self.local_files = False
     219        self.update_dir = os.path.abspath(update)
    217220        if self.save_dir:
    218221            self.save_dir = os.path.abspath(self.save_dir)
     
    648651        return found
    649652
     653    def update(self):
     654        rv = False
     655        if update_dir is None: return True
     656        lf = None
     657        files = []
     658        try:
     659            lf = open('%s/lock' % self.update_dir, 'r')
     660        except EnvironmentError, e:
     661            return rv
     662        try:
     663            fcntl.flock(lf, fcntl.LOCK_EX)
     664            files = os.listdir(update_dir)
     665            rv = self.import_credentials(file_list=files)
     666            try:
     667                for fn in files:
     668                    os.remove(fn)
     669            except EnvironmentError, e:
     670                # failure to clear the update directory is no biggie
     671                pass
     672            rv = True
     673        finally:
     674            fcntl.flock(fl, fcntl.LOCK_UN)
     675        return rv
     676
     677           
     678       
     679
    650680    def __str__(self):
    651681
  • fedd/federation/client_lib.py

    rd064566 re062282  
    5959def log_authentication(fn, action, outcome, proof):
    6060    f = open(fn, 'a')
    61     print >>f, '%s %s at %s' % (action, outcome, datetime.now())
     61    print >>f, '<comment>%s %s at %s</comment>' % (action, outcome, datetime.now())
    6262    if isinstance(proof, list):
    6363        for p in proof:
  • fedd/federation/proof.py

    rd064566 re062282  
    33
    44import ABAC
     5import Creddy
    56import sys
    67import os, os.path
     
    910from base64 import b64encode, b64decode
    1011from xml.parsers.expat import ParserCreate
     12from tempfile import mkdtemp
     13from shutil import rmtree
    1114
    1215class proof:
     
    2932        ids = set([c.issuer_cert() for c in self.creds])
    3033        attrs = set([c.attribute_cert() for c in self.creds])
    31         return list(ids) + list(attrs)
     34        out_ids = []
     35        d = mkdtemp()
     36        for i, c in enumerate(ids):
     37            try:
     38                der_name = os.path.join(d, 'file%04d.der' % i)
     39                pem_name = os.path.join(d, 'file%04d.pem' % i)
     40                f = open(der_name, 'w')
     41                f.write(c)
     42                f.close()
     43
     44                cid = Creddy.ID(der_name)
     45
     46                tf = open(pem_name, 'w')
     47                cid.write_cert(tf)
     48                tf.close()
     49                tf = open(pem_name, 'r')
     50                out_ids.append(tf.read())
     51                tf.close()
     52            except EnvironmentError, e:
     53                print "Certs to creds Error: %s" % e
     54                pass
     55        rmtree(d)
     56
     57        return out_ids + list(attrs)
    3258
    3359    def __str__(self):
Note: See TracChangeset for help on using the changeset viewer.