]> git.proxmox.com Git - pve-common.git/commitdiff
run_cli_handler: add no_rpcenv parameter
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 25 May 2016 09:03:10 +0000 (11:03 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 25 May 2016 09:33:28 +0000 (11:33 +0200)
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 <t.lamprecht@proxmox.com>
src/PVE/CLIHandler.pm

index c448a80ef7828cb2f00f4961bce7c0fcd75cc211..2a9a6c9e8e0d9bba534e164d1bf13de178f54487 100644 (file)
@@ -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
     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};
        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');
 
     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;
 
 
        PVE::INotify::inotify_init() if !$no_init;
 
+       if (!$no_rpcenv) {
        my $rpcenv = PVE::RPCEnvironment->init('cli');
        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';
     }
 
     no strict 'refs';