thread original umask through when spawning mux server

refs: #1633
This commit is contained in:
Wez Furlong committed 2022-02-11 10:00:09 -07:00
1 parent 41342ef740
commit e7b8374c3f
4 files changed
+25

No files matched your search

Generated
+2
View File
@@ -4691,6 +4691,7 @@ dependencies = [
"config",
"filedescriptor",
"futures",
"libc",
"log",
"lru",
"metrics",
@@ -4705,6 +4706,7 @@ dependencies = [
"textwrap 0.14.2",
"thiserror",
"uds_windows",
"umask",
"url",
"wezterm-ssh",
"wezterm-term",
+2
View File
@@ -15,6 +15,7 @@ config = { path = "../config" }
filedescriptor = { version="0.8", path = "../filedescriptor" }
futures = "0.3"
log = "0.4"
libc = "0.2"
lru = "0.7"
metrics = { version="0.17", features=["std"]}
mux = { path = "../mux" }
@@ -27,6 +28,7 @@ smol = "1.2"
termwiz = { path = "../termwiz" }
textwrap = "0.14"
thiserror = "1.0"
umask = { path = "../umask" }
url = "2"
wezterm-ssh = { path = "../wezterm-ssh" }
wezterm-term = { path = "../term", features=["use_serde"] }
+12
View File
@@ -24,6 +24,8 @@ use std::collections::HashMap;
use std::io::{Read, Write};
use std::marker::Unpin;
use std::net::TcpStream;
#[cfg(unix)]
use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::thread;
use std::time::Duration;
@@ -627,6 +629,16 @@ impl Reconnectable {
let mut cmd = std::process::Command::new(&argv[0]);
cmd.args(&argv[1..]);
#[cfg(unix)]
if let Some(mask) = umask::UmaskSaver::saved_umask() {
unsafe {
cmd.pre_exec(move || {
libc::umask(mask);
Ok(())
});
}
}
log::warn!("Running: {:?}", cmd);
ui.output_str(&format!("Running: {:?}\n", cmd));
+9
View File
@@ -126,6 +126,15 @@ fn run() -> anyhow::Result<()> {
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
if let Some(mask) = umask::UmaskSaver::saved_umask() {
unsafe {
cmd.pre_exec(move || {
libc::umask(mask);
Ok(())
});
}
}
return Err(anyhow::anyhow!("failed to re-exec: {:?}", cmd.exec()));
}
}