diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-12-31 09:12:43 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-12-31 09:12:43 +0100 |
commit | ebd853c83ce0f03fa59d1672b86190406659d901 (patch) | |
tree | 4ae6c29cafbb6615961d9a4b79d235f3270d24a7 /src/util/configuration.c | |
parent | 1f489833705ee9fc66686ed3045cc5dba56dfd39 (diff) | |
download | gnunet-ebd853c83ce0f03fa59d1672b86190406659d901.tar.gz gnunet-ebd853c83ce0f03fa59d1672b86190406659d901.zip |
do not use atomic write for configuration file, we may not have permissions to do this, also should not be necessary
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r-- | src/util/configuration.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index ecdcb3d53..23e6ced98 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -543,23 +543,39 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
543 | } | 543 | } |
544 | cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, | 544 | cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, |
545 | &size); | 545 | &size); |
546 | (void) GNUNET_DISK_directory_remove (fn); | ||
547 | if (GNUNET_OK != | ||
548 | GNUNET_DISK_fn_write (fn, | ||
549 | cfg_buf, | ||
550 | size, | ||
551 | GNUNET_DISK_PERM_USER_READ | ||
552 | | GNUNET_DISK_PERM_USER_WRITE | ||
553 | | GNUNET_DISK_PERM_GROUP_READ | ||
554 | | GNUNET_DISK_PERM_GROUP_WRITE)) | ||
555 | { | 546 | { |
556 | GNUNET_free (fn); | 547 | struct GNUNET_DISK_FileHandle *h; |
557 | GNUNET_free (cfg_buf); | 548 | |
558 | LOG (GNUNET_ERROR_TYPE_WARNING, | 549 | h = GNUNET_DISK_file_open (fn, |
559 | "Writing configuration to file `%s' failed\n", | 550 | GNUNET_DISK_OPEN_WRITE |
560 | filename); | 551 | | GNUNET_DISK_OPEN_TRUNCATE |
561 | cfg->dirty = GNUNET_SYSERR; /* last write failed */ | 552 | | GNUNET_DISK_OPEN_CREATE, |
562 | return GNUNET_SYSERR; | 553 | GNUNET_DISK_PERM_USER_READ |
554 | | GNUNET_DISK_PERM_USER_WRITE | ||
555 | | GNUNET_DISK_PERM_GROUP_READ | ||
556 | | GNUNET_DISK_PERM_GROUP_WRITE); | ||
557 | if (NULL == h) | ||
558 | { | ||
559 | GNUNET_free (fn); | ||
560 | return GNUNET_SYSERR; | ||
561 | } | ||
562 | if (((ssize_t) size) != | ||
563 | GNUNET_DISK_file_write (h, | ||
564 | cfg_buf, | ||
565 | size)) | ||
566 | { | ||
567 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
568 | "write", | ||
569 | fn); | ||
570 | GNUNET_DISK_file_close (h); | ||
571 | (void) GNUNET_DISK_directory_remove (fn); | ||
572 | GNUNET_free (fn); | ||
573 | GNUNET_free (cfg_buf); | ||
574 | cfg->dirty = GNUNET_SYSERR; /* last write failed */ | ||
575 | return GNUNET_SYSERR; | ||
576 | } | ||
577 | GNUNET_assert (GNUNET_OK == | ||
578 | GNUNET_DISK_file_close (h)); | ||
563 | } | 579 | } |
564 | GNUNET_free (fn); | 580 | GNUNET_free (fn); |
565 | GNUNET_free (cfg_buf); | 581 | GNUNET_free (cfg_buf); |