pub struct SecureProcess { /* private fields */ }Expand description
Launch a child process with hardware-backed secrets injected.
The run() method provides full security guarantees:
- Secret env var values are mlocked before spawn and zeroized after the child exits.
- The spawned child inherits
RLIMIT_CORE=0on Unix (preventing core dumps of the secret-laden environment).
The exec() method provides weaker guarantees:
Implementations§
Source§impl SecureProcess
impl SecureProcess
pub fn new(program: impl Into<PathBuf>) -> Self
pub fn arg(self, a: impl Into<OsString>) -> Self
pub fn args(self, args: impl IntoIterator<Item = impl Into<OsString>>) -> Self
Sourcepub fn secret_env(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn secret_env( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Inject a secret value as an environment variable (Type 2 delivery). The value is mlocked and zeroized after the child exits.
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a non-secret environment variable (e.g. a config file path).
Sourcepub fn env_remove(self, key: impl Into<String>) -> Self
pub fn env_remove(self, key: impl Into<String>) -> Self
Remove an environment variable from the child’s environment.
Sourcepub fn scrub(self, pattern: impl Into<String>) -> Self
pub fn scrub(self, pattern: impl Into<String>) -> Self
Scrub inherited env vars matching this pattern before spawning.
Accepts exact names or prefix patterns ending in *.
Sourcepub fn run(self) -> Result<ExitStatus>
pub fn run(self) -> Result<ExitStatus>
Spawn the child and wait for it to exit. Zeroizes secret env vars after child returns.
Sourcepub fn exec(self) -> Result<Infallible>
pub fn exec(self) -> Result<Infallible>
Replace the current process image via execve() (Unix). On Windows, falls back to run() since CreateProcess cannot replace the calling image.
WARNING: secret env var zeroization is NOT possible after exec() because the current process no longer exists. Use run() when zeroization matters.