From: Thomas Lamprecht Date: Wed, 24 Feb 2016 08:33:41 +0000 (+0100) Subject: pct enter: check if container runs before lxc-attach X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=d4b3eead6eda68ae9b706c1e2d27abbfd959674f;p=pve-container.git pct enter: check if container runs before lxc-attach else we get: > > lxc-attach: attach.c: lxc_attach: 710 failed to get the init pid which an arbitrary user could misunderstand. --- diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm index b2bc361..432da39 100755 --- a/src/PVE/CLI/pct.pm +++ b/src/PVE/CLI/pct.pm @@ -92,10 +92,14 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; + my $vmid = $param->{vmid}; + # test if container exists on this node - PVE::LXC::load_config($param->{vmid}); + PVE::LXC::load_config($vmid); + + die "Error: container '$vmid' not running!\n" if !PVE::LXC::check_running($vmid); - exec('lxc-attach', '-n', $param->{vmid}); + exec('lxc-attach', '-n', $vmid); }}); __PACKAGE__->register_method ({