Ignore:
Timestamp:
Jul 8, 2012 7:42:35 AM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, master
Children:
b15ecc6
Parents:
b931822
Message:

Correct updating

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/authorizer.py

    rb931822 r2c36179  
    201201    """
    202202
    203     clean_attr_re = re.compile('[^A-Za-z0-9_]+')
     203    clean_attr_re = re.compile('[^A-Za-z0-9_:]+')
    204204    clean_prefix_attr_re = re.compile('^_+')
    205205    cred_file_re = re.compile('.*\.der$')
     
    657657    def update(self):
    658658        rv = False
    659         if update_dir is None: return True
     659        if self.update_dir is None or not os.path.isdir(self.update_dir):
     660            return True
    660661        lf = None
    661662        files = []
    662663        try:
    663             lf = open('%s/lock' % self.update_dir, 'r')
     664            lf = open('%s/lock' % self.update_dir, 'w')
    664665        except EnvironmentError, e:
    665666            return rv
    666667        try:
    667668            fcntl.flock(lf, fcntl.LOCK_EX)
    668             files = os.listdir(update_dir)
     669            files = [os.path.join(self.update_dir, fn) \
     670                    for fn in os.listdir(self.update_dir) \
     671                        if fn != 'lock']
    669672            rv = self.import_credentials(file_list=files)
    670673            try:
     
    676679            rv = True
    677680        finally:
    678             fcntl.flock(fl, fcntl.LOCK_UN)
     681            fcntl.flock(lf, fcntl.LOCK_UN)
    679682        return rv
    680683
Note: See TracChangeset for help on using the changeset viewer.