php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57812 Connection fails when using socksifiy
Submitted: 2007-08-30 03:11 UTC Modified: 2012-06-22 15:22 UTC
From: daniel dot buschke at nextiraone dot de Assigned:
Status: Wont fix Package: ssh2 (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniel dot buschke at nextiraone dot de
New email:
PHP Version: OS:

 

 [2007-08-30 03:11 UTC] daniel dot buschke at nextiraone dot de
Description:
------------
Hi,
in PHP 5.1.3 I had follwing problem:

When trying to connect to a host via ssh2_connect and socksify (see dante) I got the error that ssh2_connect is unable to the host. strace shows that the socket returned with "EINPROGRESS (Operation now in progress)" witch is not a "real" error. As I tried to find the problem I recognized that fsockopen has the same problem and that the problem is in some php functions (which are also used by ssh2). BUT PHP Won't fix that (see http://bugs.php.net/bug.php?id=42467 ). Instead they told me that fsockopen is using "quick'n'dirty socket stuff".

Or with other words: they told me that ssh2 is using the "quick'n'dirty socket stuff".

BTW: socket_create and socket_connect works fine with socksify. This is not a problem of socksify!



in PHP 5.2-200708290830 (from CVS) I just got a "Segmentation fault" but strace shows that the socket still returns with "Operation now in progress"

-------- SOME OTHER INFORMATIONS --------
# php -i |fgrep configure
Configure Command =>  './configure'  '--with-zlib' '--with-mysql' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-track-vars' '--enable-ftp' '--with-snmp' '--enable-pcntl' '--enable-sockets' '--with-config-file-path=/www/conf' '--with-mime-magic' '--with-ldap' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-freetype-dir=/usr/local/lib' '--with-png-dir=/usr/lib' '--with-libxml-dir=/usr/lib' '--enable-mbstring' '--with-sybase-ct=/usr/local/freetds'

webserver_dev conf # php -v
PHP 5.2.4RC4-dev (cli) (built: Aug 29 2007 11:28:47)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


I will try to give you an gdb backtrace of the "segmentation fault".

Reproduce code:
---------------
<?php

$ssh_con = ssh2_connect('84.38.64.78');
$fingerprint = ssh2_fingerprint($ssh_con, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);

echo $fingerprint

?>

But please use your own SSH server! My firewall may drop your requests ;-)

Expected result:
----------------
successfully connect to the ssh server

Actual result:
--------------
socket returns with "Operation now in progress" and ssh2_connect returns FALSE and an PHP Warning that connect is not possible

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-30 05:54 UTC] daniel dot buschke at nextiraone dot de
Ah, ok, the "Segmentation fault" problem is "solved" after completly reinstall php and ssh2... But the connection problem still exists:

webserver_dev sandbox # socksify php -f ssh.php
PHP Warning:  ssh2_connect(): Unable to connect to 84.38.64.78 on port 22 in /www/vhosts/dev/sandbox/ssh.php on line 3
PHP Warning:  ssh2_connect(): Unable to connect to 84.38.64.78 in /www/vhosts/dev/sandbox/ssh.php on line 3
PHP Warning:  ssh2_fingerprint() expects parameter 1 to be resource, boolean given in /www/vhosts/dev/sandbox/ssh.php on line 4


# strace -enetwork socksify php -f ssh.php
[...]
connect(6, {sa_family=AF_INET, sin_port=htons(1080), sin_addr=inet_addr("10.248.2.193")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockname(3, {sa_family=AF_INET, sin_port=htons(49360), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
getsockname(3, {sa_family=AF_INET, sin_port=htons(49360), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
sendmsg(4, {msg_name(0)=NULL, msg_iov(1)=[{"\3\0\0\0\1\231\361\267\0\0\0\0$\370\366\267\1\0\0\0\0\0"..., 3076}], msg_controllen=16, {cmsg_len=16, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, {6}}, msg_flags=MSG_OOB|MSG_DONTROUTE|MSG_TRUNC|MSG_ERRQUEUE|MSG_DONTWAIT|MSG_CONFIRM|MSG_FIN|MSG_SYN|MSG_NOSIGNAL|0x20740000}, 0) = 3076
--- SIGCHLD (Child exited) @ 0 (0) ---
getsockname(6, {sa_family=AF_INET, sin_port=htons(51812), sin_addr=inet_addr("10.138.137.15")}, [16]) = 0
getpeername(6, {sa_family=AF_INET, sin_port=htons(1080), sin_addr=inet_addr("10.248.2.193")}, [16]) = 0
getsockname(3, {sa_family=AF_INET, sin_port=htons(51812), sin_addr=inet_addr("10.138.137.15")}, [16]) = 0
getpeername(3, {sa_family=AF_INET, sin_port=htons(1080), sin_addr=inet_addr("10.248.2.193")}, [16]) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
PHP Warning:  ssh2_connect(): Unable to connect to 84.38.64.78 on port 22 in /www/vhosts/dev/sandbox/ssh.php on line 3
PHP Warning:  ssh2_connect(): Unable to connect to 84.38.64.78 in /www/vhosts/dev/sandbox/ssh.php on line 3
PHP Warning:  ssh2_fingerprint() expects parameter 1 to be resource, boolean given in /www/vhosts/dev/sandbox/ssh.php on line 4
Process 31871 detached
 [2012-06-22 15:22 UTC] langemeijer@php.net
-Status: Open +Status: Wont fix
 [2012-06-22 15:22 UTC] langemeijer@php.net
Daniel, this is too much of an edge-case problem. You could try and see if the 
problem is solved by using a newer version of ssh2, libssh2 and dante.

I'm not going to spend my time on this. If you can supply a patch I'm happy to 
help.
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 29 14:03:41 2023 UTC