all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running
Date: Tue, 30 Nov 2021 13:17:29 +0100	[thread overview]
Message-ID: <28aa7b69-119e-905f-8de3-c7f00d305e52@proxmox.com> (raw)
In-Reply-To: <20211129191550.315941-1-s.ivanov@proxmox.com>

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 <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 {
> 





      reply	other threads:[~2021-11-30 12:17 UTC|newest]

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

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=28aa7b69-119e-905f-8de3-c7f00d305e52@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=s.ivanov@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