feature #203: Plain authorize method fix

This commit is contained in:
Ruben S. Montero committed 2010-07-12 18:42:46 +02:00
1 parent e3c5c8086c
commit 2fe5b7b740
1 file changed
+43 -9
+43 -9
View File
@@ -76,7 +76,7 @@ void AuthRequest::add_auth(Object ob,
bool pub)
{
ostringstream oss;
bool auth = owner == uid;
bool auth;
switch (ob)
{
@@ -118,14 +118,6 @@ void AuthRequest::add_auth(Object ob,
case USE:
oss << "USE:" ;
if ( ob == NET || ob == IMAGE )
{
auth = auth || (pub == true);
}
else if (ob == HOST)
{
auth = true;
}
break;
case MANAGE:
@@ -135,6 +127,48 @@ void AuthRequest::add_auth(Object ob,
oss << owner << ":" << pub;
// -------------------------------------------------------------------------
// Authorize the request for self authorization
// -------------------------------------------------------------------------
if ( uid == 0 )
{
auth = true;
}
else
{
auth = false;
switch (op)
{
case CREATE:
if ( ob == VM || ob == NET || ob == IMAGE )
{
auth = true;
}
break;
case DELETE:
auth = owner == uid;
break;
case USE:
if (ob == NET || ob == IMAGE)
{
auth = (owner == uid) || pub
}
else if (ob == HOST)
{
auth = true
}
break;
case MANAGE:
auth = owner == uid;
break;
}
}
self_authorize = self_authorize && auth;
auths.push_back(oss.str());