Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYXFy-0008HD-6e for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2018 13:14:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYXFw-0001nX-Ul for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2018 13:14:24 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eYXFw-0001nN-LC for pgsql-hackers@lists.postgresql.org; Mon, 08 Jan 2018 13:14:24 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eYXFt-0004ah-23 for pgsql-hackers@postgresql.org; Mon, 08 Jan 2018 13:14:23 +0000 Received: by mail-pg0-x241.google.com with SMTP id f14so2919197pga.10 for ; Mon, 08 Jan 2018 05:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mdJBdX9kW0TUb/MtTT34M4f7aNYUq45Un/1cPxiUWts=; b=bpRLwrNR0+qKPziq9ojlfVFczu1ygTezp/YqVfH7u5li6dTioYcGxQnUDO/ky2YPq6 Xsyxtm2pd7SkJN/uu+z59kPwUNjGlGTjceOt/RtWSL3KjQ91Hg+7XwtDp4beJHXjJC7x 9H54yNfQnXDk8STTSSNvtDM4iXbT4mmaJIceQJmPrqoI0zmtbniAUrN1NDXmWLaRp/m8 ZsApU+dM/jATTzNEg1vZoiFgYhUzXXlE3uKYo2Z/9oDIGNBKYfuyNdfj6JpZvPomA60l jcghkwG6jYB/5E3ORpkhSxYF374J4Ll6GZTZPtCqCJxEW8nnknP88JI3vMMuoMJpmhu/ Zmmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mdJBdX9kW0TUb/MtTT34M4f7aNYUq45Un/1cPxiUWts=; b=OflhdCVEHR34ge23TztU5wZqU3H+zisElStsY3RY7Lrky+Z5oK1Y8FkVd2j1HqBUny 4fJ7gkjvO+OjEKHWOzVbrp4U5Ongmpzw4/7Y3iyB/aj95pOYVRT7bSHyzd3NPnMwxNC4 aDIRUH99SKce0WdphL5i++0CNXVFl/2PHIKTMlFC0wvmmVku1o6aqoHaaB2IrBH15Hlp Aq8kOUP7qVSIbI9eXSvEhBfQneqLKLKZVgSEmiNUo3CCJ+kzJ7bsSQbBNKoIqB0GZ9i+ ua7HlJRnWFwJFzq0o8buiaJtEq2FfjiLBfA/jApgokD/u9EC5sANAhjZ6YswpvEZEABy JKhA== X-Gm-Message-State: AKGB3mJABfkMolRg12ogfyTN1ENtOAeOQMfOH7BWBSgW6zxOaLklxE2N 9mnulDtvCXu5FzW82swSOQ4= X-Google-Smtp-Source: ACJfBouflujvKFQxuzUg56kroAAROBe21AZtYFxDRGxVx+ebs9VAhzhAP0bmZCt+ASUF67cg43bwSw== X-Received: by 10.99.43.151 with SMTP id r145mr9421019pgr.191.1515417258156; Mon, 08 Jan 2018 05:14:18 -0800 (PST) Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp. [61.215.137.162]) by smtp.gmail.com with ESMTPSA id u67sm26449224pfd.162.2018.01.08.05.14.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 05:14:16 -0800 (PST) Date: Mon, 8 Jan 2018 22:14:11 +0900 From: Michael Paquier To: Alvaro Herrera Cc: Peter Eisentraut , Robert Haas , Thomas Munro , "pgsql-hackers@postgresql.org" Subject: Re: pgsql: Implement channel binding tls-server-end-point for SCRAM Message-ID: <20180108131411.GA76418@paquier.xyz> References: <517b2640-dfea-ca7f-220c-1d4f482f6fc4@2ndquadrant.com> <20180105175627.tndhtwsztuekz54n@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ftEhullJWpWg/VHq" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ftEhullJWpWg/VHq Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Jan 06, 2018 at 09:10:51AM +0900, Michael Paquier wrote: > On Sat, Jan 6, 2018 at 2:56 AM, Alvaro Herrera wrote: > Good idea as a whole, but I don't think this is the right approach. As > we include $(bindir) in PATH when running the prove command, why not > getting the include path from "pg_config --includedir"? So, I have been looking at that, and I propose the following counter-patch which implements this idea by adding a new routine as TestLib::config_check which is able to check within pg_config.h if a given regexp matches or not for the installation on which TAP tests are being run. I have tested with Postgres compiled with both OpenSSL 1.0.1 and 1.0.2, in which case the connection test respectively fails and passes, causing the test to be correctly handled. This is based on Peter's patch upthread. -- Michael --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fix_ssl_tests_scram_v2.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 72826d5bad..c49b4336c1 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -26,6 +26,7 @@ our @EXPORT =3D qw( slurp_dir slurp_file append_to_file + config_check system_or_bail system_log run_log @@ -221,6 +222,27 @@ sub append_to_file close $fh; } =20 +# Check presence of a given regexp within pg_config.h for the installation +# where tests are running, returning a match status result depending on +# that. +sub config_check +{ + my ($regexp) =3D @_; + my ($stdout, $stderr); + my $result =3D IPC::Run::run [ 'pg_config', '--includedir' ], '>', + \$stdout, '2>', \$stderr; + + print("# Checking for match with expression \"$regexp\" in pg_config.h\n"= ); + + die "could not execute pg_config" if $result !=3D 1; + chomp($stdout); + + open my $pg_config_h, '<', "$stdout/pg_config.h" or die "$!"; + my $match =3D (grep {/^$regexp/} <$pg_config_h>); + close $pg_config_h; + return $match; +} + # # Test functions # diff --git a/src/test/ssl/t/002_scram.pl b/src/test/ssl/t/002_scram.pl index 3f425e00f0..73c8f7adf2 100644 --- a/src/test/ssl/t/002_scram.pl +++ b/src/test/ssl/t/002_scram.pl @@ -11,6 +11,10 @@ use File::Copy; # This is the hostname used to connect to the server. my $SERVERHOSTADDR =3D '127.0.0.1'; =20 +# Determine whether build supports tls-server-end-point. +my $supports_tls_server_end_point =3D + TestLib::config_check("#define HAVE_X509_GET_SIGNATURE_NID 1"); + # Allocation of base connection string shared among multiple tests. my $common_connstr; =20 @@ -44,10 +48,19 @@ test_connect_ok($common_connstr, "SCRAM authentication with tls-unique as channel binding"); test_connect_ok($common_connstr, "scram_channel_binding=3D''", - "SCRAM authentication without channel binding"); -test_connect_ok($common_connstr, - "scram_channel_binding=3Dtls-server-end-point", - "SCRAM authentication with tls-server-end-point as channel binding"); + "SCRAM authentication without channel binding"); +if ($supports_tls_server_end_point) +{ + test_connect_ok($common_connstr, + "scram_channel_binding=3Dtls-server-end-point", + "SCRAM authentication with tls-server-end-point as channel binding"); +} +else +{ + test_connect_fails($common_connstr, + "scram_channel_binding=3Dtls-server-end-point", + "SCRAM authentication with tls-server-end-point as channel binding"); +} test_connect_fails($common_connstr, "scram_channel_binding=3Dnot-exists", "SCRAM authentication with invalid channel binding"); --KsGdsel6WgEHnImy-- --ftEhullJWpWg/VHq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlpTbqMACgkQnvQgOdby QH08YQ//QN4JbaKbA58059n5uLZ7xYyCADqSceT0sl/JyfhI1Z73m5nfiXgxYv6I G/iCTHCCs5tZTEU/Hq6UdLN011yDoj/Q9J7jZlO8IA6f8HgAkNvUsuVFFYWyuAvm EM8K4qFBYHMgT9ZX/qAfw/w066ZdR0MI2I5x8WETx3EzSMB81vvx205LvGco/YzQ QPFnmJEtGx6Ag8X4EVLU5nykhV1r1OBKyTWEE59wLj0spGWZ9IkzUnQDF5kk2f/U LfMmugZ07JMHCDBbkjHQm9amUm7nwGLBojZndMiPlWi5TdaTm/qIVhtYh0msXeZR LKRTyh9kinKccvKK4DXbzJkQy1Ti91gy6kwHHaqimpB0IGumYNg+gJOqUyHAArFI CtnTapCV/ySm450DgTi4vGPzxXEkNR2M1kLuEmOjER+ZDxbFbJI2WzlLsfdfGl/7 vsbULxzP5Vjytwd0LxCwY8DSVkH2NyU8hRmV/duaWY8QHRAh6pEpZF/hfRKZ3Qb+ uRqylfRE6lUh+KELKD2t9/JiFg+yreNvoOYF4ES13HRKlbMSESDSIOlmXbBepQpy GjOZ3V8R8WYvzZ7sCPGhhcHxH1gZ/X/lKbNLc21W1YXKyKETq3hhTtTcQHMbKBik RsL9jaxboqSq+7FKgQ44duXApzhjYo3C5pawLIArMXbPfXkVobE= =haDm -----END PGP SIGNATURE----- --ftEhullJWpWg/VHq--