Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 286741 - net-libs/libssh2-1.1 fails ssh2.sh test - "Failure establishing SSH session"
Summary: net-libs/libssh2-1.1 fails ssh2.sh test - "Failure establishing SSH session"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Netmon project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-28 10:03 UTC by Kent Fredric (IRC: kent\n) (RETIRED)
Modified: 2009-12-14 19:13 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
paludis --info net-libs/libssh2 (paludis-info,30.44 KB, text/plain)
2009-09-28 10:03 UTC, Kent Fredric (IRC: kent\n) (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2009-09-28 10:03:17 UTC
make[2]: Leaving directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make  check-TESTS
make[2]: Entering directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
PASS: simple
Failure establishing SSH session
FAIL: ssh2.sh
====================================================
1 of 2 tests failed
Please report to libssh2-devel@lists.sourceforge.net
====================================================
make[2]: Leaving directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make[1]: Leaving directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make[2]: *** [check-TESTS] Error 1
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1
/usr/libexec/paludis/utils/emake: emake returned error 2

!!! ERROR in net-libs/libssh2-1.1::gentoo:
!!! In default_src_test at line 29
!!! make check failed

!!! Call stack:
!!!    * default_src_test (/usr/libexec/paludis/2/src_test.bash:29)
!!!    * src_test (/usr/libexec/paludis/2/src_test.bash:43)
!!!    * ebuild_f_test (/usr/libexec/paludis/2/src_test.bash:74)
!!!    * ebuild_main (/usr/libexec/paludis/ebuild.bash:594)
!!!    * main (/usr/libexec/paludis/ebuild.bash:622)

* net-libs/libssh2::gentoo [N 1.1]
    -gcrypt zlib build_options: optional_tests split strip -trace
    "Library implementing the SSH2 protocol"

    Package information:
        app-admin/eselect-compiler: (none)
        app-shells/bash:       4.0_p33
        dev-java/java-config:  1.3.7-r1 2.1.9-r1
        dev-lang/python:       2.4.6 2.5.4-r3 2.6.2-r1 3.1.1
        dev-python/pycrypto:   2.0.1-r8
        dev-util/ccache:       2.4-r8
        dev-util/cmake:        2.6.4-r2
        dev-util/confcache:    (none)
        sys-apps/baselayout:   2.0.1
        sys-apps/openrc:       0.4.3-r3
        sys-apps/sandbox:      2.1
        sys-devel/autoconf:    2.13 2.63-r1
        sys-devel/automake:    1.10.2 1.11 1.4_p6 1.5 1.7.9-r1 1.8.5-r3 1.9.6-r2
        sys-devel/binutils:    2.19.1-r1
        sys-devel/gcc-config:  1.4.1
        sys-devel/libtool:     2.2.6a
        virtual/os-headers:    2.6.30-r1 (for sys-kernel/linux-headers::installed)


More details follow.
Comment 1 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2009-09-28 10:03:53 UTC
Created attachment 205451 [details]
paludis --info net-libs/libssh2
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2009-09-29 11:13:57 UTC
Can't reproduce that.
Comment 3 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2009-10-01 07:39:28 UTC
It could be related to the fact for whatever reason, a non-root user calling /usr/bin/sshd on my box  ( what ssh2.sh does ) results in: 

/etc/ssh/sshd_config: Permission denied

sudo ls -la /etc/ssh/sshd_config 
-rw------- 1 root root 3333 2009-08-26 11:29 /etc/ssh/sshd_config

Additionally, even with root privs, it doesn't work properly. 

Tweaking ssh2.sh to have '-d -d -d' on the sshd command does as follows: 

sudo make check 

make  simple
make[1]: Entering directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make[1]: `simple' is up to date.
make[1]: Leaving directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make  check-TESTS
make[1]: Entering directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
PASS: simple
debug2: load_server_config: filename /dev/null
debug2: load_server_config: done config len = 1
debug2: parse_server_config: config /dev/null len 1
debug1: sshd version OpenSSH_5.2p1
debug3: Not a RSA1 key file /tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests/etc/host.
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-f'
debug1: rexec_argv[2]='/dev/null'
debug1: rexec_argv[3]='-h'
debug1: rexec_argv[4]='/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests/etc/host'
debug1: rexec_argv[5]='-o'
debug1: rexec_argv[6]='Port 4711'
debug1: rexec_argv[7]='-o'
debug1: rexec_argv[8]='Protocol 2'
debug1: rexec_argv[9]='-o'
debug1: rexec_argv[10]='AuthorizedKeysFile /tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests/etc/user.pub'
debug1: rexec_argv[11]='-o'
debug1: rexec_argv[12]='UsePrivilegeSeparation no'
debug1: rexec_argv[13]='-o'
debug1: rexec_argv[14]='StrictModes no'
debug1: rexec_argv[15]='-D'
debug1: rexec_argv[16]='-d'
debug1: rexec_argv[17]='-d'
debug1: rexec_argv[18]='-d'
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 4711 on 0.0.0.0.
Server listening on 0.0.0.0 port 4711.
debug2: fd 4 setting O_NONBLOCK
debug1: Bind to port 4711 on ::.
Server listening on :: port 4711.
debug3: fd 5 is not O_NONBLOCK
debug1: Server will not fork when running in debugging mode.
debug3: send_rexec_state: entering fd = 8 config len 1
debug3: ssh_msg_send: type 0
debug3: send_rexec_state: done
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 3, 3
debug1: Connection refused by tcp wrapper
Failure establishing SSH session
FAIL: ssh2.sh
====================================================
1 of 2 tests failed
Please report to libssh2-devel@lists.sourceforge.net
====================================================
make[1]: *** [check-TESTS] Error 1
make[1]: Leaving directory `/tmp/portage/net-libs-libssh2-1.1/work/libssh2-1.1/tests'
make: *** [check-am] Error 2

And oddly, without 'sudo' it segfaults in libwrap 

sshd[25455]: segfault at 2a7ac630 ip 00002b005bebe072 sp 00007fff2a7aa490 error 4 in libwrap.so.0.7.6[2b005beba000+8000]

Now for some reason, it appears that this is a result of the following being present in /etc/hosts.deny *multiple* times:

  ALL: 127.0.0.1

I don't recall what put that there, but it was automated. 
Removing this line results in 'sudo make check' working again. (  But only as root, not as a normal user ) 

Comment 4 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2009-10-13 18:52:40 UTC
Backtrace from the segfault I get: 


Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaaf1072 in get_field () from /lib/libwrap.so.0

Thread 1 (Thread 0x2aaaab9a34e0 (LWP 7204)):
#0  0x00002aaaaaaf1072 in get_field () from /lib/libwrap.so.0
No symbol table info available.
#1  0x00002aaaaaaf17bb in process_options () from /lib/libwrap.so.0
No symbol table info available.
#2  0x00002aaaaaaf0517 in table_match () from /lib/libwrap.so.0
No symbol table info available.
#3  0x00002aaaaaaf060f in hosts_access () from /lib/libwrap.so.0
No symbol table info available.
#4  0x0000000000409d6b in main ()
No symbol table info available.
(gdb) quit
A debugging session is active.

This is: 

1. Non Privelaged.
2. I have to tweak the port in both ssh2.c and ssh2.sh to be >10000, ( I use 24711 instead )
3. Server run command line replaced with:

   
chmod go-r $srcdir/etc/host*
gdb -ex run -ex 'thread apply all bt full' --args $SSHD -f /dev/null -h $srcdir/etc/host \
    -o 'Port 24711' \
    -o 'Protocol 2' \
    -o "AuthorizedKeysFile $srcdir/etc/user.pub" \
    -o 'UsePrivilegeSeparation no' \
    -o 'StrictModes no' -ddd -e \
    -D &
sshdpid=$!


Comment 5 Peter Volkov (RETIRED) gentoo-dev 2009-12-14 19:13:46 UTC
Well, the reason here is not configuration file permissions, but portage user that is not allowed to login:

PASS: simple
debug2: load_server_config: filename /dev/null
debug2: load_server_config: done config len = 1
debug2: parse_server_config: config /dev/null len 1
debug1: sshd version OpenSSH_5.2p1
debug3: Not a RSA1 key file /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/host.
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: setgroups() failed: Operation not permitted
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-f'
debug1: rexec_argv[2]='/dev/null'
debug1: rexec_argv[3]='-h'
debug1: rexec_argv[4]='/vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/host'
debug1: rexec_argv[5]='-d'
debug1: rexec_argv[6]='-d'
debug1: rexec_argv[7]='-d'
debug1: rexec_argv[8]='-o'
debug1: rexec_argv[9]='Port 4711'
debug1: rexec_argv[10]='-o'
debug1: rexec_argv[11]='Protocol 2'
debug1: rexec_argv[12]='-o'
debug1: rexec_argv[13]='AuthorizedKeysFile /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/user.pub'
debug1: rexec_argv[14]='-o'
debug1: rexec_argv[15]='UsePrivilegeSeparation no'
debug1: rexec_argv[16]='-o'
debug1: rexec_argv[17]='StrictModes no'
debug1: rexec_argv[18]='-D'
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 4711 on 0.0.0.0.
Server listening on 0.0.0.0 port 4711.
socket: Address family not supported by protocol
debug3: fd 4 is not O_NONBLOCK
debug1: Server will not fork when running in debugging mode.
debug3: send_rexec_state: entering fd = 7 config len 1
debug3: ssh_msg_send: type 0
debug3: send_rexec_state: done
debug1: rexec start in 4 out 4 newsock 4 pipe -1 sock 7
debug1: inetd sockets after dupping: 3, 3
Connection from 127.0.0.1 port 50602
debug1: Client protocol version 2.0; client software version libssh2_1.2.2
debug1: no match: libssh2_1.2.2
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug2: fd 3 setting O_NONBLOCK
debug1: list_hostkey_types: ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-sha1
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug2: mac_setup: found hmac-sha1
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug2: dh_gen_key: priv key bits set: 167/320
debug2: bits set: 1051/2048
debug1: expecting SSH2_MSG_KEXDH_INIT
debug2: bits set: 1039/2048
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: KEX done
Fingerprint: A0 90 21 52 25 7A 06 7F B9 7B 52 CE FA A6 93 7F 
debug1: userauth-request for user root service ssh-connection method none
debug1: attempt 0 failures 0
debug3: Trying to reverse map address 127.0.0.1.
debug2: parse_server_config: config reprocess config len 1
debug2: input_userauth_request: setting up authctxt for root
debug2: input_userauth_request: try method none
Failed none for root from 127.0.0.1 port 50602 ssh2
Authentication methods: publickey,password,keyboard-interactive
debug1: userauth-request for user root service ssh-connection method publickey
debug1: attempt 1 failures 0
debug2: input_userauth_request: try method publickey
debug1: test whether pkalg/pkblob are acceptable
debug1: temporarily_use_uid: 0/0 (e=250/250)
debug1: trying public key file /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/user.pub
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/user.pub, line 1
Found matching RSA key: 48:2e:33:0d:0d:ca:dc:40:08:8b:0f:2c:22:74:7d:37
debug1: restore_uid: (unprivileged)
debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa
Postponed publickey for root from 127.0.0.1 port 50602 ssh2
debug1: userauth-request for user root service ssh-connection method publickey
debug1: attempt 2 failures 0
debug2: input_userauth_request: try method publickey
debug1: temporarily_use_uid: 0/0 (e=250/250)
debug1: trying public key file /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/user.pub
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /vt/portage/tmp/portage/net-libs/libssh2-1.2.2/work/libssh2-1.2.2/tests/etc/user.pub, line 1
Found matching RSA key: 48:2e:33:0d:0d:ca:dc:40:08:8b:0f:2c:22:74:7d:37
debug1: restore_uid: (unprivileged)
debug1: ssh_rsa_verify: signature correct
debug2: userauth_pubkey: authenticated 1 pkalg ssh-rsa
Accepted publickey for root from 127.0.0.1 port 50602 ssh2
debug1: Entering interactive session for SSH2.
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: server_init_dispatch_20
	Authentication by public key succeeded.
debug1: server_input_channel_open: ctype session rchan 0 win 65536 max 32768
debug1: input_session_request
debug1: channel 0: new [server-session]
debug2: session_new: allocate (allocated 0 max 10)
debug3: session_unused: session id 0 unused
debug1: session_new: session 0
debug1: session_open: channel 0
debug1: session_open: session 0: link with channel 0
debug1: server_input_channel_open: confirm session
debug1: server_input_channel_req: channel 0 request env reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req env
debug2: Ignoring env request FOO: disallowed name
debug1: server_input_channel_req: channel 0 request pty-req reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req pty-req
debug1: Allocating pty.
debug1: session_pty_req: session 0 alloc /dev/pts/8
chown(/dev/pts/8, 0, 5) failed: Operation not permitted
debug1: do_cleanup
debug1: session_pty_cleanup: session 0 release /dev/pts/8
Failed requesting pty
FAIL: ssh2.sh
====================================================
1 of 2 tests failed
Please report to libssh2-devel@lists.sourceforge.net
====================================================


I don't see how we can workaround this and thus the only solution I see it to disable test. Done and bug fixed.


BTW, Kent, if crash is still reproducible with most recent libssh2, please, rebuild sys-apps/tcp-wrappers and I guess openssh as described here: 
http://www.gentoo.org/proj/en/qa/backtraces.xml

and attach full backtrace there. Current backtrace is not useful.