[verified] fix(hs): redact onion in publish logs; cache 0700
All checks were successful
ci / test (pull_request) Successful in 3m0s
All checks were successful
ci / test (pull_request) Successful in 3m0s
wait_until_published now logs HsId via safelog, not the locator. Store and client_config mkdir Arti cache/state 0700. Arti dangerously_trust_everyone stays on storage only.
This commit is contained in:
parent
bfd28fce6b
commit
424002c0f5
6 changed files with 56 additions and 8 deletions
24
src/hs.rs
24
src/hs.rs
|
|
@ -1,5 +1,6 @@
|
|||
//! In-process Arti onion-service helpers (no C-tor).
|
||||
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
|
|
@ -8,7 +9,7 @@ use arti_client::{TorClient, TorClientConfig};
|
|||
use futures::StreamExt;
|
||||
use safelog::DisplayRedacted;
|
||||
use tor_hsservice::status::State;
|
||||
use tor_hsservice::{HsNickname, OnionServiceConfig, RunningOnionService};
|
||||
use tor_hsservice::{HsId, HsNickname, OnionServiceConfig, RunningOnionService};
|
||||
use tor_rtcompat::PreferredRuntime;
|
||||
|
||||
pub const HS_PORT: u16 = 80;
|
||||
|
|
@ -28,9 +29,24 @@ const PROBE_TIMEOUT: Duration = Duration::from_secs(12);
|
|||
|
||||
pub type Client = Arc<TorClient<PreferredRuntime>>;
|
||||
|
||||
fn mkdir_700(path: &std::path::Path) {
|
||||
std::fs::create_dir_all(path).expect("mkdir");
|
||||
let mut perms = std::fs::metadata(path).expect("metadata").permissions();
|
||||
perms.set_mode(0o700);
|
||||
std::fs::set_permissions(path, perms).expect("chmod 0700");
|
||||
}
|
||||
|
||||
/// Status/probe log label: safelog-redacted v3 onion, never the locator.
|
||||
pub fn log_label(onion: &str) -> String {
|
||||
match onion.parse::<HsId>() {
|
||||
Ok(id) => id.display_redacted().to_string(),
|
||||
Err(_) => safelog::sensitive(onion).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn client_config(state_dir: &std::path::Path, cache_dir: &std::path::Path) -> TorClientConfig {
|
||||
std::fs::create_dir_all(state_dir).expect("state dir");
|
||||
std::fs::create_dir_all(cache_dir).expect("cache dir");
|
||||
mkdir_700(state_dir);
|
||||
mkdir_700(cache_dir);
|
||||
let mut builder = TorClientConfigBuilder::from_directories(state_dir, cache_dir);
|
||||
builder.storage().permissions().dangerously_trust_everyone();
|
||||
builder
|
||||
|
|
@ -84,8 +100,8 @@ pub async fn wait_until_published(
|
|||
client: &Client,
|
||||
svc: &RunningOnionService,
|
||||
onion: &str,
|
||||
label: &str,
|
||||
) -> Result<(), String> {
|
||||
let label = log_label(onion);
|
||||
let deadline = Instant::now() + PUBLISH_WAIT;
|
||||
let mut events = svc.status_events();
|
||||
let mut next_probe = Instant::now() + PROBE_EVERY;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ impl Node {
|
|||
_svc: Arc::clone(&svc),
|
||||
rend,
|
||||
});
|
||||
hs::wait_until_published(&node.client, &svc, &onion, &onion).await?;
|
||||
hs::wait_until_published(&node.client, &svc, &onion).await?;
|
||||
node.store
|
||||
.lock()
|
||||
.map_err(|e| e.to_string())?
|
||||
|
|
@ -444,7 +444,7 @@ impl Node {
|
|||
_svc: Arc::clone(&svc),
|
||||
rend,
|
||||
});
|
||||
hs::wait_until_published(&self.client, &svc, &onion, &onion).await?;
|
||||
hs::wait_until_published(&self.client, &svc, &onion).await?;
|
||||
{
|
||||
let store = self.store.lock().map_err(|e| e.to_string())?;
|
||||
store.set_onion(&onion).map_err(|e| e.to_string())?;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ impl Store {
|
|||
}
|
||||
mkdir_700(home)?;
|
||||
mkdir_700(&home.join("arti"))?;
|
||||
mkdir_700(&home.join("cache"))?;
|
||||
let db_path = home.join("onionwire.db");
|
||||
let conn = Connection::open(&db_path)?;
|
||||
let journal: String = conn.query_row("PRAGMA journal_mode = WAL", [], |row| row.get(0))?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue