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 1oFzym-0003Rv-Ao for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 15:26:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFzyl-00045Z-6E for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 15:26:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFzyk-00045Q-BP for pgsql-hackers@lists.postgresql.org; Mon, 25 Jul 2022 15:26:42 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFzyg-0003gS-Kg for pgsql-hackers@postgresql.org; Mon, 25 Jul 2022 15:26:41 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 90F115C01B9; Mon, 25 Jul 2022 11:26:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 25 Jul 2022 11:26:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1658762795; x=1658849195; bh=mrY2VO49VY +HQ9bKjmS6E2e91C4pAwC7wS031wCWisA=; b=oDc0DYBwYcIJSSpg5NA1cnfslV VIkSmLrunGk+7E70M7+iun1QFapFIGmOs8WAD/9E4lJFzhIRK9Cgta6WzRer2gLJ +t2f+fAIf0fwHRA5mchFfFBygsUJPKitQkrWP/ZiuN69OL4OSWrmjGXtNe8JyLlQ a/Txt5LIZ7GVSiZx+yaRLLZsF0oYNWO0EtrdN+Y5CvnJDYFbzVSwud4kAa3BhQx8 HTCkrprW09GFLHQCPCpeeZJaGQugpqBnQqdH4hGTxW+PeLkwYd4+6N5yqWVDl2BT 6yrMoNjqRYSCvaj3wVMfQMWJfvgA4Cn828HhTyduq7x2LguwF2hxbqL48S4w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1658762795; x=1658849195; bh=mrY2VO49VY+HQ9bKjmS6E2e91C4p AwC7wS031wCWisA=; b=M6bHjRxlvH39Uim066a+Z6pWNbhx0SP4dXA3KSMa2eQ9 UZ08k0u0Vl3EcB36YiCcMR6JK+Htada6+mn4OksVOD0xloDjif5COxolyv2ihtZm ZgNFHK2+JSQnsslUywrjtpSqc0BOMywaaqxmTuoZQ1pS56UhZEz2gdiC2WwH3BDZ cit4bg8Jl6hqQGA62HGedki8R+1YlNNgphEjsdK4O633VUqT0N829VulzypSTkUf 7jk7M+w7ttZ+zl9gPCg0aVZuDxdCEOXzbTHwcCHrGCIlTUKy97kmp/c8GQNBq5/i 5nzypjg8xc6PHr3KQqxrKVlJtAAFupFdLdmXfNzyug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddtkedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufhffjgfkfgggtgesmhdtreertderjeenucfhrhhomhepffgrghhf ihhnnhgpkfhlmhgrrhhipgforghnnhhsnohkvghruceoihhlmhgrrhhisehilhhmrghrih drohhrgheqnecuggftrfgrthhtvghrnhepuefgfeduuedtjeeuheetjeeukefhjedtveeh jeelhfdutedvieeltddvuedvuddvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrghrihdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Jul 2022 11:26:34 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: Nathan Bossart , Kyotaro Horiguchi , michael@paquier.xyz, gurjeet@singh.im, pgsql-hackers@postgresql.org Subject: Re: Unprivileged user can induce crash by using an SUSET param in PGOPTIONS References: <20220722.151600.1094104349120879204.horikyota.ntt@gmail.com> <729330.1658516182@sss.pgh.pa.us> <20220722223359.GB3998906@nathanxps13> <763512.1658529844@sss.pgh.pa.us> <20220722225615.GC3998906@nathanxps13> <954936.1658597004@sss.pgh.pa.us> <20220725034040.GA4085281@nathanxps13> <1834276.1658720963@sss.pgh.pa.us> <20220725043044.GC4085281@nathanxps13> <2015981.1658759562@sss.pgh.pa.us> Date: Mon, 25 Jul 2022 16:26:32 +0100 In-Reply-To: <2015981.1658759562@sss.pgh.pa.us> (Tom Lane's message of "Mon, 25 Jul 2022 10:32:42 -0400") Message-ID: <87ilnli57b.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Tom Lane writes: > I wonder if it'd be a good idea to convert > auto_explain's TAP test to load auto_explain via session_preload_libraries > instead of shared_preload_libraries, and then pass in the settings for > each test via PGOPTIONS instead of constantly rewriting postgresql.conf. That whole config-file rewriting did feel a bit icky when I added more tests recently, but I completely forgot about PGOPTIONS and -c. Something like the attached is indeed much nicer. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-PGOPTIONS-and-session_preload_libraries-in-auto_.patch From c9d6850e89ff95df1034c13ca9c10aaf1cf0f02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Mon, 25 Jul 2022 16:23:09 +0100 Subject: [PATCH] Use PGOPTIONS and session_preload_libraries in auto_explain tests Instead of constantly rewriting postgresql.conf. Also change the from shared_preload_libraries to session_preload_libraries to givesome coverage of extensions providing custom GUCs. --- contrib/auto_explain/t/001_auto_explain.pl | 24 +++------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/contrib/auto_explain/t/001_auto_explain.pl b/contrib/auto_explain/t/001_auto_explain.pl index 1d952fb54d..b86761919b 100644 --- a/contrib/auto_explain/t/001_auto_explain.pl +++ b/contrib/auto_explain/t/001_auto_explain.pl @@ -16,38 +16,20 @@ sub query_log my ($node, $sql, $params) = @_; $params ||= {}; - if (keys %$params) - { - for my $key (keys %$params) - { - $node->append_conf('postgresql.conf', "$key = $params->{$key}\n"); - } - $node->reload; - } + local $ENV{PGOPTIONS} = join " ", map { "-c $_=$params->{$_}" } keys %$params; my $log = $node->logfile(); my $offset = -s $log; $node->safe_psql("postgres", $sql); - my $log_contents = slurp_file($log, $offset); - - if (keys %$params) - { - for my $key (keys %$params) - { - $node->adjust_conf('postgresql.conf', $key, undef); - } - $node->reload; - } - - return $log_contents; + return slurp_file($log, $offset); } my $node = PostgreSQL::Test::Cluster->new('main'); $node->init; $node->append_conf('postgresql.conf', - "shared_preload_libraries = 'auto_explain'"); + "session_preload_libraries = 'auto_explain'"); $node->append_conf('postgresql.conf', "auto_explain.log_min_duration = 0"); $node->append_conf('postgresql.conf', "auto_explain.log_analyze = on"); $node->start; -- 2.30.2 --=-=-=--