all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running
Date: Mon, 29 Nov 2021 20:15:50 +0100	[thread overview]
Message-ID: <20211129191550.315941-1-s.ivanov@proxmox.com> (raw)

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.

quickly tested with `pmgconfig sync`

Reported-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 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 {
-- 
2.30.2





             reply	other threads:[~2021-11-29 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 19:15 Stoiko Ivanov [this message]
2021-11-30 12:17 ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211129191550.315941-1-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal