* [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running
@ 2021-11-29 19:15 Stoiko Ivanov
2021-11-30 12:17 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Stoiko Ivanov @ 2021-11-29 19:15 UTC (permalink / raw)
To: pmg-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running
2021-11-29 19:15 [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running Stoiko Ivanov
@ 2021-11-30 12:17 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-11-30 12:17 UTC (permalink / raw)
To: Stoiko Ivanov, pmg-devel
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 {
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-30 12:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 19:15 [pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running Stoiko Ivanov
2021-11-30 12:17 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox