[php-maint] Bug#773182: Bug#773182: Problem solved

Friedhelm Mehnert friedhelm at friedhelms.net
Tue Dec 23 16:38:04 UTC 2014


On Tue, Dec 23, 2014 at 08:54:01AM +0100, Thijs Kinkhorst wrote:
> 
> It's quite harsh to tell the volunteers that maintain this package that
> we're "obviously not interested at all" when we did not yet respond within
> only one week after filing the bug...
> 
> Please share your solution and help improve free software. It will be
> processed in due time, if not sooner then certainly later.
> 
> 
> Cheers,
> Thijs


Well, that's how things seem to be these days. By asking nicely one does
not archive anything anymore. Once you get pissed, get unfriendly, and
start anoying people, *then* you'll get an answer! :-)

I'm not a programmer. I do not have the resources, to compile php-5 from
source and try the fixes out.

Anyway, let me try to explain:

I have recently updatet a production-machine from Squeeze-lts to Wheezy.
Squeeze has Postgresql 8.4.

So, after the update, I thougt it would be a good idea to update to the
"Wheezy-Version" Postgresql 9.1 as well. So I did, using the
pg_updatecluster methode as outlined in the README.Debian, which worked
like a charm. Everything was working as expected...

Well nearly everthing. After the upgrade my application could not get
the BLOBs from the database. The files had zero length and were empty.

So I put some debuging code into my application, which showed, that the
pg_lo-export function returned TRUE (success), but produced empty files.

So I purged the new version and restored the old version from backup.

I looked at the documentation, which came with the new version, but did
not find the slitest hint on what might be wrong.

Several days later I found the *course* of the problem within the
online-documentation for Postgresql 9.0!

There it was. BLOBs now have "permissions"! To be able to retrieve them
you have to grant at least "select" permission to the user the
web-browser runs as on each and every single object!

So I upgraded again, picked one BLOB, granted the permission and --
bingo -- it worked! So I had to write a script, to grant the permissions
to all the 700+ BLOBs within my database and things worked again.

So knowning the *cause* of the problem still leaves us with a bug.

The pg_lo_export function returnes TRUE and silently produces unusable
files, if the BLOB lacks the needed permissions. It *should* rather
return FALSE in this case.

I have looked at the source and I *think* line 3504 within the source
file php5-5.4.4/ext/pgsql/pgsql.c which looks now as follows:

   3504         if (lo_export(pgsql, oid, file_out)) {
   3505                 RETURN_TRUE;
   3506         }
   3507         RETURN_FALSE;
   3508 }

should be changed to:

   3504        if (lo_export(pgsql, oid, file_out) == 1) {

I have *not* tested this. Also I can not prove, that the lo_export
function actually returnes -1 in this case, as it should. Furthermore it
is possible, that other functions within the pgsql module have the same
problem.

I hope this lengthy explanation is good enough, so someone who is able
to compile from source and test it can fix this bug.

Best Regards
Friedhelm



More information about the pkg-php-maint mailing list