mirror of
https://github.com/zellij-org/zellij.git
synced 2026-10-11 22:50:07 +00:00
Error on socket paths that are too long (#4957)
* error on socket paths that are too long * add pr
This commit is contained in:
@@ -28,6 +28,7 @@ pub fn start_cli_client(
|
||||
sock_dir.push(session_name);
|
||||
sock_dir
|
||||
};
|
||||
crate::check_ipc_pipe_length(&zellij_ipc_pipe);
|
||||
os_input.connect_to_server(&*zellij_ipc_pipe);
|
||||
let pane_id = os_input
|
||||
.env_variable("ZELLIJ_PANE_ID")
|
||||
@@ -264,6 +265,7 @@ pub fn start_subscribe_client(
|
||||
sock_dir.push(session_name);
|
||||
sock_dir
|
||||
};
|
||||
crate::check_ipc_pipe_length(&zellij_ipc_pipe);
|
||||
os_input.connect_to_server(&*zellij_ipc_pipe);
|
||||
|
||||
// Parse pane IDs
|
||||
|
||||
@@ -302,6 +302,23 @@ fn spawn_web_server(_cli_args: &CliArgs) -> Result<String, String> {
|
||||
Ok("".to_owned())
|
||||
}
|
||||
|
||||
fn check_ipc_pipe_length(ipc_pipe: &Path) {
|
||||
use zellij_utils::consts::ZELLIJ_SOCK_MAX_LENGTH;
|
||||
let path_len = ipc_pipe.as_os_str().len();
|
||||
if path_len >= ZELLIJ_SOCK_MAX_LENGTH {
|
||||
eprintln!(
|
||||
"Error: the IPC socket path is too long ({} bytes, max {}):\n {}\n\n\
|
||||
This is usually caused by a long $TMPDIR path.\n\
|
||||
To fix this, set a shorter socket directory, eg.:\n \
|
||||
ZELLIJ_SOCKET_DIR=/tmp/zellij zellij",
|
||||
path_len,
|
||||
ZELLIJ_SOCK_MAX_LENGTH - 1,
|
||||
ipc_pipe.display()
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Spawn the Zellij server process.
|
||||
///
|
||||
/// On Unix the server daemonizes (double-fork) inside start_server(), so
|
||||
@@ -757,6 +774,7 @@ pub fn start_client(
|
||||
std::fs::create_dir_all(&sock_dir).unwrap();
|
||||
set_permissions(&sock_dir, 0o700).unwrap();
|
||||
sock_dir.push(envs::get_session_name().unwrap());
|
||||
check_ipc_pipe_length(&sock_dir);
|
||||
sock_dir
|
||||
};
|
||||
|
||||
@@ -1293,6 +1311,7 @@ pub fn start_server_detached(
|
||||
std::fs::create_dir_all(&sock_dir).unwrap();
|
||||
set_permissions(&sock_dir, 0o700).unwrap();
|
||||
sock_dir.push(envs::get_session_name().unwrap());
|
||||
check_ipc_pipe_length(&sock_dir);
|
||||
sock_dir
|
||||
};
|
||||
|
||||
|
||||
@@ -145,5 +145,6 @@ pub fn create_ipc_pipe(session_name: &str) -> PathBuf {
|
||||
sock_dir.push(session_name);
|
||||
sock_dir
|
||||
};
|
||||
crate::check_ipc_pipe_length(&zellij_ipc_pipe);
|
||||
zellij_ipc_pipe
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user