mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 05:04:56 +09:00
F #1401: Configurable VM_*_OPERATIONS per group and user. Restructure of the API
authorization levels and initialization logic. Co-authored-by: Pavel Czerny <pczerny@opennebula.systems>
This commit is contained in:
1 parent
332560d38f
commit
500e45dbd6
58 files changed
+1442
-1130
No files matched your search
+66
-12
@@ -356,7 +356,7 @@ void Request::execute(
|
||||
const xmlrpc_c::callInfo * _callInfoP,
|
||||
xmlrpc_c::value * const _retval)
|
||||
{
|
||||
RequestAttributes att;
|
||||
RequestAttributes att(auth_op);
|
||||
|
||||
att.retval = _retval;
|
||||
att.session = xmlrpc_c::value_string(_paramList.getString(0));
|
||||
@@ -371,6 +371,8 @@ void Request::execute(
|
||||
bool authenticated = upool->authenticate(att.session, att.password,
|
||||
att.uid, att.gid, att.uname, att.gname, att.group_ids, att.umask);
|
||||
|
||||
att.set_auth_op(vm_action);
|
||||
|
||||
if ( log_method_call )
|
||||
{
|
||||
log_method_invoked(att, _paramList, format_str, method_name,
|
||||
@@ -440,11 +442,9 @@ void Request::execute(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool Request::basic_authorization(int oid,
|
||||
AuthRequest::Operation op,
|
||||
RequestAttributes& att)
|
||||
bool Request::basic_authorization(int oid, RequestAttributes& att)
|
||||
{
|
||||
ErrorCode ec = basic_authorization(pool, oid, op, auth_object, att);
|
||||
ErrorCode ec = basic_authorization(pool, oid, auth_object, att);
|
||||
|
||||
if (ec == SUCCESS)
|
||||
{
|
||||
@@ -463,7 +463,6 @@ bool Request::basic_authorization(int oid,
|
||||
Request::ErrorCode Request::basic_authorization(
|
||||
PoolSQL* pool,
|
||||
int oid,
|
||||
AuthRequest::Operation op,
|
||||
PoolObjectSQL::ObjectType auth_object,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
@@ -493,7 +492,7 @@ Request::ErrorCode Request::basic_authorization(
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(op, perms);
|
||||
ar.add_auth(att.auth_op, perms);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -942,25 +941,29 @@ int Request::get_info(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
Request::ErrorCode Request::as_uid_gid(Template * tmpl,
|
||||
RequestAttributes& att)
|
||||
Request::ErrorCode Request::as_uid_gid(Template * tmpl, RequestAttributes& att)
|
||||
{
|
||||
string gname;
|
||||
string uname;
|
||||
|
||||
PoolObjectAuth uperms;
|
||||
PoolObjectAuth gperms;
|
||||
|
||||
int uid = att.uid, as_uid = -1, as_gid = -1;
|
||||
|
||||
set<int> gids = att.group_ids;
|
||||
|
||||
int rc;
|
||||
|
||||
UserPool * upool = Nebula::instance().get_upool();
|
||||
UserPool * upool = Nebula::instance().get_upool();
|
||||
GroupPool * gpool = Nebula::instance().get_gpool();
|
||||
|
||||
if ( tmpl->get("AS_UID", as_uid) )
|
||||
{
|
||||
tmpl->erase("AS_UID");
|
||||
rc = get_info(upool, as_uid, PoolObjectSQL::USER, att, uperms, uname,true);
|
||||
|
||||
rc = get_info(upool, as_uid, PoolObjectSQL::USER, att, uperms, uname,
|
||||
true);
|
||||
|
||||
if ( rc == -1 )
|
||||
{
|
||||
@@ -975,7 +978,9 @@ Request::ErrorCode Request::as_uid_gid(Template * tmpl,
|
||||
if ( tmpl->get("AS_GID", as_gid) )
|
||||
{
|
||||
tmpl->erase("AS_GID");
|
||||
rc = get_info(gpool, as_gid, PoolObjectSQL::GROUP, att, gperms, gname,true);
|
||||
|
||||
rc = get_info(gpool, as_gid, PoolObjectSQL::GROUP, att, gperms, gname,
|
||||
true);
|
||||
|
||||
if ( rc == -1 )
|
||||
{
|
||||
@@ -1031,3 +1036,52 @@ Request::ErrorCode Request::as_uid_gid(Template * tmpl,
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void RequestAttributes::set_auth_op(VMActions::Action action)
|
||||
{
|
||||
if (action == VMActions::NONE_ACTION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AuthRequest::Operation result = AuthRequest::NONE;
|
||||
|
||||
auto& nd = Nebula::instance();
|
||||
auto user = nd.get_upool()->get_ro(uid);
|
||||
|
||||
if (user != nullptr)
|
||||
{
|
||||
result = user->get_vm_auth_op(action);
|
||||
}
|
||||
|
||||
user->unlock();
|
||||
|
||||
if (result != AuthRequest::NONE)
|
||||
{
|
||||
auth_op = result;
|
||||
return;
|
||||
}
|
||||
|
||||
auto group = nd.get_gpool()->get_ro(gid);
|
||||
|
||||
if (group != nullptr)
|
||||
{
|
||||
result = group->get_vm_auth_op(action);
|
||||
}
|
||||
|
||||
group->unlock();
|
||||
|
||||
if (result != AuthRequest::NONE)
|
||||
{
|
||||
auth_op = result;
|
||||
return;
|
||||
}
|
||||
|
||||
result = nd.get_vm_auth_op(action);
|
||||
|
||||
if (result != AuthRequest::NONE)
|
||||
{
|
||||
auth_op = result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
ar.add_auth(auth_op, operms); // MANAGE OBJECT
|
||||
ar.add_auth(att.auth_op, operms); // MANAGE OBJECT
|
||||
|
||||
if ( noid > -1 )
|
||||
{
|
||||
@@ -411,7 +411,7 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
|
||||
// --------------- Recursive change associated VM objects ------------------
|
||||
// IMPORTANT!: pool/auth_object members are redirected to the VM pool to
|
||||
// IMPORTANT!: pool/auth_object members are redirected to the VM pool to
|
||||
// chown VMs
|
||||
// -------------------------------------------------------------------------
|
||||
bool error_vm_quotas = false;
|
||||
@@ -546,7 +546,7 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, uperms); // MANAGE USER
|
||||
ar.add_auth(att.auth_op, uperms); // MANAGE USER
|
||||
ar.add_auth(AuthRequest::USE, ngperms); // USE GROUP
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
|
||||
@@ -89,7 +89,7 @@ Request::ErrorCode RequestManagerClone::clone(int source_id, const string &name,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, perms); //USE OBJECT
|
||||
ar.add_auth(att.auth_op, perms); //USE OBJECT
|
||||
|
||||
tmpl->to_xml(tmpl_str);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ void RequestManagerCluster::action_generic(
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, c_perms); // ADMIN CLUSTER
|
||||
ar.add_auth(att.auth_op, c_perms); // ADMIN CLUSTER
|
||||
ar.add_auth(AuthRequest::ADMIN, obj_perms); // ADMIN OBJECT
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
@@ -218,7 +218,7 @@ void RequestManagerClusterHost::add_generic(
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, c_perms); // ADMIN CLUSTER
|
||||
ar.add_auth(att.auth_op, c_perms); // ADMIN CLUSTER
|
||||
ar.add_auth(AuthRequest::ADMIN, obj_perms); // ADMIN HOST
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static Request::ErrorCode delete_authorization(PoolSQL* pool,
|
||||
int oid, AuthRequest::Operation auth_op, RequestAttributes& att)
|
||||
static Request::ErrorCode delete_authorization(PoolSQL* pool, int oid,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
PoolObjectAuth perms;
|
||||
|
||||
@@ -39,7 +39,7 @@ static Request::ErrorCode delete_authorization(PoolSQL* pool,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, perms); // <MANAGE|ADMIN> OBJECT
|
||||
ar.add_auth(att.auth_op, perms); // <MANAGE|ADMIN> OBJECT
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
recursive = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
}
|
||||
|
||||
ErrorCode ec = delete_object(oid, recursive, att, auth_op);
|
||||
ErrorCode ec = delete_object(oid, recursive, att);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
@@ -79,10 +79,8 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
void ImageDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
AuthRequest::Operation auth = auth_op;
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
|
||||
//get the image
|
||||
Image* img = static_cast<ImagePool *>(pool)->get_ro(oid);
|
||||
|
||||
if (img == 0)
|
||||
@@ -94,12 +92,12 @@ void ImageDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
if (img->is_locked())
|
||||
{
|
||||
auth = AuthRequest::ADMIN;
|
||||
att.auth_op = AuthRequest::ADMIN;
|
||||
}
|
||||
|
||||
img->unlock();
|
||||
|
||||
ErrorCode ec = delete_object(oid, false, att, auth);
|
||||
ErrorCode ec = delete_object(oid, false, att);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
@@ -115,13 +113,13 @@ void ImageDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Request::ErrorCode RequestManagerDelete::delete_object(int oid,
|
||||
bool recursive, RequestAttributes& att, AuthRequest::Operation auth)
|
||||
Request::ErrorCode RequestManagerDelete::delete_object(int oid, bool recursive,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
string err;
|
||||
ErrorCode ec;
|
||||
|
||||
ec = delete_authorization(pool, oid, auth, att);
|
||||
ec = delete_authorization(pool, oid, att);
|
||||
|
||||
if ( ec != SUCCESS )
|
||||
{
|
||||
|
||||
@@ -99,8 +99,7 @@ Request::ErrorCode ImagePersistent::request_execute(
|
||||
|
||||
ErrorCode ec;
|
||||
|
||||
ec = basic_authorization(ipool, id,
|
||||
AuthRequest::MANAGE, PoolObjectSQL::IMAGE, att);
|
||||
ec = basic_authorization(ipool, id, PoolObjectSQL::IMAGE, att);
|
||||
|
||||
if ( ec != SUCCESS)
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ void TemplateInfo::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, perms); //USE TEMPLATE
|
||||
ar.add_auth(att.auth_op, perms); //USE TEMPLATE
|
||||
|
||||
if (extended)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ void VirtualNetworkTemplateInfo::request_execute(xmlrpc_c::paramList const& para
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, perms); //USE TEMPLATE
|
||||
ar.add_auth(att.auth_op, perms); //USE TEMPLATE
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ void RequestManagerRename::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, operms); // MANAGE OBJECT
|
||||
ar.add_auth(att.auth_op, operms); // MANAGE OBJECT
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
|
||||
@@ -127,4 +127,3 @@ void RequestManagerUpdateTemplate::request_execute(
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ void UserLogin::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(auth_op, perms);
|
||||
ar.add_auth(att.auth_op, perms);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
|
||||
@@ -30,8 +30,7 @@ bool RequestManagerVirtualMachine::vm_authorization(
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * host_perm,
|
||||
PoolObjectAuth * ds_perm,
|
||||
PoolObjectAuth * img_perm,
|
||||
AuthRequest::Operation op)
|
||||
PoolObjectAuth * img_perm)
|
||||
{
|
||||
PoolObjectSQL * object;
|
||||
PoolObjectAuth vm_perms;
|
||||
@@ -52,7 +51,7 @@ bool RequestManagerVirtualMachine::vm_authorization(
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
ar.add_auth(op, vm_perms);
|
||||
ar.add_auth(att.auth_op, vm_perms);
|
||||
|
||||
if (host_perm != nullptr)
|
||||
{
|
||||
@@ -496,8 +495,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
ostringstream oss;
|
||||
string error;
|
||||
|
||||
AuthRequest::Operation op;
|
||||
History::VMAction action;
|
||||
VMActions::Action action;
|
||||
|
||||
VirtualMachineTemplate quota_tmpl;
|
||||
|
||||
@@ -513,11 +511,12 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
action_st = "terminate";
|
||||
}
|
||||
|
||||
History::action_from_str(action_st, action);
|
||||
VMActions::action_from_str(action_st, action);
|
||||
|
||||
op = nd.get_vm_auth_op(action);
|
||||
// Update the authorization level for the action
|
||||
att.set_auth_op(action);
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -527,21 +526,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
vm->get_template_attribute("MEMORY", memory);
|
||||
vm->get_template_attribute("CPU", cpu);
|
||||
|
||||
quota_tmpl.add("RUNNING_MEMORY", memory);
|
||||
quota_tmpl.add("RUNNING_CPU", cpu);
|
||||
quota_tmpl.add("RUNNING_VMS", 1);
|
||||
|
||||
quota_tmpl.add("VMS", 0);
|
||||
quota_tmpl.add("MEMORY", 0);
|
||||
quota_tmpl.add("CPU", 0);
|
||||
|
||||
RequestAttributes& att_aux(att);
|
||||
att_aux.uid = vm->get_uid();
|
||||
att_aux.gid = vm->get_gid();
|
||||
|
||||
// Check if the action is supported for imported VMs
|
||||
if (vm->is_imported() && !vm->is_imported_action_supported(action))
|
||||
{
|
||||
att.resp_msg = "Action \"" + action_st + "\" is not supported for "
|
||||
@@ -553,11 +538,30 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate quota information for resume action
|
||||
RequestAttributes& att_aux(att);
|
||||
|
||||
if (action == VMActions::RESUME_ACTION)
|
||||
{
|
||||
vm->get_template_attribute("MEMORY", memory);
|
||||
vm->get_template_attribute("CPU", cpu);
|
||||
|
||||
quota_tmpl.add("RUNNING_MEMORY", memory);
|
||||
quota_tmpl.add("RUNNING_CPU", cpu);
|
||||
quota_tmpl.add("RUNNING_VMS", 1);
|
||||
|
||||
quota_tmpl.add("VMS", 0);
|
||||
quota_tmpl.add("MEMORY", 0);
|
||||
quota_tmpl.add("CPU", 0);
|
||||
|
||||
att_aux.uid = vm->get_uid();
|
||||
att_aux.gid = vm->get_gid();
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
if ( action == History::RESUME_ACTION &&
|
||||
!quota_authorization("a_tmpl, Quotas::VIRTUALMACHINE, att_aux,
|
||||
att.resp_msg) )
|
||||
if (action == VMActions::RESUME_ACTION && !quota_authorization("a_tmpl,
|
||||
Quotas::VIRTUALMACHINE, att_aux, att.resp_msg))
|
||||
{
|
||||
failure_response(ACTION, att);
|
||||
return;
|
||||
@@ -565,49 +569,49 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case History::TERMINATE_ACTION:
|
||||
case VMActions::TERMINATE_ACTION:
|
||||
rc = dm->terminate(id, false, att, error);
|
||||
break;
|
||||
case History::TERMINATE_HARD_ACTION:
|
||||
case VMActions::TERMINATE_HARD_ACTION:
|
||||
rc = dm->terminate(id, true, att, error);
|
||||
break;
|
||||
case History::HOLD_ACTION:
|
||||
case VMActions::HOLD_ACTION:
|
||||
rc = dm->hold(id, att, error);
|
||||
break;
|
||||
case History::RELEASE_ACTION:
|
||||
case VMActions::RELEASE_ACTION:
|
||||
rc = dm->release(id, att, error);
|
||||
break;
|
||||
case History::STOP_ACTION:
|
||||
case VMActions::STOP_ACTION:
|
||||
rc = dm->stop(id, att, error);
|
||||
break;
|
||||
case History::SUSPEND_ACTION:
|
||||
case VMActions::SUSPEND_ACTION:
|
||||
rc = dm->suspend(id, att, error);
|
||||
break;
|
||||
case History::RESUME_ACTION:
|
||||
case VMActions::RESUME_ACTION:
|
||||
rc = dm->resume(id, att, error);
|
||||
break;
|
||||
case History::REBOOT_ACTION:
|
||||
case VMActions::REBOOT_ACTION:
|
||||
rc = dm->reboot(id, false, att, error);
|
||||
break;
|
||||
case History::REBOOT_HARD_ACTION:
|
||||
case VMActions::REBOOT_HARD_ACTION:
|
||||
rc = dm->reboot(id, true, att, error);
|
||||
break;
|
||||
case History::RESCHED_ACTION:
|
||||
case VMActions::RESCHED_ACTION:
|
||||
rc = dm->resched(id, true, att, error);
|
||||
break;
|
||||
case History::UNRESCHED_ACTION:
|
||||
case VMActions::UNRESCHED_ACTION:
|
||||
rc = dm->resched(id, false, att, error);
|
||||
break;
|
||||
case History::POWEROFF_ACTION:
|
||||
case VMActions::POWEROFF_ACTION:
|
||||
rc = dm->poweroff(id, false, att, error);
|
||||
break;
|
||||
case History::POWEROFF_HARD_ACTION:
|
||||
case VMActions::POWEROFF_HARD_ACTION:
|
||||
rc = dm->poweroff(id, true, att, error);
|
||||
break;
|
||||
case History::UNDEPLOY_ACTION:
|
||||
case VMActions::UNDEPLOY_ACTION:
|
||||
rc = dm->undeploy(id, false, att, error);
|
||||
break;
|
||||
case History::UNDEPLOY_HARD_ACTION:
|
||||
case VMActions::UNDEPLOY_HARD_ACTION:
|
||||
rc = dm->undeploy(id, true, att, error);
|
||||
break;
|
||||
default:
|
||||
@@ -702,7 +706,7 @@ int set_vnc_port(VirtualMachine *vm, int cluster_id, RequestAttributes& att)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (vm->hasHistory() && vm->get_action()==History::STOP_ACTION)
|
||||
else if (vm->hasHistory() && vm->get_action()==VMActions::STOP_ACTION)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -761,6 +765,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
bool auth = false;
|
||||
bool check_nic_auto = false;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get request parameters and information about the target host
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -815,9 +820,9 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
|
||||
if (vm->hasHistory() &&
|
||||
(vm->get_action() == History::STOP_ACTION ||
|
||||
vm->get_action() == History::UNDEPLOY_ACTION ||
|
||||
vm->get_action() == History::UNDEPLOY_HARD_ACTION))
|
||||
(vm->get_action() == VMActions::STOP_ACTION ||
|
||||
vm->get_action() == VMActions::UNDEPLOY_ACTION ||
|
||||
vm->get_action() == VMActions::UNDEPLOY_HARD_ACTION))
|
||||
{
|
||||
ds_id = vm->get_ds_id();
|
||||
|
||||
@@ -924,13 +929,11 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
auth = vm_authorization(id, 0, &tmpl, att, &host_perms, auth_ds_perms,0,
|
||||
auth_op);
|
||||
auth = vm_authorization(id, 0, &tmpl, att, &host_perms, auth_ds_perms,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
auth = vm_authorization(id, 0, 0, att, &host_perms, auth_ds_perms, 0,
|
||||
auth_op);
|
||||
auth = vm_authorization(id, 0, 0, att, &host_perms, auth_ds_perms, 0);
|
||||
}
|
||||
|
||||
if (auth == false)
|
||||
@@ -1068,7 +1071,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
string error;
|
||||
|
||||
History::VMAction action;
|
||||
VMActions::Action action;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get request parameters and information about the target host
|
||||
@@ -1134,8 +1137,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
// ------------------------------------------------------------------------
|
||||
// Authorize request
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
auth = vm_authorization(id, 0, 0, att, &host_perms, auth_ds_perms, 0, auth_op);
|
||||
auth = vm_authorization(id, 0, 0, att, &host_perms, auth_ds_perms, 0);
|
||||
|
||||
if (auth == false)
|
||||
{
|
||||
@@ -1174,7 +1176,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
if (live)
|
||||
{
|
||||
action = History::LIVE_MIGRATE_ACTION;
|
||||
action = VMActions::LIVE_MIGRATE_ACTION;
|
||||
|
||||
if ( vm->is_pinned() )
|
||||
{
|
||||
@@ -1187,7 +1189,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
}
|
||||
else
|
||||
{
|
||||
action = History::MIGRATE_ACTION;
|
||||
action = VMActions::MIGRATE_ACTION;
|
||||
}
|
||||
|
||||
if (vm->is_imported() && !vm->is_imported_action_supported(action))
|
||||
@@ -1589,7 +1591,7 @@ void VirtualMachineDiskSaveas::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation & check quotas
|
||||
// -------------------------------------------------------------------------
|
||||
rc_auth = vm_authorization(id, itemplate, 0, att, 0,&ds_perms,0,auth_op);
|
||||
rc_auth = vm_authorization(id, itemplate, 0, att, 0, &ds_perms, 0);
|
||||
|
||||
if ( rc_auth == true )
|
||||
{
|
||||
@@ -1720,7 +1722,7 @@ void VirtualMachineMonitoring::request_execute(
|
||||
|
||||
string oss;
|
||||
|
||||
bool auth = vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op);
|
||||
bool auth = vm_authorization(id, 0, 0, att, 0, 0, 0);
|
||||
|
||||
if ( auth == false )
|
||||
{
|
||||
@@ -1829,8 +1831,7 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation & check quotas
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( vm_authorization(id, 0, &tmpl, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, &tmpl, att, 0, 0, 0) == false)
|
||||
{
|
||||
return AUTHORIZATION;
|
||||
}
|
||||
@@ -1914,8 +1915,7 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2038,7 +2038,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Authorize the operation & restricted attributes */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2217,8 +2217,7 @@ void VirtualMachineSnapshotCreate::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2255,8 +2254,7 @@ void VirtualMachineSnapshotRevert::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2293,8 +2291,7 @@ void VirtualMachineSnapshotDelete::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2560,23 +2557,21 @@ void VirtualMachineRecover::request_execute(
|
||||
Nebula& nd = Nebula::instance();
|
||||
DispatchManager * dm = nd.get_dm();
|
||||
|
||||
AuthRequest::Operation aop;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case 0: //recover-failure
|
||||
case 1: //recover-success
|
||||
aop = nd.get_vm_auth_op(History::RECOVER_ACTION);
|
||||
att.set_auth_op(VMActions::RECOVER_ACTION);
|
||||
break;
|
||||
|
||||
case 2: //retry
|
||||
aop = nd.get_vm_auth_op(History::RETRY_ACTION);
|
||||
att.set_auth_op(VMActions::RETRY_ACTION);
|
||||
break;
|
||||
|
||||
case 3: //delete
|
||||
case 4: //delete-recreate set same as delete in OpenNebulaTemplate
|
||||
case 5: //delete-db
|
||||
aop = nd.get_vm_auth_op(History::DELETE_ACTION);
|
||||
att.set_auth_op(VMActions::DELETE_ACTION);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2585,7 +2580,7 @@ void VirtualMachineRecover::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, aop) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2751,14 +2746,10 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
}
|
||||
|
||||
/* ---------- Attributes for quota update requests ---------------------- */
|
||||
|
||||
RequestAttributes img_att_quota;
|
||||
RequestAttributes vm_att_quota;
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
if (img_ds_quota)
|
||||
{
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if (img == nullptr)
|
||||
@@ -2774,19 +2765,21 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
img->unlock();
|
||||
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms, auth_op) == false)
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
img_att_quota = RequestAttributes(img_perms.uid, img_perms.gid, att);
|
||||
}
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vm_att_quota = RequestAttributes(vm_perms.uid, vm_perms.gid, att);
|
||||
RequestAttributes vm_att_quota = RequestAttributes(vm_perms.uid,
|
||||
vm_perms.gid, att);
|
||||
RequestAttributes img_att_quota = RequestAttributes(img_perms.uid,
|
||||
img_perms.gid, att);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Check quotas for the new size in image/system datastoress */
|
||||
@@ -2874,7 +2867,7 @@ void VirtualMachineDiskSnapshotRevert::request_execute(
|
||||
int did = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
int snap_id = xmlrpc_c::value_int(paramList.getInt(3));
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2955,12 +2948,12 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
|
||||
|
||||
img->unlock();
|
||||
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms, auth_op) == false)
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
else if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2998,7 +2991,7 @@ void VirtualMachineDiskSnapshotRename::request_execute(xmlrpc_c::paramList const
|
||||
int snap_id = xmlrpc_c::value_int(paramList.getInt(3));
|
||||
string new_snap_name = xmlrpc_c::value_string(paramList.getString(4));
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -3072,7 +3065,7 @@ void VirtualMachineUpdateConf::request_execute(
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Authorize the operation & restricted attributes */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -3260,13 +3253,10 @@ void VirtualMachineDiskResize::request_execute(
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Authorize the request for VM and IMAGE for persistent disks */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
RequestAttributes img_att_quota;
|
||||
RequestAttributes vm_att_quota;
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
if ( img_ds_quota )
|
||||
{
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
if ( img_id != -1 )
|
||||
{
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
@@ -3285,23 +3275,24 @@ void VirtualMachineDiskResize::request_execute(
|
||||
img->unlock();
|
||||
}
|
||||
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms, auth_op) == false)
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, &img_perms) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
img_att_quota = RequestAttributes(img_perms.uid, img_perms.gid, att);
|
||||
}
|
||||
|
||||
if ( vm_ds_quota )
|
||||
{
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
if (vm_authorization(id, 0, 0, att, 0, 0, 0) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vm_att_quota = RequestAttributes(vm_perms.uid, vm_perms.gid, att);
|
||||
RequestAttributes img_att_quota = RequestAttributes(img_perms.uid,
|
||||
img_perms.gid, att);
|
||||
RequestAttributes vm_att_quota = RequestAttributes(vm_perms.uid,
|
||||
vm_perms.gid, att);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Check quotas for the new size in image/system datastoress */
|
||||
|
||||
Reference in new issue
Block a user