Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wwerO-0027Jq-2M for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Aug 2026 11:53:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wwerN-003ZQM-2H for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Aug 2026 11:53:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wwerM-003ZQD-2C for pgsql-hackers@lists.postgresql.org; Wed, 19 Aug 2026 11:53:33 +0000 Received: from flow-b8-smtp.messagingengine.com ([202.12.124.143]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wwerJ-000000007Je-1jUS for pgsql-hackers@lists.postgresql.org; Wed, 19 Aug 2026 11:53:32 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailflow.stl.internal (Postfix) with ESMTP id 12B0A130018D; Wed, 19 Aug 2026 07:53:26 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 19 Aug 2026 07:53:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=abdiel.eu; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1787140405; x=1787144005; bh=Ep2ujhUytn WlnI+FoQxFv4IfV5xsBGGx7xvPTET3KgA=; b=hO+Z9F74FyX5m5qxqcWtXTBR0+ WJVOxN2P/tN5oEqiG1+rTPuGHTsocyua77hIrt4YtdH5xb5nkZHi8ODHZB0mY8JW sbF99uXwYv3YSz8pbJRt3rfll8OfNqCy2jDs1ZVCYHV2JcCoxZBaT8X3gkvnwSvK zKVR0KpYc/Y03NQci02Qg1i9ZdlP68i1W/mUP9F1Gtbzlir8D1unjFlQAcuifxvy 5d/h6LGcbiY53Igu9Sr+WRjkDoGLPPX5Ziht830qX2FlofcpP86GkMONAPADd0QP 9KktCmfVGyFSYCgQP2SFv31c9LhUrkifxxKEiB58fYMcPCWnsFkL95pa+6Ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787140405; x=1787144005; bh=Ep2ujhUytnWlnI+FoQxFv4IfV5xsBGGx7xv PTET3KgA=; b=BumIvcdWcEgw15IYPp73U58PC3qQu1TQOaM+khV0xNPfHGF1Pxj ibowQ61majoXth8xHJTe/IPQlTWWuOlkSXhEnsUjophE8mUevpK9GgAfvzGLS4qT g+AZODc/hF3JvzdQ8/HUW/nnOVijsrXIQuoGrk4Yck+zci4sYKsYvKGaut8nX4wf mWaT/W6KmghrCo1qo0k0Gcay+0jjsyEGAlFS4m1TyeNk09St1074ilN8oOmw8Poe vM8O1h+WWhc3DakAtfthV6lixfO7KpAGlvvzV7hmd3uwdCWPkBV5hOmnb5mVo6WX bQIsPRsXkiIPYH6ov78p1NLhFGGmpU8zr8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE8gfZ/rTYluBvAeBwrNkhmFCb8yoWJWNBafynvLb7hxThHrKTTJ2XEj56vCDi+Zb QMw07+bcx74MOhqhwxAwp3bF6q+kZWlxZrHee9XXQ8nvuKW5kOpE+ejzYjsbxySzUVJ4Su gXEVJbkf22Z8lHEjAr5Ol9xbXqm8dZa4E3F860mO07KOZFJmSYv0fiihfgAU1qUpp2ViO7 KhJ8FkrOYAj8NZ7G/bXbdtJVxaJdO2Ky4RVoB1HlEgiLNh3wPaCbPeeHSr5H0bWQDPi0B1 YPpTuZnD2ZRvdAsW/UizxgCyFhHA29o9F5Iu9VmF8vLxyXoC3LSx+hHVheVVFfbZubeheC nG55mYiTRz9vhzgS1ClTk4+8QiqtTeo9iUv5BbiAT5jd5dUWDGbdeFuUlgibLOmdASETUh noiYhbddcvkUpL6DjBpxyohg569kooc/Mw+witA9xS6xvhdrIUtw8rRH85+J++eajp9deY fnQEyVxXwAyS9GAZPvIh++akmsdnY8cLvfx3H9d7N6H1Au3838ycbZeS9dMUrQKpsdMXuh KyhKZeVeTASOBEZAzn3Waq8b3PlhmGQY4+Z11BF6X1MqZVckHtIjNxc1Vwf4HOoeg+FMv7 MsiAP/Ibti4BqXAZ7zHJjD46QV32NE/goNw8gfLtL0UjES3ictKHMrWjN5fA X-ME-Proxy: Feedback-ID: i19364b5b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 19 Aug 2026 07:53:24 -0400 (EDT) From: "Jonathan Gonzalez V." To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Introduce psystem() to replace system() In-Reply-To: <2314092.1786402806@sss.pgh.pa.us> References: <87zeyt93ns.fsf@abdiel.eu> <2314092.1786402806@sss.pgh.pa.us> Date: Wed, 19 Aug 2026 13:53:21 +0200 Message-ID: <87wltmz5qm.fsf@abdiel.eu> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello! Tom Lane writes: > "Jonathan Gonzalez V." writes: >> For some time I've been wondering why PostgreSQL needs system() calls, >> which use a shell that can lead to many problems, and also why it >> requires a shell to run a command. > > There's a lot to be said for not going through system() if we don't > have to, and I think you are right that there are many places where > we don't have to, if we're willing to write our own stdio-redirection > code (but that might be a bigger can of worms than it seems). That'd > improve security and also performance, though I'm not very sure how > big the latter win would be. I found a lot of discussions in the past, that's why I thought the idea will be of interest. The stdio-redirection, it's for now, just something for send stuff to DEVNULL, probably it can evolve in future patches, but for now, I think that for the silent stuff it's enough, because the redirection stuff will open the door to manage some piping and the idea it's to remove those kind of needs too. In terms of security, there is an improvement, but for performance, I wasn't able to establish a base line or even what to measure, but I can imagine that people here may have more ideas about what and how to measure it. > However, I think your apparent ambition to have *zero* use of system() > is a bridge too far. In particular: > >> There's an important topic related to using shell versus not a shell. In >> some places like `archive_command` people may use `&&`, but this idea >> aims to avoid this kind of behavior since it's not secure. > > I think breaking the existing definition of archive_command and > similar GUCs is a nonstarter. You're going to make many users > unhappy and only a tiny minority happier. > > There might be some way to compromise, along the lines of "if the > string contains no shell metacharacters then parse it ourselves and > use execv(), else use system()". The devil's in the details there; > but if it could work then it'd satisfy people who'd like to not > have a shell available and are willing to deal with the ensuing > restrictions. But if you think that description covers all or even > most of our users, I'm here to tell you you're wrong. I'm pretty sure it will not, but I open the door to think about it and keep I'm trying to keep in mind those situations when thinking about the design of the patches. > As for details ... doesn't this pcommand_count_args thing break > instantly on cases like pathnames containing spaces? I think > you need a much clearer concept (and, um, some documentation) > about the semantics of these functions. I don't think we're > really going to move the goalposts far unless we can get away > from assumptions like that. Well, that function it's designed in case we should keep compatibility with system(), I'm not happy with that idea but it may be required, but if we can avoid having that from the beginning I'm more than happy with this. With all that said, I'll start putting some documentation and clarify the concepts for this and have a better v2 version. Regards! -- Jonathan Gonzalez V. EDB https://www.enterprisedb.com