[horde] VFS ssh2 _listFolder() buglet?

Lawrence Stewart lstewart at room52.net
Thu Jan 6 16:01:39 UTC 2011


Hi all,

Whilst switching my Gollem config over to using the ssh2 backend, I
think I've found a bug in the ssh2 VFS code. I got the Gollem config to
the point where I could successfully upload files, but the directory
listing would always claim the directory to be empty without any sort of
error logged in the horde log file.

After a bit of sleuthing, I tracked the offending line of code to:

$stream = @ssh2_exec($this->_stream, 'LC_TIME=C ls -' . $ls_args . ' ' .
escapeshellarg($path));

(Horde v3.3.11, line 489 of lib/VFS/ssh2.php)

I use FreeBSD as the server OS and tcsh as my shell. Prefixing the
command with an ENV=VAR assignment only works on Bourne type shells. It
seems the sftp server on FreeBSD runs the command in the context of the
user's selected shell as opposed to /bin/sh, because the offending line
produces no output as a result of the command failing.

My solution fixes the problem for me and I believe is more correct than
the current code. By prefixing the ls command with "env", all shells
including tcsh are happy i.e.:

$stream = @ssh2_exec($this->_stream, 'env LC_TIME=C ls -' . $ls_args . '
' . escapeshellarg($path));

Prefixing with env allows everything to work perfectly for me.

Does the above seem reasonable or have I misunderstood something? I'll
file a bug report with the patch if people think my analysis is correct.

Cheers,
Lawrence

PS: I haven't looked, but I suspect there could be instances of other
such problems in the tree. It would be useful to do an audit of command
lines run by horde to look for others which set env vars in the same
manner as the above code.


More information about the horde mailing list