[PATCH] Bug in lib/VFS/ssh2.php and ingo/lib/Driver/vfs.php?

View: New views
3 Messages — Rating Filter:   Alert me  

[PATCH] Bug in lib/VFS/ssh2.php and ingo/lib/Driver/vfs.php?

by Bugzilla from lstewart@room52.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

Updating and reading of my .procmailrc file via Ingo stopped working
after a recent system update to Horde 3.3.5/Ingo 1.2.2. After realising
the "vfs_path" param was now required in Ingo's config/backends.php file
(used to work without it), there were still issues retrieving the active
script.

I tracked the problem to the 2 files mentioned in the subject. The
attached "ingo_fixread.diff" patch updates the vfs->read() call Ingo
makes to try and retrieve the active script file. The patch makes the
read() call pass parameters in the way the VFS code seems to expect them
(gleaned from observing how the write code path works). I believe things
may work without this patch but it seems to be more correct this way to me.

The attached "horde_sshfilesizefix.diff" patch addresses the fact that
even though the active script file was being successfully pulled via ssh
and created as a local tmpfile, the filesize() check on the local
tmpfile would always return 0, even though the tmpfile actually
contained data (verified by hacking source code to dump contents of
tmpfile into a separate file). It seems some prior calls to PHP
functions that call the underlying OS stat() routine were caching the
filesize at 0 (before it had been populated), and this in turn meant the
script would not be successfully displayed to the user. Clearing the
stat cache fully mitigates the issue for me.

With these two patches applied, everything is peachy again. For
posterity's sake, my working Ingo backends.php config is included at the
end of the email.

Cheers,
Lawrence





$backends['procmail'] = array(
     'driver' => 'vfs',
     'preferred' => '',
     'hordeauth' => true,
     'params' => array(
         'hostspec' => '127.0.0.1',
         'filename' => '.procmailrc',
         'port' => 22,
         'vfs_path' => '/home/%U',
         'vfstype' => 'ssh2'
     ),
     'script' => 'procmail',
     'scriptparams' => array(
         'path_style' => 'mbox',
         'variables' => array(
             'MAILDIR' => '$HOME/.mail',
         )
     )
);

--- lib/VFS/ssh2.php 2009-09-14 20:08:48.000000000 +1000
+++ lib/VFS/ssh2.php 2009-10-28 09:59:43.000000000 +1100
@@ -118,6 +118,7 @@
             return $file;
         }
 
