From e5261f610a894bc706399bdf189d949367ef2b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 10 Sep 2014 19:10:00 +0200 Subject: [PATCH] Feature #3175: Ask for SECGROUP USE auth in VM creation. This only checks the sec groups requested directly in each NIC/SECURITY_GROUPS. The sec groups added from the vnet (and AR) are not checked for auth. --- src/vm/VirtualMachine.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index f240f14574..b97a4e85be 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -3360,11 +3360,15 @@ void VirtualMachine::set_auth_request(int uid, int num; vector vectors; VectorAttribute * vector; + set::iterator it; Nebula& nd = Nebula::instance(); ImagePool * ipool = nd.get_ipool(); VirtualNetworkPool * vnpool = nd.get_vnpool(); + SecurityGroupPool * sgpool = nd.get_secgrouppool(); + + SecurityGroup * sgroup; num = tmpl->get("DISK",vectors); @@ -3395,6 +3399,23 @@ void VirtualMachine::set_auth_request(int uid, } vnpool->authorize_nic(vector,uid,&ar); + + set sgroups = nic_security_groups(vector); + + for(it = sgroups.begin(); it != sgroups.end(); it++) + { + sgroup = sgpool->get(*it, true); + + if(sgroup != 0) + { + PoolObjectAuth perm; + sgroup->get_permissions(perm); + + sgroup->unlock(); + + ar.add_auth(AuthRequest::USE, perm); + } + } } }