[pmg-devel] [PATCH pmg-api] cli utils: chdir to / before running
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Nov 29 20:15:50 CET 2021
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 at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at 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
More information about the pmg-devel
mailing list