avoid spawn failures after using sudo -i
The heart of the issue is that `sudo -i` sets the cwd to the homedir of the root user, and that isn't accessible to the regular unprivileged user, and cannot be set as the cwd for the newly spawned panes/tabs. A secondary issue is that it is hard to see what the error is without improved diagnostics. So this improves the diagnostics, and then changes the existence check that we were doing for local domain spawns to try to read the directory instead. refs: https://github.com/wez/wezterm/issues/2120
This commit is contained in:
1 parent
dfeeccbf2c
commit
3b9be25161
3 files changed
+19
-2
No files matched your search
@@ -83,6 +83,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Synthesized bold didn't kick in for automatically computed `font_rules`. [#2074](https://github.com/wez/wezterm/issues/2074)
|
||||
* Added [freetype_pcf_long_family_names](config/lua/config/freetype_pcf_long_family_names.md) option to workaround PCF font naming issues on certain Linux distributions. [#2100](https://github.com/wez/wezterm/issues/2100)
|
||||
* X11/Wayland: wezterm.desktop now specifies `StartupWMClass`. Thanks to [@uncomfyhalomacro](https://github.com/uncomfyhalomacro)! [#2052](https://github.com/wez/wezterm/issues/2052) [#2125](https://github.com/wez/wezterm/pull/2125)
|
||||
* `sudo -i` in a pane would cause subsequent pane/tab creation to fail until the cwd was changed to an accessible directory [#2120](https://github.com/wez/wezterm/issues/2120)
|
||||
|
||||
### 20220408-101518-b908e2dd
|
||||
|
||||
|
||||
+9
-1
@@ -254,7 +254,15 @@ impl LocalDomain {
|
||||
// can be painful; in the case where a tab is local but has connected
|
||||
// to a remote system and that remote has used OSC 7 to set a path
|
||||
// that doesn't exist on the local system, process spawning can fail.
|
||||
if !std::path::Path::new(&dir).exists() {
|
||||
// Another situation is `sudo -i` has the pane with set to a cwd
|
||||
// that is not accessible to the user.
|
||||
if let Err(err) = std::path::Path::new(&dir).read_dir() {
|
||||
log::warn!(
|
||||
"Directory {:?} is not readable and will not be \
|
||||
used for the command we are spawning: {:#}",
|
||||
dir,
|
||||
err
|
||||
);
|
||||
cmd.clear_cwd();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -1100,7 +1100,15 @@ impl Mux {
|
||||
},
|
||||
);
|
||||
|
||||
let tab = domain.spawn(size, command, cwd, window_id).await?;
|
||||
let tab = domain
|
||||
.spawn(size, command.clone(), cwd.clone(), window_id)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Spawning in domain `{}`: {size:?} command={command:?} cwd={cwd:?}",
|
||||
domain.domain_name()
|
||||
)
|
||||
})?;
|
||||
|
||||
let pane = tab
|
||||
.get_active_pane()
|
||||
|
||||
Reference in new issue
Block a user