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 1uVb0S-002POv-L2 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Jun 2025 19:14:32 +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 1uVazR-00968j-M5 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Jun 2025 19:13:30 +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 1uVazR-00968a-DW for pgsql-bugs@lists.postgresql.org; Sat, 28 Jun 2025 19:13:30 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uVazP-004cNC-2p for pgsql-bugs@lists.postgresql.org; Sat, 28 Jun 2025 19:13:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 55SJDP4p2334361; Sat, 28 Jun 2025 15:13:26 -0400 From: Tom Lane To: d.kovalenko@postgrespro.ru cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program In-reply-to: <18971-53687392b125e4bf@postgresql.org> References: <18971-53687392b125e4bf@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sat, 28 Jun 2025 07:17:54 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2334359.1751138005.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Jun 2025 15:13:25 -0400 Message-ID: <2334360.1751138005@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > 4) pg_probackup3 process has the following environment variables: > PWD=3D"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Van= illa-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_= relative_path/restored/data" > PGDATA=3D"../../../../../../../../../../../../home/dima/MY/Work/CurrentT= asks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/= tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data" > ---------- PROBLEM > PGDATA (4) is invalid for pg_probackup3. I do not think this is a Postgres bug. The PGDATA environment variable is not canonical, it is just the default to be used if you don't specify a -D switch on the postmaster/pg_ctl command line. In fact, it might not be set at all. (I see that pg_ctl does set it, but pg_ctl is not the only way to start the postmaster.) Therefore, relying on PGDATA in a restore_command script isn't safe. You should be relying on the current working directory (PWD) instead. regards, tom lane