Re: Replace remaining getpwuid() calls with getpwuid_r()? - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Replace remaining getpwuid() calls with getpwuid_r()?
Date
Msg-id CA+hUKGLH_sDExwZ8dS3hg8J6ihQwS=4HLiQP+CADXhMBNvFDbg@mail.gmail.com
Whole thread Raw
In response to Replace remaining getpwuid() calls with getpwuid_r()?  (Steve Lau <stevelauc@outlook.com>)
List pgsql-hackers
On Thu, Jul 10, 2025 at 5:10 PM Steve Lau <stevelauc@outlook.com> wrote:
> Hi hackers, when reading the source code, I noticed that Postgres is still using getpwuid(), which is not thread-safe
sinceit returns a pointer to the static memory that can be overwritten by concurrent calls. Then I searched "getpwuid"
inthe mailing list[1], and there was a committed patch that refactored one such usage. So maybe we can clean up the
remaininggetpwuid() calls? 

+1, we should.

> Then I realized that Postgres does not use threads but processes, so technically IMHO getpwuid() is safe to Postgres?
Butthat patch mentioned that[2]: 

We would like to use threads, and many things like this are being
changed currently.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] PGSERVICEFILE as part of a normal connection string
Next
From: vignesh C
Date:
Subject: Re: A recent message added to pg_upgade