Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewzm1-0002T3-6a for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 00:32:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewzlz-0000Dj-Tz for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 00:32:35 +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.89) (envelope-from ) id 1ewzlz-0000DZ-Nh for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 00:32:35 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewzlv-0000IP-FB for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 00:32:33 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id D570313E1; Fri, 16 Mar 2018 20:32:29 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Fri, 16 Mar 2018 20:32:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=j3iStXGLIe3dqi/svMJDaBU7O40+79nJ8UJWNkDnEN4=; b=qlgohrp+ f4Kx8mfgMpA7QB7ql/7avBXWmpyqy+BmCVjkK6+VdVfkeH5njYp1KpZlcO0HwUNM PgMiSnUAMDwpUbxtevyvr6BQszyHD0uL+5LXmv1L+bvNbCgwRwi1TQT9PzANS/El jWJvfhvWwB7sbmHw0JssEMGd+wrJAMF0twyx11BL5E3fSKSVdz4fD1bWj5HxtKnx HbzNz0JuGFojE5nlPxTW1SZEReuflsQjOOo92rGgqI8KSBD+nP4mWTcj3DNurXQU PdLQbd5JA9bacSE218S1LgE7oYGvRwveXtf0q2XP876eNGW+dBijtBSmayb9zxbz VCR59ex+QU+gfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=j3iStXGLIe3dqi/svMJDaBU7O40+7 9nJ8UJWNkDnEN4=; b=OgLMLB2ct5um8naRabwU7frPST5NZanSXoadyN4fs9ngI mqzKu8cSW6zmBHowaJ1q02h+AfeFZkemmVtww9ch3JEMCqlGA8Vrl3Ztnzd/9u+M KR5Xa89PLEZNPNaBRpxmmjg+pb+twmKao5AnFMOXS5RT5PcHkN5r4QjAh2QLMZb3 v5H2KBMEN5sXrIrtqqd3DJ8JM1Tlvg2NSoj8V9t7Soq/Pml1nmY5eCMS/F48Cxn7 Kf//Dk4/BsfcN4S06qi2+QVvM9s3yYyeEh50TUjnuAw/LB2osfDLwJeayfRFMJBM 7k1x7+dmoPvKvhPHIBjsMJgY1Q818tEan0weaYVow== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 2E7B324346; Fri, 16 Mar 2018 20:32:27 -0400 (EDT) Date: Sat, 17 Mar 2018 09:32:23 +0900 From: Michael Paquier To: Peter Eisentraut Cc: kotlarski.krzysztof@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15116: pg_recvlogical always fails Message-ID: <20180317003223.GC1532@paquier.xyz> References: <152121448830.1224.17250900005569274883@wrigleys.postgresql.org> <20180317002026.GB1532@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ycz6tD7Th1CMF4v7" Content-Disposition: inline In-Reply-To: <20180317002026.GB1532@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Ycz6tD7Th1CMF4v7 Content-Type: multipart/mixed; boundary="4ZLFUWh1odzi/v6L" Content-Disposition: inline --4ZLFUWh1odzi/v6L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Mar 17, 2018 at 09:20:26AM +0900, Michael Paquier wrote: > At least slot creation fails. One just needs to start up an instance > and run that for example: > $ pg_recvlogical --create-slot -S popo -d "dbname=postgres" > pg_recvlogical: could not clear search_path: ERROR: syntax erro The issue is that support for plain SQL queries has been added in PostgreSQL 10 for logical replication connections, however e170b8c8 has missed the fact that this is not supported for older versions. Hence, two things need to happen as pg_recvlogical needs to be kept compatible with past server versions: 1) Make the check deciding if search_path should be enforced smarter by checking if the server version is newer than 10. This needs to be patched on HEAD and REL_10_STABLE. recvlogical-search-path-fix.patch does so. 2) Simply remove the check on past branches, as I recall that we maintain downstream compatibility, but do not for example guarantee that a Postgres 10 server would work with a 9.6's pg_recvlogical. This is what recvlogical-search-path-fix-96.patch attached does. Thanks, -- Michael --4ZLFUWh1odzi/v6L Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="recvlogical-search-path-fix.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/str= eamutil.c index 296b1888aa..79a1a0bdca 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -209,8 +209,12 @@ GetConnection(void) if (conn_opts) PQconninfoFree(conn_opts); =20 - /* Set always-secure search path, so malicious users can't get control. */ - if (dbname !=3D NULL) + /* + * Set always-secure search path, so malicious users can't get control. + * The capacity to run normal SQL queries has been added in PostgreSQL + * 10, so this does not matter for older versions. + */ + if (dbname !=3D NULL && PQserverVersion(conn) >=3D 100000) { PGresult *res; =20 --4ZLFUWh1odzi/v6L Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="recvlogical-search-path-fix-96.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/str= eamutil.c index aa14dbbb75..3f3f2633ae 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -209,23 +209,6 @@ GetConnection(void) if (conn_opts) PQconninfoFree(conn_opts); =20 - /* Set always-secure search path, so malicious users can't get control. */ - if (dbname !=3D NULL) - { - PGresult *res; - - res =3D PQexec(tmpconn, ALWAYS_SECURE_SEARCH_PATH_SQL); - if (PQresultStatus(res) !=3D PGRES_TUPLES_OK) - { - fprintf(stderr, _("%s: could not clear search_path: %s\n"), - progname, PQerrorMessage(tmpconn)); - PQclear(res); - PQfinish(tmpconn); - exit(1); - } - PQclear(res); - } - /* * Ensure we have the same value of integer timestamps as the server we * are connecting to. --4ZLFUWh1odzi/v6L-- --Ycz6tD7Th1CMF4v7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlqsYhcACgkQnvQgOdby QH0p9A//ZziQbCCPG2wQ1HOKCWGnFFCgyWCbKCXiZ1TBkbovoRk6xCTTzq70ShSJ CU9TKOH5XCkns984aTx/m4ayPts7KFkSvaJFn/Pm7yXtl4Mz/hgI6lcekG09Z3+t ZYG59zy76kGget8ohhEwL8o2IZpdsLM/hSEEAMPO+0geKe48oWCCOBloJPU3lgKR 2evZRgVV6iKoQRkTByjYfVELlpDOxzMFWUVl6kne1Iwp2twAqPj8pPpWeweX5t8I ybYOE1i/KpwqATMrl2vFTPDdLCL9HEOf3n88cl0sVVqnPLzDhweFLQZALF1ghmMd /g8fcsLKGj9cdNclo6LOQpAqgmP5izJ1mOTR9vmJy49eKxCLykZddOEPHHONB+8F Qm99TE6+E+v62Z3rD/6WIjfYzdUeeRpLF5nUgG1il2i/vT6s4D2jpmDQEMwMBOZb 1JnjwaIVZe7Vb12StolfkIprOUALZWLYE2ERgJ41E6t154PxlndqdqGdkKY2UYEd WgjMzB+yYS1caybPconinp7yjC3Pz5LVL+4i84A1LLuaupmZBj+JUp9SYu3G3yNo HyMpH+hvtsL09eL0IQhP9MiL5pwh4z1jXtqQ5OOm2ydiDQxKPcYBz1wGtazgw7HP 5yiTjk7cUi93LvsdHLmhENMdJRoEzUP8n+hhnOHCKWPvCJaYjp4= =1e2o -----END PGP SIGNATURE----- --Ycz6tD7Th1CMF4v7--