pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.
Date: 2025-10-05 20:28:06
Message-ID: E1v5VKw-000E3p-0q@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

On Windows, this code did not handle error conditions correctly at
all, since it looked at "errno" which is not used for socket-related
errors on that platform. This resulted, for example, in failure
to connect to a PostgreSQL server with GSSAPI enabled.

We have a convention for dealing with this within libpq, which is to
use SOCK_ERRNO and SOCK_ERRNO_SET rather than touching errno directly;
but the GSSAPI code is a relative latecomer and did not get that memo.
(The equivalent backend code continues to use errno, because the
backend does this differently. Maybe libpq's approach should be
rethought someday.)

Apparently nobody tries to build libpq with GSSAPI support on Windows,
or we'd have heard about this before, because it's been broken all
along. Back-patch to all supported branches.

Author: Ning Wu <ning94803(at)gmail(dot)com>
Co-authored-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAFGqpvg-pRw=cdsUpKYfwY6D3d-m9tw8WMcAEE7HHWfm-oYWvw@mail.gmail.com
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ea78bd6d5d0f18c09db1e3ec6fd19be38d706030

Modified Files
--------------
src/interfaces/libpq/fe-secure-gssapi.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-10-06 02:24:53 pgsql: Fix two comments in numeric.c
Previous Message Álvaro Herrera 2025-10-05 16:41:07 pgsql: Don't include access/htup_details.h in executor/tuptable.h