Skip to content

Commit

Permalink
fix: don't make /proc or /run inaccessible
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Feb 4, 2025
1 parent 877f62a commit e66e342
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/systemd/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,11 +1333,14 @@ pub(crate) fn build_options(
.ok()
.and_then(|i| i.collect::<Result<Vec<_>, _>>().ok())
.and_then(|v| {
// Don't make those inaccessible, systemd won't be able to start anything
let excluded_run_dirs = [Path::new("/run"), Path::new("/proc")];
// Directories in PATH env var need to be accessible, otherwise systemd errors
let env_paths: Vec<_> = env::var_os("PATH")
.map(|ev| env::split_paths(&ev).collect())
.unwrap_or_default();
v.into_iter()
.filter(|e| !excluded_run_dirs.contains(&e.path().as_ref()))
// systemd follows symlinks when applying option, so exclude them
.filter(|e| e.file_type().is_ok_and(|t| !t.is_symlink()))
// exclude paths wich are below paths in PATH
Expand Down

0 comments on commit e66e342

Please sign in to comment.