Re: Replace remaining getpwuid() calls with getpwuid_r()?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Lau <stevelauc(at)outlook(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Replace remaining getpwuid() calls with getpwuid_r()?
Date: 2025-07-10 05:48:39
Message-ID: 1466210.1752126519@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Steve Lau <stevelauc(at)outlook(dot)com> writes:
> 1. Will the thread-safety issue of getpwuid() affect Postgres? Why?

You have to pay attention to context. AFAICS the two extant calls
to getpwuid() are in

1. psql's exec_command_cd(). psql is not multithreaded and I'd
be surprised if there is a reason to make it so.

2. src/common/username.c's get_user_name(). This might be
problematic, but looking at the current usages I very much
doubt it. Most callers are non-multithreaded src/bin/ programs,
and the one server-side call is in single-user-mode startup,
and on top of that the call is only for geteuid() which will
not change within a given process anyway.

As Thomas mentioned, we are interested in converting the server
to multithreaded operation. But this quick survey does not
suggest that getpwuid() needs to be high on the list of things
to fix.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2025-07-10 06:05:21 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2
Previous Message Dilip Kumar 2025-07-10 05:48:08 Re: A recent message added to pg_upgade