[horde] VFS SSH2 download problem

Steffen skhorde at smail.inf.fh-bonn-rhein-sieg.de
Thu Oct 17 13:14:35 UTC 2013


On Mon, 14 Oct 2013, Jan Schneider wrote:

> Date: Mon, 14 Oct 2013 15:55:15 +0200
> From: Jan Schneider <jan at horde.org>
> To: horde at lists.horde.org
> Subject: Re: [horde] VFS SSH2 download problem
> 
>
> Zitat von Steffen <skhorde at smail.inf.fh-bonn-rhein-sieg.de>:
>
>> On Wed, 9 Oct 2013, Jan Schneider wrote:
>> 
>>> Zitat von Steffen <skhorde at smail.inf.fh-bonn-rhein-sieg.de>:
>>> 
>>>> Hi,
>>>> 
>>>> I've configured Gollem to use the SSH2 backend, with
>>>> 
>>>> $backends['ssh2']['disabled'] = false;
>>>> $backends['ssh2']['name'] = <host>;
>>>> $backends['ssh2']['hordeauth'] = 'full';
>>>> $backends['ssh2']['params']['hostspec'] = <host>;
>>>> $backends['ssh2']['params']['timeout'] = 20;
>>>> 
>>>> $backends['ssh2']['home'] = '/';
>>>> $backends['ssh2']['params']['vfsroot'] =
>>>> '/home/'.$GLOBALS['registry']->getAuth();
>>>> 
>>>> All operations seems to work, except "download", "edit" and the like.
>>>> If I leave the parameters home and vfsroot unconfigured, the problem 
>>>> remains.
>>>> 
>>>> When I try to download a file, Horde Vfs Ssh2 readStream() is called, the 
>>>> generated URL looks OK: ssh2.sftp://<user>:<pwd>@<host>:22/<path>//<file>
>>>> 
>>>> but the Apache process surfing my request allocates 100% CPU and 
>>>> endlessly calls recvfrom/sendto syscalls with data actually. The file 
>>>> descriptor of the syscalls is the SSH connection.
>>>> 
>>>> If I assemble a test PHP script like this:
>>>> 
>>>> $fp = fopen('ssh2.sftp://URL', 'r'); // The URL is a Copy'n'Paste from
>>>> 	// the log generated by:
>>>> 	// Horde::log("Vfs::Ssh2::fopen(".$this->_wrap($this->_getPath($path, 
>>>> $name)).")", 'ERR');
>>>> 
>>>> while ($line = fgets($fp, 100)) {
>>>> 	echo $line."<br />";
>>>> }
>>>> fclose($fp);
>>>> 
>>>> I get the file successfully.
>>>> 
>>>> If I comment out readStream() in /usr/share/php/Horde/Vfs/Ssh2.php to 
>>>> force the use of readFile(), I can download files successfully.
>>>> 
>>>> Can I do something to debug this issue further?
>>> 
>>> You can track this further down in Gollem_Application::download().
>> 
>> The problem is in /var/www/horde/services/download/index.php, the loop to 
>> read the file:
>> 
>> if (is_resource($res['data'])) {
>>    rewind($res['data']);
>>    while (!feof($res['data'])) {
>>        echo fread($res['data'], 8192);
>>    }
>>    fclose($res['data']);
>> 
>> seems to hit this bug (or something similiar) 
>> https://bugs.php.net/bug.php?id=59138, I use Debian Squeeze with packaged 
>> libssh2-php 0.11.0-2.1. feof() never returns true.
>> 
>> fgets() works, as shown in my sample script, e.g.:
>> 
>> while ($line = fgets($fp, 100)) {
>> 	echo $line."<br />";
>> }
>> if(feof($fp)) {
>> 	echo "EOF\n";
>> } else {
>> 	echo "NO EOF!!!\n";
>> }
>> 
>> triggers "no eof", but stops eventually.
>> 
>> I upgraded the ssh2 extension with
>> 
>> pecl install -a "channel://pecl.php.net/ssh2-0.12"
>> 
>> , because there is no newer package for Squeeze. Now the 
>> while(feof($res['data'])) loop terminates.
>> 
>> Maybe you add a check & warning about the version number of the ssh2 
>> extension to test.php or something?
>> 
> Which version did you run earlier?

The one prepacked with Debian Squeeze: libssh2-php 0.11.0-2.1

-- 
Steffen


More information about the horde mailing list