Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ENAMETOOLONG error in setup_console_socket #2915

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/libcontainer/src/tty.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -75,7 +76,13 @@ 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.
morganllewellynjones marked this conversation as resolved.
Show resolved Hide resolved

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(),
Expand Down Expand Up @@ -105,6 +112,8 @@ pub fn setup_console_socket(
})?,
Ok(()) => csocketfd.as_raw_fd(),
};

let _ = env::set_current_dir(prev_dir);
Ok(csocketfd)
}

Expand Down
Loading