diff options
| author | tv <tv@krebsco.de> | 2026-12-01 00:51:48 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 00:51:48 +0000 |
| commit | 683e2128a5d00bcadea7cc2f71a48253032632a5 (patch) | |
| tree | 7d6804eb4908079db1309ae895fb265352a4cca2 /src | |
| parent | f994019c242ecb097a8fdabc7650f00721dddf10 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/store.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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<Lock> { 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) |
