- Timestamp:
- Dec 10, 2010 10:28:52 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- f4f036f
- Parents:
- ddf0903
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/authorizer.py
rddf0903 r8cf2c507 223 223 if rv != 0: 224 224 raise abac_authorizer.bad_name( 225 'Cannot load identity from %s' % me .cert)225 'Cannot load identity from %s' % me) 226 226 else: 227 227 self.fedid = None … … 235 235 if load: 236 236 self.load(load) 237 238 # Modify the pickling operations so that the context and lock are not 239 # pickled 240 241 def __getstate__(self): 242 d = self.__dict__.copy() 243 del d['lock'] 244 del d['context'] 245 return d 246 247 def __setstate__(self, d): 248 # Import everything from the pickle dict (except what we excluded in 249 # __getstate__) 250 self.__dict__.update(d) 251 # Initialize the unpicklables 252 self.context = ABAC.Context() 253 self.lock = Lock() 237 254 238 255 @staticmethod … … 421 438 if not os.access(dir, os.F_OK): 422 439 os.mkdir(dir) 423 # These are unpicklable, so set them aside424 context = self.context425 lock = self.lock426 self.context = None427 self.lock = None428 440 429 441 f = open("%s/state" % dir, "w") … … 433 445 if not os.access("%s/certs" %dir, os.F_OK): 434 446 os.mkdir("%s/certs" % dir) 435 seenid = set() 436 seenattr = set() 437 438 #restore unpicklable state 439 self.context = context 440 self.lock = lock 441 #remove old certs 447 448 # Clear the certs subdir 442 449 for fn in [ f for f in os.listdir("%s/certs" % dir) \ 443 450 if abac_authorizer.cred_file_re.match(f)]: 444 451 os.unlink('%s/certs/%s' % (dir, fn)) 452 453 # Save the context 445 454 ii = 0 446 455 ai = 0 456 seenid = set() 457 seenattr = set() 447 458 for c in self.context.credentials(): 448 459 id = c.issuer_cert() … … 463 474 seenattr.add(attr) 464 475 except EnvironmentError, e: 465 # If we've mislaid self.lock, release lock (they're the same object) 466 if self.lock: self.lock.release() 467 elif lock: lock.release() 476 self.lock.release() 468 477 raise e 469 478 except pickle.PickleError, e: 470 # If we've mislaid self.lock, release lock (they're the same object) 471 if self.lock: self.lock.release() 472 elif lock: lock.release() 479 self.lock.release() 473 480 raise e 474 481 self.lock.release()
Note: See TracChangeset
for help on using the changeset viewer.