+        clearstatcache();
         $size = filesize($file);
         if ($size === 0) {
             return '';

--- ingo/lib/Driver/vfs.php 2009-01-07 02:24:35.000000000 +1100
+++ ingo/lib/Driver/vfs.php 2009-10-28 09:55:57.000000000 +1100
@@ -105,7 +105,7 @@
         if (is_a($result, 'PEAR_Error')) {
             return $result;
         }
-        return $this->_vfs->read('', $this->_params['vfs_path'] . '/' . $this->_params['filename']);
+        return $this->_vfs->read($this->_params['vfs_path'], $this->_params['filename']);
     }
 
     /**

--
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@...

Re: [PATCH] Bug in lib/VFS/ssh2.php and ingo/lib/Driver/vfs.php?

by Jan Schneider :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Zitat von Lawrence Stewart <lstewart@...>:

> Hi All,
>
> Updating and reading of my .procmailrc file via Ingo stopped working  
> after a recent system update to Horde 3.3.5/Ingo 1.2.2. After  
> realising the "vfs_path" param was now required in Ingo's  
> config/backends.php file (used to work without it), there were still  
> issues retrieving the active script.
>
> I tracked the problem to the 2 files mentioned in the subject. The  
> attached "ingo_fixread.diff" patch updates the vfs->read() call Ingo  
> makes to try and retrieve the active script file. The patch makes  
> the read() call pass parameters in the way the VFS code seems to  
> expect them (gleaned from observing how the write code path works).  
> I believe things may work without this patch but it seems to be more  
> correct this way to me.
>
> The attached "horde_sshfilesizefix.diff" patch addresses the fact  
> that even though the active script file was being successfully  
> pulled via ssh and created as a local tmpfile, the filesize() check  
> on the local tmpfile would always return 0, even though the tmpfile  
> actually contained data (verified by hacking source code to dump  
> contents of tmpfile into a separate file). It seems some prior calls  
> to PHP functions that call the underlying OS stat() routine were  
> caching the filesize at 0 (before it had been populated), and this  
> in turn meant the script would not be successfully displayed to the  
> user. Clearing the stat cache fully mitigates the issue for me.
>
> With these two patches applied, everything is peachy again. For  
> posterity's sake, my working Ingo backends.php config is included at  
> the end of the email.
>
> Cheers,
> Lawrence
>
>
>
>
>
> $backends['procmail'] = array(
>     'driver' => 'vfs',
>     'preferred' => '',
>     'hordeauth' => true,
>     'params' => array(
>         'hostspec' => '127.0.0.1',
>         'filename' => '.procmailrc',
>         'port' => 22,
>         'vfs_path' => '/home/%U',
>         'vfstype' => 'ssh2'
>     ),
>     'script' => 'procmail',
>     'scriptparams' => array(
>         'path_style' => 'mbox',
>         'variables' => array(
>             'MAILDIR' => '$HOME/.mail',
>         )
>     )
> );
>


Please create a ticket on http://bugs.horde.org/.

Jan.

--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/

--
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@...

Re: [PATCH] Bug in lib/VFS/ssh2.php and ingo/lib/Driver/vfs.php?

by Bugzilla from lstewart@room52.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jan Schneider wrote:

> Zitat von Lawrence Stewart <lstewart@...>:
>
>> Hi All,
>>
>> Updating and reading of my .procmailrc file via Ingo stopped working
>> after a recent system update to Horde 3.3.5/Ingo 1.2.2. After
>> realising the "vfs_path" param was now required in Ingo's
>> config/backends.php file (used to work without it), there were still
>> issues retrieving the active script.
>>
>> I tracked the problem to the 2 files mentioned in the subject. The
>> attached "ingo_fixread.diff" patch updates the vfs->read() call Ingo
>> makes to try and retrieve the active script file. The patch makes the
>> read() call pass parameters in the way the VFS code seems to expect
>> them (gleaned from observing how the write code path works). I believe
>> things may work without this patch but it seems to be more correct
>> this way to me.
>>
>> The attached "horde_sshfilesizefix.diff" patch addresses the fact that
>> even though the active script file was being successfully pulled via
>> ssh and created as a local tmpfile, the filesize() check on the local
>> tmpfile would always return 0, even though the tmpfile actually
>> contained data (verified by hacking source code to dump contents of
>> tmpfile into a separate file). It seems some prior calls to PHP
>> functions that call the underlying OS stat() routine were caching the
>> filesize at 0 (before it had been populated), and this in turn meant
>> the script would not be successfully displayed to the user. Clearing
>> the stat cache fully mitigates the issue for me.
>>
>> With these two patches applied, everything is peachy again. For
>> posterity's sake, my working Ingo backends.php config is included at
>> the end of the email.
>>
>> Cheers,
>> Lawrence
>>
>>
>>
>>
>>
>> $backends['procmail'] = array(
>>     'driver' => 'vfs',
>>     'preferred' => '',
>>     'hordeauth' => true,
>>     'params' => array(
>>         'hostspec' => '127.0.0.1',
>>         'filename' => '.procmailrc',
>>         'port' => 22,
>>         'vfs_path' => '/home/%U',
>>         'vfstype' => 'ssh2'
>>     ),
>>     'script' => 'procmail',
>>     'scriptparams' => array(
>>         'path_style' => 'mbox',
>>         'variables' => array(
>>             'MAILDIR' => '$HOME/.mail',
>>         )
>>     )
>> );
>>
>
>
> Please create a ticket on http://bugs.horde.org/.

Tickets 8669 for the Horde patch and 8670 for the Ingo patch are now in
the bug tracker.

Cheers,
Lawrence
--
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@...