postgresql/src
Tom Lane ff6ce9a3a6 Fix bugs in libpq's GSSAPI encryption support.
The critical issue fixed here is that if a GSSAPI-encrypted connection
is successfully made, pqsecure_open_gss() cleared conn->allow_ssl_try,
as an admittedly-hacky way of preventing us from then trying to tunnel
SSL encryption over the already-encrypted connection.  The problem
with that is that if we abandon the GSSAPI connection because of a
failure during authentication, we would not attempt SSL encryption
in the next try with the same server.  This can lead to unexpected
connection failure, or silently getting a non-encrypted connection
where an encrypted one is expected.

Fortunately, we'd only manage to make a GSSAPI-encrypted connection
if both client and server hold valid tickets in the same Kerberos
infrastructure, which is a relatively uncommon environment.
Nonetheless this is a very nasty bug with potential security
consequences.  To fix, don't reset the flag, instead adding a
check for conn->gssenc being already true when deciding whether
to try to initiate SSL.

While here, fix some lesser issues in libpq's GSSAPI code:

* Use the need_new_connection stanza when dropping an attempted
GSSAPI connection, instead of partially duplicating that code.
The consequences of this are pretty minor: AFAICS it could only
lead to auth_req_received or password_needed remaining set when
they shouldn't, which is not too harmful.

* Fix pg_GSS_error() to not repeat the "mprefix" it's given multiple
times, and to notice any failure return from gss_display_status().

* Avoid gratuitous dependency on NI_MAXHOST in
pg_GSS_load_servicename().

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

Discussion: https://postgr.es/m/e5b0b6ed05764324a2f3fe7acfc766d5@smhi.se
2020-12-28 15:43:44 -05:00
..
backend Fix inconsistent code with shared invalidations of snapshots 2020-12-28 22:16:49 +09:00
bin Revert "Add key management system" (978f869b99) & later commits 2020-12-27 21:37:42 -05:00
common Revert "Add key management system" (978f869b99) & later commits 2020-12-27 21:37:42 -05:00
fe_utils Remove incorrect %s in string 2020-11-09 10:38:22 +01:00
include Revert "Add key management system" (978f869b99) & later commits 2020-12-27 21:37:42 -05:00
interfaces Fix bugs in libpq's GSSAPI encryption support. 2020-12-28 15:43:44 -05:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Further fix thinko in plpgsql memory leak fix. 2020-12-28 11:55:23 -05:00
port Remove ability to independently select random number generator 2020-11-20 13:57:33 +01:00
template On macOS, use -isysroot in link steps as well as compile steps. 2020-11-20 00:07:09 -05:00
test Second attempt to stabilize 05c02589. 2020-12-27 12:09:00 -08:00
timezone Improve hash_create()'s API for some added robustness. 2020-12-15 11:38:53 -05:00
tools Revert "Add key management system" (978f869b99) & later commits 2020-12-27 21:37:42 -05:00
tutorial Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Split Makefile symbol CFLAGS_VECTOR into two symbols. 2020-09-06 21:28:16 -04:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00