From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5FFC282A05 for ; Tue, 30 Nov 2021 13:17:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 56993270FE for ; Tue, 30 Nov 2021 13:17:32 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 8F602270EF for ; Tue, 30 Nov 2021 13:17:31 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 63DC244CD9 for ; Tue, 30 Nov 2021 13:17:31 +0100 (CET) Message-ID: <28aa7b69-119e-905f-8de3-c7f00d305e52@proxmox.com> Date: Tue, 30 Nov 2021 13:17:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Thunderbird/95.0 Content-Language: en-US To: Stoiko Ivanov , pmg-devel@lists.proxmox.com References: <20211129191550.315941-1-s.ivanov@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20211129191550.315941-1-s.ivanov@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.747 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -1.317 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [restenvironment.pm] Subject: Re: [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 12:17:32 -0000 On 29.11.21 20:15, Stoiko Ivanov wrote: > some of PMG's CLI invocations switch user to postgres and run `psql` > (through `PMG::Utils::postgres_admin_cmd()`) > > When running a command in `/root` (or any other directory not > accessible by the postgres user this causes: > `could not change directory to "/root": Permission denied` > to be printed multiple times on stderr for those invocations, which is > confusing and has caused quite a few support requests. > > grepping through the code-base setup_default_cli_env seems the > appropriate place for chdir to /, since it's only called once per cli > utility. > can be fine, but do we have any path params where this could break passing from CWD relative paths? > quickly tested with `pmgconfig sync` > > Reported-by: Oguz Bektas > Signed-off-by: Stoiko Ivanov > --- > src/PMG/RESTEnvironment.pm | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/PMG/RESTEnvironment.pm b/src/PMG/RESTEnvironment.pm > index 3875720..49dd8e8 100644 > --- a/src/PMG/RESTEnvironment.pm > +++ b/src/PMG/RESTEnvironment.pm > @@ -50,6 +50,7 @@ sub setup_default_cli_env { > > my $rest_env = $class->get(); > $rest_env->set_role('root'); > + chdir('/'); > } > > sub set_format { >