From 2730fdd3bc8b07e00838d55293ce3286b52d76b5 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 1 Jun 2016 16:10:07 +0200 Subject: [PATCH] bug #4496: Do not allow to change ownership for VMs in DONE (cherry picked from commit 36d48bfe1f28a69d6830a60e0723881264e4b56a) --- src/rm/RequestManagerChown.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/rm/RequestManagerChown.cc b/src/rm/RequestManagerChown.cc index f6d9957e08..cd7b7009c5 100644 --- a/src/rm/RequestManagerChown.cc +++ b/src/rm/RequestManagerChown.cc @@ -51,7 +51,18 @@ PoolObjectSQL * RequestManagerChown::get_and_quota( if (auth_object == PoolObjectSQL::VM) { - tmpl = (static_cast(object))->clone_template(); + VirtualMachine * vm = static_cast(object); + + if ( vm->get_state() == VirtualMachine::DONE ) + { + vm->unlock(); + + att.resp_msg = "Could not change VM ownership, wrong state"; + failure_response(ACTION, att); + return 0; + } + + tmpl = vm->clone_template(); qtype = Quotas::VIRTUALMACHINE; } else if (auth_object == PoolObjectSQL::IMAGE)