Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kY8Q6-0005y0-O9 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Oct 2020 13:56:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kY8Q5-00070V-Bo for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Oct 2020 13:56:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kY8Q5-0006zD-4q for pgsql-hackers@lists.postgresql.org; Thu, 29 Oct 2020 13:56:49 +0000 Received: from tamriel.snowman.net ([70.109.60.50]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kY8Pz-0007Pj-0J for pgsql-hackers@lists.postgresql.org; Thu, 29 Oct 2020 13:56:47 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 99D915F799; Thu, 29 Oct 2020 09:56:41 -0400 (EDT) Date: Thu, 29 Oct 2020 09:56:41 -0400 From: Stephen Frost To: vignesh C Cc: PostgreSQL Hackers Subject: Re: Log message for GSS connection is missing once connection authorization is successful. Message-ID: <20201029135641.GH16415@tamriel.snowman.net> References: <20201028161448.GE16415@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Aq4SrlNverAHn87R" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Aq4SrlNverAHn87R Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * vignesh C (vignesh21@gmail.com) wrote: > I have made a v2 patch based on the changes you have suggested. The > patch for the same is attached. > From b067cf823750f200102be0a0cad9a26a08e29a92 Mon Sep 17 00:00:00 2001 > From: Vignesh C > Date: Wed, 28 Oct 2020 08:19:06 +0530 > Subject: [PATCH v2] Log message for GSS connection is missing once connec= tion > authorization is successful. >=20 > Log message for GSS connection is missing once connection authorization is > successful. We have similar log message for SSL connections once the conn= ection > authorization is successful. This message will help the user to identify = the > connection that was selected from the logfile. Just to be clear- it's not that the message is 'missing', it's just not providing the (certainly useful) information about how the connection was authorized. The commit message should make it clear that what we're doing here is improving the connection authorization message for GSS authenticated or encrypted connections. > diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/p= ostinit.c > index d4ab4c7..7980e92 100644 > --- a/src/backend/utils/init/postinit.c > +++ b/src/backend/utils/init/postinit.c > @@ -267,6 +267,21 @@ PerformAuthentication(Port *port) > be_tls_get_compression(port) ? _("on") : _("off")))); > else > #endif > +#ifdef ENABLE_GSS > + if (be_gssapi_get_auth(port) || be_gssapi_get_princ(port)) > + ereport(LOG, > + (port->application_name !=3D NULL > + ? errmsg("replication connection authorized: user=3D%s applicatio= n_name=3D%s GSS %s (principal=3D%s)", > + port->user_name, > + port->application_name, > + be_gssapi_get_auth(port) || be_gssapi_get_enc(port) ? _("on") = : _("off"), > + be_gssapi_get_princ(port)) > + : errmsg("replication connection authorized: user=3D%s GSS %s (pr= incipal=3D%s)", > + port->user_name, > + be_gssapi_get_auth(port) || be_gssapi_get_enc(port) ? _("on") = : _("off"), > + be_gssapi_get_princ(port)))); > + else > +#endif No, this isn't what I was suggesting. "on" and "off" really isn't communicating the details about the GSS-using connection. What I suggested before was something like: errmsg("replication connection authorized: user=3D%s application_name=3D%s = GSS %s (principal=3D%s)", port->user_name, port->application_name, (be_gssapi_get_auth(port) && be_gssapi_get_enc(port)) ? "authenticated an= d encrypted" : be_gssapi_get_auth(port) ? "authenticated" : "encrypted", be_gssapi_get_princ(port)) Though I'll admit that perhaps there's something better which could be done here- but just 'on/off' certainly isn't that. Another option might be: errmsg("replication connection authorized: user=3D%s application_name=3D%s = GSS authenticated: %s, encrypted: %s, principal: %s", port->user_name, port->application_name, be_gssapi_get_auth(port) ? "yes" : "no", be_gssapi_get_enc(port) ? "yes" : "no", be_gssapi_get_princ(port)) Also, it would be good to see if there's a way to add to the tests we have for GSSAPI authentication/encryption to show that we hit each of the possible cases and check that we get the correct messages in the log as a result. Thanks, Stephen --Aq4SrlNverAHn87R Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfmsoZAAoJEO1sijiDR2RVElYP/3sdkbbP1pa2Xg2IxhBdpWYo 2YmH4KQl2TYT/7Ypnmd5Pg/8/rybvSDrCHgYgOzwmqEASRHbmERaALnh4c/vzxHJ RJODGR3mIxZiYe8a+XxG9/K2nRREV5wEE1/+AMc7xEMFj4Hu069bQeQsqhkCI/OS r1Gh87ZlyRJwpnZXmc/avJFbJ95XNJdeJdD3lVD91uBGxNRp3nW7Rh0W6+67B+DO utlnzeoNqC5gKNFfTG7zLnDKKc5g8zvmldNGOkEHWb3zfNy4kL0jxj48CSMbrWiE /nGUwU8420Lntayuxc5+zhldVSjWUez5LJ2SpgCyAcEEOhlN+klAzUmV97Na/4L7 jKPw7XXCvjBOg/Md2754AaHowm4VfQYPlt/GYddNKVSv3JAwMkCFPJmm+2HTehyl 28vdW3iE4m5y0+UTn9qSi5JVTWu0x9/ajhMAZ/hLsRQgTciZJfiB5QGwnQygsHuN zqfZIfNxZM27QVapcwNO9i5GRHMLAJGQyXkGEiYCH35OLVKM3uAZhp7VXviPwo1Q TR33Mt92MEljyl+MqQVG+jum+f1d95tsW6/485YHOAJ0OX61nJnqWwIfETTSYD8r /ElxG1GxcB12lv++aQn10f0wZNCzUvTC7abs5gb6mKx6gO428YdbvvXCZ2F4qyl9 +P5PXBUqrb0gwwlb9nvV =GpRZ -----END PGP SIGNATURE----- --Aq4SrlNverAHn87R--