Re: libpq not reentrant

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Federico Di Gregorio <fog(at)initd(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: libpq not reentrant
Date: 2002-01-18 19:12:10
Message-ID: 200201181912.g0IJCAP03030@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > As of 7.2 we are only going to recommend crypt for backward
> > compatibility with older releases. I will add a mention in libpq docs
> > that crypt authentication is not thread-safe. Even when crypt did work
> ^^^^^^
> "may not be"
>
> > it wasn't always portable between OS's. Is that how we want to go?

BSD/OS manual page says:

The crypt() function leaves its result in an internal static object and
returns a pointer to that object. Subsequent calls to crypt() will modi-
fy the same object.

The crypt() function may not be safely called concurrently from multiple
threads, e.g., the interfaces described by pthreads(3).

and the API is the same for all OS's. However, I looked in the Solaris
8 crypt() manual page and found:

http://docs.sun.com/ab2/coll.40.6/REFMAN3A/%40Ab2PageView/17377?Ab2Lang=C&Ab2Enc=iso-8859-1

In multithreaded applications, the return value is a pointer to
thread-specific data.

So here is at least one OS that has a thread-safe crypt, as you suggested.

I will mention crypt() relies on the OS's version of crypt(), which is
_may_not_be_ not thread-safe. I will then recommend MD5.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-01-18 19:12:15 Re: postgres error on debian woody
Previous Message Peter Eisentraut 2002-01-18 18:15:49 Re: libpq not reentrant