From 361d54c3299f0860f58d8657cf22e2648bf35dfb Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 25 May 2016 11:03:10 +0200 Subject: [PATCH] run_cli_handler: add no_rpcenv parameter This can be used if a CLIHandler child class does not needs or wants RPCEnv. E.g. this is the case with pve-cluster, as it's a dependency of the package where RPCEnv resides (access-control), so this can be set to avoid a implicit circular build dependency. Signed-off-by: Thomas Lamprecht --- src/PVE/CLIHandler.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index c448a80..2a9a6c9 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -468,11 +468,13 @@ sub run_cli_handler { foreach my $key (keys %params) { next if $key eq 'prepare'; next if $key eq 'no_init'; # used by lxc hooks + next if $key eq 'no_rpcenv'; die "unknown parameter '$key'"; } my $preparefunc = $params{prepare}; my $no_init = $params{no_init}; + my $no_rpcenv = $params{no_rpcenv}; my $pwcallback = $class->can('read_password'); my $stringfilemap = $class->can('string_param_file_mapping'); @@ -486,10 +488,12 @@ sub run_cli_handler { PVE::INotify::inotify_init() if !$no_init; + if (!$no_rpcenv) { my $rpcenv = PVE::RPCEnvironment->init('cli'); - $rpcenv->init_request() if !$no_init; - $rpcenv->set_language($ENV{LANG}); - $rpcenv->set_user('root@pam'); + $rpcenv->init_request() if !$no_init; + $rpcenv->set_language($ENV{LANG}); + $rpcenv->set_user('root@pam'); + } } no strict 'refs'; -- 2.39.2