From 2a8ced7bacb7da8ab4143a59720e74a2897cf714 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 4 Sep 2015 12:32:44 +0200 Subject: [PATCH] run_cli: skip environment init for PVE::Service::* classes This is done by the daemon implementation instead. --- src/PVE/CLIHandler.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index 5372198..e6fd415 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -372,14 +372,17 @@ sub run_cli { initlog($exename); - die "please run as root\n" if $> != 0; - PVE::INotify::inotify_init() if $class !~ m/^PVE::Service::/; + if ($class !~ m/^PVE::Service::/) { + die "please run as root\n" if $> != 0; - my $rpcenv = PVE::RPCEnvironment->init('cli'); - $rpcenv->init_request(); - $rpcenv->set_language($ENV{LANG}); - $rpcenv->set_user('root@pam'); + PVE::INotify::inotify_init(); + + my $rpcenv = PVE::RPCEnvironment->init('cli'); + $rpcenv->init_request(); + $rpcenv->set_language($ENV{LANG}); + $rpcenv->set_user('root@pam'); + } no strict 'refs'; my $def = ${"${class}::cmddef"}; -- 2.39.2