Re: libpq not reentrant - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: libpq not reentrant
Date
Msg-id 200201181912.g0IJCAP03030@candle.pha.pa.us
Whole thread Raw
In response to Re: libpq not reentrant  (Peter Eisentraut <peter_e@gmx.net>)
List 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@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: postgres error on debian woody
Next
From: Federico Di Gregorio
Date:
Subject: Re: postgres error on debian woody