windows: protect the state directory, names that become files, logs
The state directory gets a protected DACL (SYSTEM and Administrators) at every start; on Windows programs run only from its bin\, never from PATH; rule-set and geodata names are validated before they become file names, and checked again where they do; logs need the secrets scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41c8ed4406
commit
d678976c2d
6 files changed
+96
-3
No files matched your search
@@ -14,13 +14,18 @@ impl Components {
|
||||
Self { bin }
|
||||
}
|
||||
|
||||
/// The program `name` (without `.exe`) of `component`.
|
||||
/// The program `name` (without `.exe`) of `component`. On Windows only the protected
|
||||
/// `bin\` counts: what the service runs, it runs as SYSTEM, and PATH may hold a directory
|
||||
/// any user can write.
|
||||
pub fn find(&self, component: &str, name: &str) -> Option<PathBuf> {
|
||||
let file = if cfg!(windows) { format!("{name}.exe") } else { name.to_owned() };
|
||||
let installed = self.bin.join(component).join(&file);
|
||||
if installed.is_file() {
|
||||
return Some(installed);
|
||||
}
|
||||
if cfg!(windows) {
|
||||
return None;
|
||||
}
|
||||
let path = std::env::var_os("PATH")?;
|
||||
std::env::split_paths(&path).map(|dir| dir.join(&file)).find(|p| p.is_file())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user