git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: 2313828) | patch
More use of getpwuid_r() directly
Mon, 2 Sep 2024 06:16:25 +0000 (08:16 +0200)
Mon, 2 Sep 2024 07:04:30 +0000 (09:04 +0200)
commit 4d5111b3f1a151faf8129e38f8424898588e606d
More use of getpwuid_r() directly

Remove src/port/user.c, call getpwuid_r() directly. This reduces some
complexity and allows better control of the error behavior. For
example, the old code would in some circumstances silently truncate
the result string, or produce error message strings that the caller
wouldn't use.

src/port/user.c used to be called src/port/thread.c and contained
various portability complications to support thread-safety. These are
all obsolete, and all but the user-lookup functions have already been
removed. This patch completes this by also removing the user-lookup
functions.

Also convert src/backend/libpq/auth.c to use getpwuid_r() for
thread-safety.

Originally, I tried to be overly correct by using
sysconf(_SC_GETPW_R_SIZE_MAX) to get the buffer size for getpwuid_r(),
but that doesn't work on FreeBSD. All the OS where I could find the
source code internally use 1024 as the suggested buffer size, so I
just ended up hardcoding that. The previous code used BUFSIZ, which
is an unrelated constant from stdio.h, so its use seemed
inappropriate.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/5f293da9-ceb4-4937-8e52-82c25db8e4d3%40eisentraut.org
src/backend/libpq/auth.c diff | blob | blame | history
src/bin/psql/nls.mk diff | blob | blame | history
src/include/port.h diff | blob | blame | history
src/interfaces/libpq/fe-auth.c diff | blob | blame | history
src/interfaces/libpq/fe-connect.c diff | blob | blame | history
src/interfaces/libpq/nls.mk diff | blob | blame | history
src/port/Makefile diff | blob | blame | history
src/port/meson.build diff | blob | blame | history
src/port/path.c diff | blob | blame | history
src/port/user.c [deleted file] blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /