aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-31 09:12:43 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-31 09:12:43 +0100
commitebd853c83ce0f03fa59d1672b86190406659d901 (patch)
tree4ae6c29cafbb6615961d9a4b79d235f3270d24a7
parent1f489833705ee9fc66686ed3045cc5dba56dfd39 (diff)
downloadgnunet-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
-rw-r--r--debian/gnunet.postrm14
-rw-r--r--src/util/configuration.c48
2 files changed, 41 insertions, 21 deletions
diff --git a/debian/gnunet.postrm b/debian/gnunet.postrm
index 0aba484db..2c3887202 100644
--- a/debian/gnunet.postrm
+++ b/debian/gnunet.postrm
@@ -33,10 +33,6 @@ remove_gns() {
33 } 33 }
34 s/^(hosts:)(.*)/$1.remove($2)/e; 34 s/^(hosts:)(.*)/$1.remove($2)/e;
35 ' /etc/nsswitch.conf 35 ' /etc/nsswitch.conf
36 # remove the gns nsswitch plugins as well
37 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
38 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
39 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
40} 36}
41 37
42 38
@@ -81,11 +77,19 @@ case "${1}" in
81 delgroup --quiet --system --only-if-empty ${GNUNETDNS_GROUP} || true 77 delgroup --quiet --system --only-if-empty ${GNUNETDNS_GROUP} || true
82 fi 78 fi
83 79
84 rm -rf /var/log/gnunetd /var/lib/gnunet /etc/default/gnunet 80 rm -rf /var/log/gnunet.log /var/lib/gnunet /etc/default/gnunet
85 ;; 81 ;;
86 82
87 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 83 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
88 84
85 if $_LIBNSSWITCH
86 then
87 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
88 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
89 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
90 remove_gns
91 fi
92
89 ;; 93 ;;
90 94
91 *) 95 *)
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);