Ticket #3590 (closed defect: duplicate)

Opened 6 years ago

Last modified 6 years ago

[musl alpinelinux] sftp vfs connects to localhost or another alpinelinux-host only

Reported by: vaka Owned by:
Priority: major Milestone:
Component: mc-vfs Version: master
Keywords: sftp musl alpinelinux Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:


I add sftp finctionality to alpinelinux 'mc' package and have a problem with connecting to non-alpinelinux hosts.

connect to gentoo host:

if I describe gentoo host in .ssh/config

Host gentoo

connect to freebsd server crashes while reading it from config

Host came
HostName freebsd.domain.com
User camedev
Port 1254

As you see, in this case cannot chdir to ip.ad.dr.es not to hostname as in gentoo-case.

The same server without .ssh/config:

The same strange problems with any other non-alpinelinux server.

I try to check if it is a libssh2 bug and run simple php libssh2-based script which connects to server and shows remote directory listing. And it works well on any host.

So the problem somewhere in mc.

I deploy patches from mc-3406 and mc-3581, and make a small type_of_socket fixup.
But it didn't help.

a patch to fix type of socket below:

--- a/src/vfs/sftpfs/connection.c
+++ b/src/vfs/sftpfs/connection.c
@@ -63,11 +63,11 @@
  * @return socket descriptor number, -1 if any error was occurred

-static int
+static libssh2_socket_t
 sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
     struct addrinfo hints, *res = NULL, *curr_res;
-    int my_socket = 0;
+    libssh2_socket_t my_socket = 0;
     char port[BUF_TINY];
     int e;

@@ -388,9 +388,7 @@
     /* ... start it up. This will trade welcome banners, exchange keys,
      * and setup crypto, compression, and MAC layers
-    /* FIXME: Starting in libssh2 version 1.2.8  this function is considered deprecated.
-       Use libssh2_session_handshake instead. */
-    rc = libssh2_session_startup (super_data->session, super_data->socket_handle);
+    rc = libssh2_session_handshake (super_data->session, super_data->socket_handle);
     if (rc != 0)
         mc_propagate_error (mcerror, -1, _("sftp: Failure establishing SSH session: (%d)"), rc);
--- a/src/vfs/sftpfs/internal.h
+++ b/src/vfs/sftpfs/internal.h
@@ -41,7 +41,7 @@
     char *pubkey;
     char *privkey;

-    int socket_handle;
+    libssh2_socket_t socket_handle;
     const char *fingerprint;
     vfs_path_element_t *original_connection_info;
 } sftpfs_super_data_t;

$ mc -V
GNU Midnight Commander 4.8.15
Built with GLib 2.46.2
Using the ncurses library
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 32; void *: 32; size_t: 32; off_t: 64;

$ mc -F
Root directory: /home/vaka

[System data]

Config directory: /etc/mc/
Data directory: /usr/share/mc/
File extension handlers: /usr/lib/mc/ext.d/
VFS plugins and scripts: /usr/lib/mc/

extfs.d: /usr/lib/mc/extfs.d/
fish: /usr/lib/mc/fish/

[User data]

Config directory: /home/vaka/.config/mc/
Data directory: /home/vaka/.local/share/mc/

$ mc --configure-options

'--build=i586-alpine-linux-musl' '--host=i586-alpine-linux-musl' '--prefix=/usr' '--libexecdir=/usr/lib' '--mandir=/usr/share/man' '--sysconfdir=/etc' '--enable-background' '--enable-charset' '--enable-largefile' '--enable-vfs-sftp' '--with-edit' '--with-mmap' '--with-screen=ncurses' '--with-subshell' '--with-vfs' '--without-debug' '--without-gnome' '--without-gpm-mouse' '--without-included-gettext' '--without-samba' '--without-x' 'build_alias=i586-alpine-linux-musl' 'host_alias=i586-alpine-linux-musl' 'CC=gcc' 'CFLAGS=-Os -fomit-frame-pointer' 'LDFLAGS=-Wl,--as-needed' 'CPPFLAGS=-Os -fomit-frame-pointer'

alpinelinux use musl-libc (1.1.12) not glibc.
$ uname -a
Linux alpine 4.1.15-5-grsec 6-Alpine SMP Wed Jan 20 14:05:19 GMT 2016 i686 Linux

Change History

comment:1 Changed 6 years ago by andrew_b

  • Status changed from new to closed
  • Resolution set to duplicate
  • Milestone Future Releases deleted

Closed as duplicate of #3581.

comment:2 Changed 6 years ago by and

to eval a testcase let's use your sftp:// example only

all patches from #3406 and #3581 applied including config parser patch? please crosscheck

$ telnet 22 print a ssh version line?

after each test, close and re-open mc and try a single ssh connection
cd /​sftp:// works?
cd /​sftp:// don't work?
cd /​sftp://gentoo don't work? (via ssh config)

comment:3 Changed 6 years ago by zaytsev

The parent ticket has been closed, if current master still doesn't work, please reopen with more information.

Note: See TracTickets for help on using tickets.