mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Use write_str_if_not_equal() for onion services
This commit is contained in:
parent
c212578bf0
commit
67a62ccf51
6
changes/bug40062
Normal file
6
changes/bug40062
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
o Minor features (onion services):
|
||||||
|
- When writing an onion service hostname file, first read it to make
|
||||||
|
sure it contains what we want before attempting to write it. Now
|
||||||
|
onion services can set their existing onion service directories to
|
||||||
|
read-only and Tor will still work. Resolves ticket 40062. Patch by
|
||||||
|
Neel Chauhan.
|
@ -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);
|
tor_asprintf(&addr_buf, "%s.%s\n", service->onion_address, address_tld);
|
||||||
/* Notice here that we use the given "fname_". */
|
/* Notice here that we use the given "fname_". */
|
||||||
fname = hs_path_from_filename(service->config.directory_path, 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",
|
log_warn(LD_REND, "Could not write onion address to hostname file %s",
|
||||||
escaped(fname));
|
escaped(fname));
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -835,7 +835,7 @@ router_initialize_tls_context(void)
|
|||||||
STATIC int
|
STATIC int
|
||||||
router_write_fingerprint(int hashed, int ed25519_identity)
|
router_write_fingerprint(int hashed, int ed25519_identity)
|
||||||
{
|
{
|
||||||
char *keydir = NULL, *cp = NULL;
|
char *keydir = NULL;
|
||||||
const char *fname = hashed ? "hashed-fingerprint" :
|
const char *fname = hashed ? "hashed-fingerprint" :
|
||||||
(ed25519_identity ? "fingerprint-ed25519" :
|
(ed25519_identity ? "fingerprint-ed25519" :
|
||||||
"fingerprint");
|
"fingerprint");
|
||||||
@ -870,7 +870,7 @@ router_write_fingerprint(int hashed, int ed25519_identity)
|
|||||||
tor_asprintf(&fingerprint_line, "%s %s\n", options->Nickname, fingerprint);
|
tor_asprintf(&fingerprint_line, "%s %s\n", options->Nickname, fingerprint);
|
||||||
|
|
||||||
/* Check whether we need to write the (hashed-)fingerprint file. */
|
/* Check whether we need to write the (hashed-)fingerprint file. */
|
||||||
if (write_str_if_not_equal(keydir, fingerprint_line)) {
|
if (write_str_to_file_if_not_equal(keydir, fingerprint_line)) {
|
||||||
log_err(LD_FS, "Error writing %s%s line to file",
|
log_err(LD_FS, "Error writing %s%s line to file",
|
||||||
hashed ? "hashed " : "",
|
hashed ? "hashed " : "",
|
||||||
ed25519_identity ? "ed25519 identity" : "fingerprint");
|
ed25519_identity ? "ed25519 identity" : "fingerprint");
|
||||||
@ -884,7 +884,6 @@ router_write_fingerprint(int hashed, int ed25519_identity)
|
|||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
done:
|
done:
|
||||||
tor_free(cp);
|
|
||||||
tor_free(keydir);
|
tor_free(keydir);
|
||||||
tor_free(fingerprint_line);
|
tor_free(fingerprint_line);
|
||||||
return result;
|
return result;
|
||||||
|
@ -1554,7 +1554,7 @@ rend_service_load_keys(rend_service_t *s)
|
|||||||
fname = rend_service_path(s, hostname_fname);
|
fname = rend_service_path(s, hostname_fname);
|
||||||
|
|
||||||
tor_snprintf(buf, sizeof(buf),"%s.onion\n", s->service_id);
|
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.");
|
log_warn(LD_CONFIG, "Could not write onion address to hostname file.");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user