test,ssh: avoid leaking user config into testing ssh sessions (#8395)
This commit is contained in:
1 parent
c41674ceee
commit
1026152aa1
1 file changed
+7
@@ -241,6 +241,10 @@ impl SshdConfig {
|
|||||||
.insert("StrictModes".to_string(), Self::yes_value(yes));
|
.insert("StrictModes".to_string(), Self::yes_value(yes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_env(&mut self, pair: String) {
|
||||||
|
self.0.entry("SetEnv".to_string()).or_default().push(pair);
|
||||||
|
}
|
||||||
|
|
||||||
fn yes_value(yes: bool) -> Vec<String> {
|
fn yes_value(yes: bool) -> Vec<String> {
|
||||||
vec![Self::yes_string(yes)]
|
vec![Self::yes_string(yes)]
|
||||||
}
|
}
|
||||||
@@ -339,6 +343,9 @@ impl Sshd {
|
|||||||
let sshd_pid_file = tmp.child("sshd.pid");
|
let sshd_pid_file = tmp.child("sshd.pid");
|
||||||
config.set_pid_file(sshd_pid_file.path());
|
config.set_pid_file(sshd_pid_file.path());
|
||||||
|
|
||||||
|
// Prevent user config from interfering with the tests
|
||||||
|
config.set_env(format!("HOME={}", tmp.path().display()));
|
||||||
|
|
||||||
// Generate $ROOT/sshd_config based on config
|
// Generate $ROOT/sshd_config based on config
|
||||||
let sshd_config_file = tmp.child("sshd_config");
|
let sshd_config_file = tmp.child("sshd_config");
|
||||||
let config_string = config.to_string();
|
let config_string = config.to_string();
|
||||||
|
|||||||
Reference in new issue
Block a user