]> git.proxmox.com Git - pve-common.git/commitdiff
run_cli: skip environment init for PVE::Service::* classes
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 10:32:44 +0000 (12:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 10:32:44 +0000 (12:32 +0200)
This is done by the daemon implementation instead.

src/PVE/CLIHandler.pm

index 5372198fdc2c1d5d57d345438938f39470bac042..e6fd415b3ef4fd237c03db93eb038e835e7d1bed 100644 (file)
@@ -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"};