Changeset 36f642f for fedd/federation/authorizer.py
- Timestamp:
- Sep 16, 2011 5:26:57 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- cbe0570
- Parents:
- 6031c9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/authorizer.py
r6031c9d r36f642f 213 213 self.me = me 214 214 self.save_dir = load or save 215 self.local_files = False 215 216 if self.save_dir: 216 217 self.save_dir = os.path.abspath(self.save_dir) … … 228 229 229 230 self.key, self.me = abac_split_cert(self.me, keyfile, certfile) 231 self.local_files = True 230 232 else: 231 233 raise abac_authorizer.bad_cert_error("Combination " + \ … … 444 446 return rv 445 447 448 def copy_file(self, src, dest, mode=0600): 449 ''' 450 Copy src to dest with file mode mode. May raise exceptions on file ops 451 ''' 452 d = open(dest, 'w') 453 s = open(src, 'r') 454 d.write(s.read()) 455 s.close() 456 d.close() 457 os.chmod(dest, mode) 458 459 460 446 461 def save(self, dir=None): 447 462 self.lock.acquire() … … 457 472 os.mkdir(dir) 458 473 474 # if self.key and self.me were split, copy the split files into the 475 # new directory. 476 if self.local_files: 477 self.copy_file(self.key, '%s/key.pem' % dir) 478 self.copy_file(self.me, '%s/cert.pem' % dir) 479 # Point the key and me members to the new locations for 480 # pickling 481 hold_key = self.key 482 hold_me = self.me 483 self.key = '%s/key.pem' % dir 484 self.me = '%s/cert.pem' % dir 485 459 486 f = open("%s/state" % dir, "w") 460 487 pickle.dump(self, f) 461 488 f.close() 489 490 if self.local_files: 491 self.key = hold_key 492 self.me = hold_me 462 493 463 494 if not os.access("%s/certs" %dir, os.F_OK):
Note: See TracChangeset
for help on using the changeset viewer.