=== modified file 'TODO' --- TODO 2011-12-21 00:33:12 +0000 +++ TODO 2011-12-23 18:59:19 +0000 @@ -45,7 +45,6 @@ * mandos (server) ** TODO Document why we ignore sigint ** TODO [#B] Log level :BUGS: -** TODO [#A] Save state to new file and move instead of overwrite *** TODO /etc/mandos/clients.d/*.conf Watch this directory and add/remove/update clients? ** TODO [#C] config for TXT record === modified file 'mandos' --- mandos 2011-12-23 18:12:16 +0000 +++ mandos 2011-12-23 18:59:19 +0000 @@ -2405,12 +2405,13 @@ del client_settings[client.name]["secret"] try: - with os.fdopen(os.open(stored_state_path, - (os.O_CREAT | os.O_WRONLY - | os.O_TRUNC | os.O_EXCL), - (stat.S_IREAD | stat.S_IWRITE)), - "wb") as stored_state: + tempfd, tempname = tempfile.mkstemp(suffix=".pickle", + prefix="clients-", + dir=os.path.dirname + (stored_state_path)) + with os.fdopen(tempfd, "wb") as stored_state: pickle.dump((clients, client_settings), stored_state) + os.rename(tempname, stored_state_path) except (IOError, OSError) as e: logger.warning("Could not save persistent state: {0}" .format(e))