pgsql: Fix assorted issues in backend's GSSAPI encryption support. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix assorted issues in backend's GSSAPI encryption support.
Date
Msg-id E1ku1Tt-0006OT-GL@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix assorted issues in backend's GSSAPI encryption support.

Unrecoverable errors detected by GSSAPI encryption can't just be
reported with elog(ERROR) or elog(FATAL), because attempting to
send the error report to the client is likely to lead to infinite
recursion or loss of protocol sync.  Instead make this code do what
the SSL encryption code has long done, which is to just report any
such failure to the server log (with elevel COMMERROR), then pretend
we've lost the connection by returning errno = ECONNRESET.

Along the way, fix confusion about whether message translation is done
by pg_GSS_error() or its callers (the latter should do it), and make
the backend version of that function work more like the frontend
version.

Avoid allocating the port->gss struct until it's needed; we surely
don't need to allocate it in the postmaster.

Improve logging of "connection authorized" messages with GSS enabled.
(As part of this, I back-patched the code changes from dc11f31a1.)

Make BackendStatusShmemSize() account for the GSS-related space that
will be allocated by CreateSharedBackendStatus().  This omission
could possibly cause out-of-shared-memory problems with very high
max_connections settings.

Remove arbitrary, pointless restriction that only GSS authentication
can be used on a GSS-encrypted connection.

Improve documentation; notably, document the fact that libpq now
prefers GSS encryption over SSL encryption if both are possible.

Per report from Mikael Gustavsson.  Back-patch to v12 where
this code was introduced.

Discussion: https://postgr.es/m/e5b0b6ed05764324a2f3fe7acfc766d5@smhi.se

Branch
------
REL_13_STABLE

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

Modified Files
--------------
doc/src/sgml/client-auth.sgml        | 123 ++++++++++++++++++-----------------
doc/src/sgml/libpq.sgml              |  19 ++++++
doc/src/sgml/protocol.sgml           |  42 +++++++-----
doc/src/sgml/runtime.sgml            |  12 +++-
src/backend/libpq/auth.c             |  35 +++++-----
src/backend/libpq/be-gssapi-common.c |  51 ++++++++++-----
src/backend/libpq/be-secure-gssapi.c |  98 ++++++++++++++++++++--------
src/backend/libpq/be-secure.c        |   4 +-
src/backend/libpq/hba.c              |  19 ++----
src/backend/libpq/pqcomm.c           |  27 ++++----
src/backend/postmaster/pgstat.c      |  12 +++-
src/backend/postmaster/postmaster.c  |  37 ++---------
src/backend/utils/init/postinit.c    |  89 +++++++++++--------------
src/include/libpq/be-gssapi-common.h |   2 +-
src/include/libpq/libpq-be.h         |   5 +-
15 files changed, 322 insertions(+), 253 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix bugs in libpq's GSSAPI encryption support.
Next
From: Michael Paquier
Date:
Subject: pgsql: doc: Improve description of min_dynamic_shared_memory