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.94.2) (envelope-from ) id 1u3DB1-00CEGF-V5 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Apr 2025 12:08:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u3DAz-008o2L-Iy for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Apr 2025 12:08:05 +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.94.2) (envelope-from ) id 1u3DAz-008o2D-2r for pgsql-hackers@lists.postgresql.org; Fri, 11 Apr 2025 12:08:05 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u3DAw-004hYD-0g for pgsql-hackers@lists.postgresql.org; Fri, 11 Apr 2025 12:08:05 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 3653C114017C; Fri, 11 Apr 2025 08:07:59 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 11 Apr 2025 08:07:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1744373279; x=1744459679; bh=v IvMjzGZhi+ILsPFgAPIIFt2EKOp7V56WsV/md/pTHc=; b=c/vb81d4sVzd1qXTl lxfqiRGPddTv+qtGD9futB2RaiNzuLaraZ0RjBjkzAozcefeyKPkaxmDKU/oNQRS DXnaf+aHaTCqLLJuw4yq623By+x8nO/1ESaBf/FDWKz0Zmwe90xVkVychSZP2s1v 7UwW4k5kNW4b0Lhz9SbOYqROqHGP6AT9gxDbEtvEMgpoQeQcJ/BogShzwSbn8Ild AKX/7B/VcZRhyw2AG/91HhrurbSGSnPshQAbRVySp/Kn9AgO1L2m1n56HBmIX/yi 0W6uzyVBxu448SI+1DEAa6/drBGUmYZ6ML8tJV1J9i6zauFsKOFQX8Pmgr8V3D8w E4XdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvuddujeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheplmhlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdehueffhefgueekueef heehgffhuefgfedukeejveduffegffekgeffffevgeehnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsg gprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrnhgurhgv fiesughunhhslhgrnhgvrdhnvghtpdhrtghpthhtohepmhgrhhhiiehruhhnsehgmhgrih hlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphho shhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 11 Apr 2025 08:07:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1744373275; bh=YozpOLv8A209mbBVMI+2SSjfS5iDZCS9EFcpRaWiIpw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Mro4yFhPEoaTCPoXjMK2lBB9Q0wREpLHh4Dzr/zVa8RnOjSHQfpWM2uDObp3wkh2r eTZGGbg3kmTLYaBQQlSZhE/O4diTG1OxuF7Rdak8QbVhVHgAGd3Z/xHSZ+kAypUOVn h6J0MO5trbushGT8bPrsZeF4VY6DVrmQKe00uoZSzNPngDVMS6MJy81gKvsOYH2iq3 Z6fdqFDXJ9UZlprD8f9U7S9EoBcL0Aun0s4058pC1q988pO1J1MWyCR+5FWvG0LJrn pDZXT4EeJ7nUUjej5Z4dmJyjdyEwFdT3JZVwcHdXBb8wYAFfkcNEu9f2P6+aL4AEHO wUIk8BHTjSMNA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id E67598F; Fri, 11 Apr 2025 14:07:55 +0200 (CEST) Date: Fri, 11 Apr 2025 14:07:55 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Mahendra Singh Thalor Cc: Andrew Dunstan , PostgreSQL Hackers Subject: Re: as per commit 643a1a61985bef2590496, move create/open dir code to function using switch case of pg_backup_directory.c file also Message-ID: <202504111207.pk6wancjzolp@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I don't understand why the routine is called "create_or_open_dir". In what sense does this open the directory? I think "check_or_create_dir" would be closer to what this seem to be doing. Is there no TOCTTOU bug in pg_dumpall because of the way this code is written? A malicious user that can create an empty directory that pg_dumpall is going to use as output destination could remove it after the opendir(), then replace it with another directory with a symlink called "global.dat" that causes some other file to be overwritten with the privileges of the user running pg_dumpall. Maybe there's no problem here, but I don't see what the explanation for that is. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/