I've been testing tunneling on Linux with openssh-SNAP-20060116.tar.gz and found a problem. When I use LocalCommand for doing ifconfig stuff, the command line was executed before a tunneling interface is opened. This causes errors on Linux and the interface is not automatically set up. This is not a problem on *BSD because you can do ifconfig for unopened tun/tap interfaces. But in Linux, you need to open it first. A possible solution seems to have ssh_local_cmd() executed in ssh_session2_setup(). Thank you, Yusuke
Yusuke Shinyama
2006-Jan-17 00:26 UTC
[PATCH] Re: LocalCommand problem for tunneling on Linux
Yusuke Shinyama <yusuke at cs.nyu.edu> wrote:> I've been testing tunneling on Linux with openssh-SNAP-20060116.tar.gz > and found a problem. > > When I use LocalCommand for doing ifconfig stuff, the command line > was executed before a tunneling interface is opened. This causes > errors on Linux and the interface is not automatically set up. > > This is not a problem on *BSD because you can do ifconfig for > unopened tun/tap interfaces. But in Linux, you need to open it first. > > A possible solution seems to have ssh_local_cmd() executed > in ssh_session2_setup().I made a quick patch for it. This is against openssh-SNAP-20060116.tar.gz. It is a bit ugly as the local command execution part is duplicated in another function. Thanks Yusuke ---------------------------------------------------------------- *** ssh.c.orig Mon Jan 16 19:19:10 2006 --- ssh.c Mon Jan 16 19:17:13 2006 *************** *** 1095,1100 **** --- 1095,1105 ---- } } + /* Execute a local command */ + if (options.local_command != NULL && + options.permit_local_command) + ssh_local_cmd(options.local_command); + client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply); *************** *** 1156,1167 **** ssh_init_forwarding(); ssh_control_listener(); if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) id = ssh_session2_open(); ! ! /* Execute a local command */ ! if (options.local_command != NULL && ! options.permit_local_command) ssh_local_cmd(options.local_command); /* If requested, let ssh continue in the background. */ --- 1161,1173 ---- ssh_init_forwarding(); ssh_control_listener(); + /* If a session is going to open, a local command will be + * executed within it. */ if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) id = ssh_session2_open(); ! /* Otherwise execute a local command now */ ! else if (options.local_command != NULL && ! options.permit_local_command) ssh_local_cmd(options.local_command); /* If requested, let ssh continue in the background. */ ----------------------------------------------------------------