X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FCLIHandler.pm;h=f973bdc1ccce6c2425665fa3e5bd2caeb5f82fd5;hb=5ffbe2f10ac9c4b7f95cfde9ff91e542ac32b07c;hp=b32c2886e9fc9964da777680d21009790836cab6;hpb=891b798d5260042a747026b8d7bcab041296f443;p=pve-common.git diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index b32c288..f973bdc 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -113,7 +113,8 @@ __PACKAGE__->register_method ({ sub print_simple_pod_manpage { my ($podfn, $class, $name, $arg_param, $uri_param) = @_; - die "not initialized" if !($cmddef && $exename && $cli_handler_class); + die "not initialized" if !$cli_handler_class; + my $pwcallback = $cli_handler_class->can('read_password'); my $synopsis = " $name help\n\n"; @@ -468,7 +469,7 @@ sub run_cli { die "password callback is no longer supported" if $pwcallback; - run_cli_handler($class, podfn => $podfn, preparefunc => $preparefunc); + run_cli_handler($class, podfn => $podfn, prepare => $preparefunc); } sub run_cli_handler { @@ -478,8 +479,16 @@ sub run_cli_handler { $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; + foreach my $key (keys %params) { + next if $key eq 'podfn'; + next if $key eq 'prepare'; + next if $key eq 'no_init'; # used by lxc hooks + die "unknown parameter '$key'"; + } + my $podfn = $params{podfn}; - my $preparefunc = $params{preparefunc}; + my $preparefunc = $params{prepare}; + my $no_init = $params{no_init}; my $pwcallback = $class->can('read_password'); @@ -490,10 +499,10 @@ sub run_cli_handler { if ($class !~ m/^PVE::Service::/) { die "please run as root\n" if $> != 0; - PVE::INotify::inotify_init(); + PVE::INotify::inotify_init() if !$no_init; my $rpcenv = PVE::RPCEnvironment->init('cli'); - $rpcenv->init_request(); + $rpcenv->init_request() if !$no_init; $rpcenv->set_language($ENV{LANG}); $rpcenv->set_user('root@pam'); }