aboutsummaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/hs/hs_service.c2
-rw-r--r--src/feature/relay/router.c17
-rw-r--r--src/feature/rend/rendservice.c2
3 files changed, 8 insertions, 13 deletions
diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c
index b56b7f4368..3e264b4686 100644
--- a/src/feature/hs/hs_service.c
+++ b/src/feature/hs/hs_service.c
@@ -990,7 +990,7 @@ write_address_to_file(const hs_service_t *service, const char *fname_)
tor_asprintf(&addr_buf, "%s.%s\n", service->onion_address, address_tld);
/* Notice here that we use the given "fname_". */
fname = hs_path_from_filename(service->config.directory_path, fname_);
- if (write_str_to_file(fname, addr_buf, 0) < 0) {
+ if (write_str_to_file_if_not_equal(fname, addr_buf)) {
log_warn(LD_REND, "Could not write onion address to hostname file %s",
escaped(fname));
goto end;
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index 48f53a263d..675b977ade 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -835,7 +835,7 @@ router_initialize_tls_context(void)
STATIC int
router_write_fingerprint(int hashed, int ed25519_identity)
{
- char *keydir = NULL, *cp = NULL;
+ char *keydir = NULL;
const char *fname = hashed ? "hashed-fingerprint" :
(ed25519_identity ? "fingerprint-ed25519" :
"fingerprint");
@@ -870,15 +870,11 @@ router_write_fingerprint(int hashed, int ed25519_identity)
tor_asprintf(&fingerprint_line, "%s %s\n", options->Nickname, fingerprint);
/* Check whether we need to write the (hashed-)fingerprint file. */
-
- cp = read_file_to_str(keydir, RFTS_IGNORE_MISSING, NULL);
- if (!cp || strcmp(cp, fingerprint_line)) {
- if (write_str_to_file(keydir, fingerprint_line, 0)) {
- log_err(LD_FS, "Error writing %s%s line to file",
- hashed ? "hashed " : "",
- ed25519_identity ? "ed25519 identity" : "fingerprint");
- goto done;
- }
+ if (write_str_to_file_if_not_equal(keydir, fingerprint_line)) {
+ log_err(LD_FS, "Error writing %s%s line to file",
+ hashed ? "hashed " : "",
+ ed25519_identity ? "ed25519 identity" : "fingerprint");
+ goto done;
}
log_notice(LD_GENERAL, "Your Tor %s identity key %s fingerprint is '%s %s'",
@@ -888,7 +884,6 @@ router_write_fingerprint(int hashed, int ed25519_identity)
result = 0;
done:
- tor_free(cp);
tor_free(keydir);
tor_free(fingerprint_line);
return result;
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index 1ac88d0eb7..8e1a22fb39 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -1554,7 +1554,7 @@ rend_service_load_keys(rend_service_t *s)
fname = rend_service_path(s, hostname_fname);
tor_snprintf(buf, sizeof(buf),"%s.onion\n", s->service_id);
- if (write_str_to_file(fname,buf,0)<0) {
+ if (write_str_to_file_if_not_equal(fname, buf)) {
log_warn(LD_CONFIG, "Could not write onion address to hostname file.");
goto err;
}