azriel91 / ssh_jumper

Async SSH tunnel through a jump host.
Apache License 2.0
12 stars 5 forks source link

Fatal IO Safety Violation in Rust 1.81.0 #5

Open jasondeewright opened 1 month ago

jasondeewright commented 1 month ago

This package seems to have started panicking with an IO Safety error with a recent version. I have a simple test written that should be passing. It's based largely on the example in the readme.

fatal runtime error: IO Safety violation: owned file descriptor already closed

The crate was working for me a few months ago. I suspect a recent version of Rust has triggered the issue. I'm very new to Rust, and haven't been able to glean much more. Using the debugger in RustRover I was able to isolate it to the channel_direct_tcpip method. Hope this helps.

    macro_rules! tokio_await {
        ($x:expr) => {
            tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on($x)
        };
    }

    #[test]
    fn test_ssh_jumper() {
        use std::borrow::Cow;
        use ssh_jumper::{
            model::{HostAddress, HostSocketParams, JumpHostAuthParams, SshTunnelParams},
            SshJumper
        };

        let (local_socket_addr, _ssh_forwarder_end_rx) = {
            let jump_host = HostAddress::HostName(Cow::Borrowed("localhost"));
            let jump_host_auth_params = JumpHostAuthParams::password(
                Cow::Borrowed("jumpuser"),
                Cow::Borrowed("jumppassword"),
            );
            let target_socket = HostSocketParams {
                address: HostAddress::HostName(Cow::Borrowed("mysql")),
                port: 3306,
            };
            let ssh_params =
                SshTunnelParams::new(jump_host, jump_host_auth_params, target_socket)
                    .with_jump_host_port(10022);

            tokio_await!(SshJumper::open_tunnel(&ssh_params)).unwrap()
        };

        assert!(local_socket_addr.port() > 0);
    }

Here's the docker-compose file

services:
  ssh_tunnel:
    image: lscr.io/linuxserver/openssh-server:latest
    links:
      - mysql
    ports:
      - 10022:2222
    environment:
      PASSWORD_ACCESS: true
      USER_NAME: jumpuser
      USER_PASSWORD: jumppassword

  mysql:
    image: bitnami/mysql
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: mypassword
      SQL_MODE: ""
      MYSQL_DATABASE: testdb

Let me know if I can provide any more information

azriel91 commented 1 month ago

Heya, I would likely only get to looking at this in November.

Also, feel free to tag me then in case I forget.

jasondeewright commented 2 weeks ago

Hey @azriel91, just a quick update on this.

For my own purposes, I ended up porting the integration to use russh. So, while I'm sure this is still an issue, I'm not blocked by it anymore.

If you're curious, I was able to utilize this stackoverflow post as a basis for my own integration: https://stackoverflow.com/questions/79137536/how-to-create-an-ssh-tunnel-with-russh-that-supports-multiple-connections