Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvkRM-0006xn-5Z for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Feb 2019 15:02:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gvkRJ-0005eP-Pv for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Feb 2019 15:02:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvkRJ-0005e6-IE for pgsql-hackers@lists.postgresql.org; Mon, 18 Feb 2019 15:02:37 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvkRG-0003VT-Lg for pgsql-hackers@postgresql.org; Mon, 18 Feb 2019 15:02:37 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84040C0C4276; Mon, 18 Feb 2019 15:02:31 +0000 (UTC) Received: from localhost (ovpn-112-52.rdu2.redhat.com [10.10.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 731A45D978; Mon, 18 Feb 2019 15:02:30 +0000 (UTC) From: Robbie Harwood To: Andres Freund Cc: pgsql-hackers@postgresql.org, Stephen Frost , Nico Williams , Michael Paquier , Alvaro Herrera , David Steele Subject: Re: [PATCH v20] GSSAPI encryption support In-Reply-To: <20190216041026.gpkfn4e6wrozliyb@alap3.anarazel.de> References: <20190216041026.gpkfn4e6wrozliyb@alap3.anarazel.de> Date: Mon, 18 Feb 2019 10:02:27 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 18 Feb 2019 15:02:31 +0000 (UTC) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Andres Freund writes: > On 2018-12-18 14:12:46 -0500, Robbie Harwood wrote: > >> Subject: [PATCH] libpq GSSAPI encryption support > > Could some of these be split into separate patches that could be more > eagerly merged? This is a somewhat large patch... What splits do you propose? (It's been a single patch since v3 as per your request in id:20151003161810.GD30738@alap3.anarazel.de and Michael Paquier's request in id:CAB7nPqTJD-tTrM1Vu8P55_4kKVeDX8DFz9v1D_XsQQvR_xA5qQ@mail.gmail.com). >> diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-= secure.c >> index a06fc7dc82..f4f196e3b4 100644 >> --- a/src/interfaces/libpq/fe-secure.c >> +++ b/src/interfaces/libpq/fe-secure.c >> @@ -220,6 +220,13 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len) >> n =3D pgtls_read(conn, ptr, len); >> } >> else >> +#endif >> +#ifdef ENABLE_GSS >> + if (conn->gssenc) >> + { >> + n =3D pg_GSS_read(conn, ptr, len); >> + } >> + else >> #endif >> { >> n =3D pqsecure_raw_read(conn, ptr, len); >> @@ -287,7 +294,7 @@ pqsecure_raw_read(PGconn *conn, void *ptr, size_t le= n) >> * to determine whether to continue/retry after error. >> */ >> ssize_t >> -pqsecure_write(PGconn *conn, const void *ptr, size_t len) >> +pqsecure_write(PGconn *conn, void *ptr, size_t len) >> { >> ssize_t n; >>=20=20 >> @@ -297,6 +304,13 @@ pqsecure_write(PGconn *conn, const void *ptr, size_= t len) >> n =3D pgtls_write(conn, ptr, len); >> } >> else >> +#endif >> +#ifdef ENABLE_GSS >> + if (conn->gssenc) >> + { >> + n =3D pg_GSS_write(conn, ptr, len); >> + } >> + else >> #endif >> { >> n =3D pqsecure_raw_write(conn, ptr, len); > > Not a fan of this. Seems like we'll grow more and more such branches > over time? Wouldn't the right thing be to have callbacks in PGconn > (and similarly in the backend)? Is that really a problem? Each branch is only seven lines, which is a lot less than adding callback support will be. And we'll only get a new branch when we want to support a new encryption protocol - unlike authentication, there aren't too many of those. > Seems like if that's done reasonably it'd also make integration of > compression easier, because that could just layer itself between > encryption and wire? The current interface would allow a compress/decompress call in a way that makes sense to me (here for write, ignoring ifdefs): ssize_t pqsecure_write(PGConn *conn, void *ptr, size_t len) { ssize_t n; if (conn->compress) { do_compression(conn, &ptr, &len); } if (conn->ssl_in_use) { n =3D pgtls_write(conn, ptr, len); } else if (conn->gssenc) { n =3D pg_GSS_write(conn, ptr, len); } else { n =3D pqsecure_raw_write(conn, ptr, len); } return n; } (pqsecure_read would look similarly, with decompression as the last step instead of the first.) Thanks, =2D-Robbie --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEA5qc6hnelQjDaHWqJTL5F2qVpEIFAlxqyQMACgkQJTL5F2qV pELRWhAAqiBWRna/YlUHISVAXZqPT1jTJV7os/b7A/f8fs2B1R7Kx0K1qNkpmn8w 3dN48AoQlOLFB8ynOOwybk1dRjwSRqnmF4CWFoVA5yNx0bGWc+11ILS7mFNUehhW FM+Kt96MEn3XnAEL3hjhH2dclD44b4c6Z3oJ/kSlqCX+QJBd1vt4cB3xUtnZfHjR VIF7RJGn71YLYrNNyZ3crUih2MrcLEmxcDG9DgVFeJYGF+HzpV6Ym9NmI8M19gES z01p2AVsd0bGykyXTdzXg1C5i0DV1AEaED2uFvb9NCAXWEIO5XIPM/8UFS7hOysq jrC5UUC2/OUJohwyiPT+e2yhEy9BsSq0G1UC/z0+ioueLpAKjf3eHX3C4/Dxgybu biiuQRis9srHQb5uCjsOqbASfy0btAV0VC0QOIMipWRLbdtaT3KdmxRbVMGzqs0T 9jeA3kn0UbpxArqQZlRwHglXWQTF7iTAdI1G2CDLFDeAuA8p6l/gvlGui32dmwDJ 2AOW8Xxj9uyN2jPDXKujiq2ZueC4zKtIPFxO5VanDv8t5MpmJdhmo3l55SjY4O0V oBr5LS9qG67RAZDYxVgdLDJuWiP/RyyLLqTruBn5UUF6bmhuhTPXM0PoxVK8Escw x/f7D+EGNpu8Ofn7BOHH76bKAyyNKve4bshVUbN3cX2H01ahufU= =6T6T -----END PGP SIGNATURE----- --=-=-=--