init: Maintain default service env vars separate from init env vars

With this only the env vars set using export or explicitly specify for a
service are passed to services (in addition to RUST_BACKTRACE, PATH and
LD_LIBRARY_PATH). As such we no longer need to manually unset bootloader
env vars to keep the environment clean. And finally this means that env
var substitutions in shell scripts always use the bootloader provided
env vars rather than locally specified ones.

This does regress multi monitor support when there is no proper graphics
driver.
This commit is contained in:
bjorn3
2026-02-19 21:06:53 +01:00
parent b7524c3a65
commit 87abd3fb70
5 changed files with 26 additions and 19 deletions
+5 -2
View File
@@ -1,3 +1,5 @@
use std::collections::BTreeMap;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
use std::{env, fs, io, iter, process};
@@ -149,9 +151,10 @@ impl Process {
}
}
pub fn into_command(self) -> process::Command {
pub fn into_command(self, base_envs: &BTreeMap<String, OsString>) -> process::Command {
let mut command = process::Command::new(self.cmd);
command.args(self.args).envs(self.envs);
command.args(self.args);
command.env_clear().envs(base_envs).envs(self.envs);
command
}
}