aboutsummaryrefslogtreecommitdiff
path: root/src/nse/gnunet-service-nse.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-19 18:43:38 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-19 18:43:38 +0100
commit3636ea628d051cf2ba7a9038c50528c561d0aeaa (patch)
tree87664b904950052e8b6997a371ed5ecb1ea4b310 /src/nse/gnunet-service-nse.c
parent74d7528e6bd53cf5acc939c63a5be74a001e5ce1 (diff)
downloadgnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.tar.gz
gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.zip
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
Diffstat (limited to 'src/nse/gnunet-service-nse.c')
-rw-r--r--src/nse/gnunet-service-nse.c23
1 files changed, 15 insertions, 8 deletions
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,
824 * Write our current proof to disk. 824 * Write our current proof to disk.
825 */ 825 */
826static void 826static void
827write_proof () 827write_proof (void)
828{ 828{
829 char *proof; 829 char *proof;
830 830
831 if (GNUNET_OK != 831 if (GNUNET_OK !=
832 GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) 832 GNUNET_CONFIGURATION_get_value_filename (cfg,
833 "NSE",
834 "PROOFFILE",
835 &proof))
833 return; 836 return;
834 if (sizeof(my_proof) != GNUNET_DISK_fn_write (proof, 837 (void) GNUNET_DISK_directory_remove (proof);
835 &my_proof, 838 if (GNUNET_OK !=
836 sizeof(my_proof), 839 GNUNET_DISK_fn_write (proof,
837 GNUNET_DISK_PERM_USER_READ 840 &my_proof,
838 | GNUNET_DISK_PERM_USER_WRITE)) 841 sizeof(my_proof),
839 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); 842 GNUNET_DISK_PERM_USER_READ
843 | GNUNET_DISK_PERM_USER_WRITE))
844 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
845 "write",
846 proof);
840 GNUNET_free (proof); 847 GNUNET_free (proof);
841} 848}
842 849