pgsql: Properly unregister OpenSSL callbacks when libpq is done with

Lists: pgsql-committerspgsql-hackers
From: mha(at)postgresql(dot)org (Magnus Hagander)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-03 20:04:27
Message-ID: 20081203200427.0A23B7545A4@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Log Message:
-----------
Properly unregister OpenSSL callbacks when libpq is done with
it's connection. This is required for applications that unload
the libpq library (such as PHP) in which case we'd otherwise
have pointers to these functions when they no longer exist.

This needs a bit more testing before we can consider a backpatch,
so not doing that yet.

In passing, remove unused functions in backend/libpq.

Bruce Momjian and Magnus Hagander, per report and analysis
by Russell Smith.

Modified Files:
--------------
pgsql/src/backend/libpq:
be-secure.c (r1.86 -> r1.87)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/libpq/be-secure.c?r1=1.86&r2=1.87)
pgsql/src/interfaces/libpq:
fe-secure.c (r1.110 -> r1.111)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-secure.c?r1=1.110&r2=1.111)


From: Kris Jurka <books(at)ejurka(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-04 02:42:43
Message-ID: 493743A3.2010909@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Magnus Hagander wrote:
> Log Message:
> -----------
> Properly unregister OpenSSL callbacks when libpq is done with
> it's connection. This is required for applications that unload
> the libpq library (such as PHP) in which case we'd otherwise
> have pointers to these functions when they no longer exist.

Breaks the build with --enable-thread-safety and --with-openssl because
of this typo.

Kris Jurka

Attachment Content-Type Size
fix-libpq-threaded-ssl.patch text/x-patch 481 bytes

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-04 02:52:39
Message-ID: 200812040252.mB42qdY18269@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Kris Jurka wrote:
> Magnus Hagander wrote:
> > Log Message:
> > -----------
> > Properly unregister OpenSSL callbacks when libpq is done with
> > it's connection. This is required for applications that unload
> > the libpq library (such as PHP) in which case we'd otherwise
> > have pointers to these functions when they no longer exist.
>
> Breaks the build with --enable-thread-safety and --with-openssl because
> of this typo.

Thanks, applied.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Kris Jurka <books(at)ejurka(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-04 14:08:13
Message-ID: 4937E44D.6070008@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Bruce Momjian wrote:
> Kris Jurka wrote:
>> Magnus Hagander wrote:
>>> Log Message:
>>> -----------
>>> Properly unregister OpenSSL callbacks when libpq is done with
>>> it's connection. This is required for applications that unload
>>> the libpq library (such as PHP) in which case we'd otherwise
>>> have pointers to these functions when they no longer exist.
>> Breaks the build with --enable-thread-safety and --with-openssl because
>> of this typo.
>
> Thanks, applied.

That fix is wrong.

The comment clearly says the code *shouldn't* free the lockarray, so the
proper fix is to remove those two lines.

I have applied a patch that does this.

//Magnus


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [COMMITTERS] pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-08 20:45:58
Message-ID: 946.1228769158@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

[ still catching up on back email ]

mha(at)postgresql(dot)org (Magnus Hagander) writes:
> Properly unregister OpenSSL callbacks when libpq is done with
> it's connection. This is required for applications that unload
> the libpq library (such as PHP) in which case we'd otherwise
> have pointers to these functions when they no longer exist.

I find it fairly disturbing that this patch was committed with a bug
that ensured it wouldn't even compile for the case of SSL and
THREAD_SAFETY both enabled. Which one would think would have been
the primary case to test. Would anyone like to reassure us why this
patch shouldn't just be reverted in toto until it's actually been
tested a bit?

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [COMMITTERS] pgsql: Properly unregister OpenSSL callbacks when libpq is done with
Date: 2008-12-08 20:49:49
Message-ID: 493D886D.305@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Tom Lane wrote:
> [ still catching up on back email ]
>
> mha(at)postgresql(dot)org (Magnus Hagander) writes:
>> Properly unregister OpenSSL callbacks when libpq is done with
>> it's connection. This is required for applications that unload
>> the libpq library (such as PHP) in which case we'd otherwise
>> have pointers to these functions when they no longer exist.
>
> I find it fairly disturbing that this patch was committed with a bug
> that ensured it wouldn't even compile for the case of SSL and
> THREAD_SAFETY both enabled. Which one would think would have been
> the primary case to test. Would anyone like to reassure us why this
> patch shouldn't just be reverted in toto until it's actually been
> tested a bit?

The patch itself was tested. I applied the wrong version of the patch to
the main tree when I moved it from my testing tree to the one where I
apply it from :-( (which was configured without thread-safety)

That part was also included in the part of the patch that was tested by
the PHP guy who originally reported the problem.

//Magnus