简体   繁体   English

使用phpseclib时出现“分段错误”

[英]“Segmentation fault” when using phpseclib

I downloaded phpseclib-0.3.10 from http://phpseclib.sourceforge.net/ 我从http://phpseclib.sourceforge.net/下载了phpseclib-0.3.10

My php Version : PHP 5.2.4 我的PHP版本: PHP 5.2.4

OS : CentOS release 6.6 操作系统:CentOS版本6.6

When I run following I am getting "Segmentation fault" at this line $ssh->login('username', 'password') 当我运行以下时,我在此行获得“分段错误” $ssh->login('username', 'password')

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
$ssh=new Net_SSH2('servername');
if (!$ssh->login('username', 'password')) {
     exit('Login Failed');
}
echo $ssh->exec('pwd');
?>

I am unable find the reason for this issue. 我无法找到这个问题的原因。 Could you please help me to find the reason for this. 你能帮我找到原因吗?

My guess: either the fsockopen() call or the stream_select() call. 我的猜测:fsockopen()调用或stream_select()调用。 You can figure it out by putting die()'s in your code at successive points within login() and the functions called therein. 您可以通过在login()中的连续点和其中调用的函数中将die()放入代码中来解决这个问题。

Looking it up... login() calls _login(): 查找... login()调用_login():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1801 https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1801

_login() calls _connect(): _login()调用_connect():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1817 https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1817

eg. 例如。 before line 964 in Net/SSH2.php add die('this far') . 在Net / SSH2.php第964行之前添加die('this far') If it says "this far" then try adding it after. 如果它说“这么远”,那么尝试添加它。 If you get a seg fault when it's after but not before that probably means it's the fsockopen that's to blame. 如果你遇到了一个段错误,那么它可能意味着它应该归咎于fsockopen。

And just keep on doing that until you get the seg fault. 并继续这样做,直到你得到seg故障。 Do a die('this far'); die('this far'); before and after the stream_select and just where-ever. 在stream_select之前和之后以及其他地方。 And then post the line you're getting it on. 然后发布你正在接收它的行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM