From 3636ea628d051cf2ba7a9038c50528c561d0aeaa Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 19 Dec 2020 18:43:38 +0100 Subject: change GNUNET_DISK_fn_write() to always do atomic writes and to NOT overwrite existing files; also change the return value to not return the size of the written file but GNUNET_OK on success, and integrate creating the directory if needed; breaks API, hence bumping libgnunetutil version --- src/nse/gnunet-service-nse.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/nse') diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index dfd71e57a..8e9cd0c9d 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -824,19 +824,26 @@ check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, * Write our current proof to disk. */ static void -write_proof () +write_proof (void) { char *proof; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) + GNUNET_CONFIGURATION_get_value_filename (cfg, + "NSE", + "PROOFFILE", + &proof)) return; - if (sizeof(my_proof) != GNUNET_DISK_fn_write (proof, - &my_proof, - sizeof(my_proof), - GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); + (void) GNUNET_DISK_directory_remove (proof); + if (GNUNET_OK != + GNUNET_DISK_fn_write (proof, + &my_proof, + sizeof(my_proof), + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, + "write", + proof); GNUNET_free (proof); } -- cgit v1.2.3