diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index e9093651c9..86d723a1fe 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -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());