From 683e2128a5d00bcadea7cc2f71a48253032632a5 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 00:51:48 +0000 Subject: enstate: the state directory is root's The receptor makes the state directory 0700 whoever created it (a deploy copying into incoming/, say), and the module has tmpfiles keep it so. --- src/store.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/store.rs b/src/store.rs index 08d0959..9de62d3 100644 --- a/src/store.rs +++ b/src/store.rs @@ -14,7 +14,7 @@ //! RUN/tmp/ scratch //! ``` //! -//! Entries are root's (mode 0600). A new snapshot +//! Entries are root's (mode 0600), and the state directory is 0700. A new snapshot //! or view generation is written next to the old one and put in place by replacing //! a symbolic link, so a reader sees one or the other, never a mix; a snapshot is //! flushed to disk before that, so a crash leaves the old one or the new one. @@ -77,6 +77,10 @@ impl Store { /// Waits for, and takes, the store's lock: one receptor at a time. pub fn lock(&self) -> Result { create_dir(&self.state, 0o700)?; + // Whatever created it (a deploy copying into incoming/, say), it is root's. + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&self.state, std::fs::Permissions::from_mode(0o700)) + .with_context(|| format!("chmod {}", self.state.display()))?; let path = self.state.join("lock"); let file = File::options() .create(true) -- cgit v1.3.1