mirror of
https://github.com/containers/youki
synced 2024-11-22 17:02:00 +01:00
Fixed ENAMETOOLONG error in setup_console_socket (#2915)
* Fixed ENAMETOOLONG error in setup_console_socket Signed-off-by: morganllewellynjones <morganjones.gm@gmail.com> * Update crates/libcontainer/src/tty.rs Co-authored-by: Toru Komatsu <k0ma@utam0k.jp> --------- Signed-off-by: morganllewellynjones <morganjones.gm@gmail.com> Co-authored-by: Toru Komatsu <k0ma@utam0k.jp>
This commit is contained in:
parent
44ca398f2a
commit
3aa41cf5fd
@ -1,5 +1,6 @@
|
||||
//! tty (teletype) for user-system interaction
|
||||
|
||||
use std::env;
|
||||
use std::io::IoSlice;
|
||||
use std::os::unix::fs::symlink;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
@ -75,7 +76,14 @@ pub fn setup_console_socket(
|
||||
console_socket_path: &Path,
|
||||
socket_name: &str,
|
||||
) -> Result<RawFd> {
|
||||
let linked = container_dir.join(socket_name);
|
||||
// Move into the container directory to avoid sun family conflicts with long socket path names.
|
||||
// ref: https://github.com/containers/youki/issues/2910
|
||||
|
||||
let prev_dir = env::current_dir().unwrap();
|
||||
let _ = env::set_current_dir(container_dir);
|
||||
|
||||
let linked = PathBuf::from(socket_name);
|
||||
|
||||
symlink(console_socket_path, &linked).map_err(|err| TTYError::Symlink {
|
||||
source: err,
|
||||
linked: linked.to_path_buf().into(),
|
||||
@ -105,6 +113,8 @@ pub fn setup_console_socket(
|
||||
})?,
|
||||
Ok(()) => csocketfd.as_raw_fd(),
|
||||
};
|
||||
|
||||
let _ = env::set_current_dir(prev_dir);
|
||||
Ok(csocketfd)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user