/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2011-12-23 18:12:16 UTC
  • mto: (237.7.76 trunk)
  • mto: This revision was merged to the branch mainline in revision 290.
  • Revision ID: teddy@recompile.se-20111223181216-hejy3ig08wzyngpi
* mandos (main/cleanup): Use O_EXCL when creating saved state file;
                         abort if file already exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2406
2406
        
2407
2407
        try:
2408
2408
            with os.fdopen(os.open(stored_state_path,
2409
 
                                   os.O_CREAT|os.O_WRONLY|os.O_TRUNC,
2410
 
                                   0600), "wb") as stored_state:
 
2409
                                   (os.O_CREAT | os.O_WRONLY
 
2410
                                    | os.O_TRUNC | os.O_EXCL),
 
2411
                                   (stat.S_IREAD | stat.S_IWRITE)),
 
2412
                           "wb") as stored_state:
2411
2413
                pickle.dump((clients, client_settings), stored_state)
2412
2414
        except (IOError, OSError) as e:
2413
2415
            logger.warning("Could not save persistent state: {0}"
2414
2416
                           .format(e))
2415
 
            if e.errno not in (errno.ENOENT, errno.EACCES):
 
2417
            if e.errno not in set((errno.ENOENT, errno.EACCES,
 
2418
                                   errno.EEXIST)):
2416
2419
                raise
2417
2420
        
2418
2421
        # Delete all clients, and settings from config