Repository: cloudstack
Updated Branches:
  refs/heads/master b1fa37861 -> f65dec4b0


Implemented condition that only admin or owner of the template can change its 
permissions using updateTemplatePermissions API


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f7e8d445
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f7e8d445
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f7e8d445

Branch: refs/heads/master
Commit: f7e8d445525e659ee007be5e4ef181ab8ee546e6
Parents: 3df847d
Author: Maneesha.P <[email protected]>
Authored: Wed Aug 5 14:28:00 2015 +0530
Committer: Maneesha.P <[email protected]>
Committed: Tue Aug 11 11:08:35 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/template/TemplateManagerImpl.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7e8d445/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java 
b/server/src/com/cloud/template/TemplateManagerImpl.java
index e9581e2..6e9af8a 100644
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1324,6 +1324,11 @@ public class TemplateManagerImpl extends ManagerBase 
implements TemplateManager,
             throw new InvalidParameterValueException("Update template 
permissions is an invalid operation on template " + template.getName());
         }
 
+        //Only admin or owner of the template should be able to change its 
permissions
+        if (caller.getId() != ownerId && !isAdmin) {
+            throw new InvalidParameterValueException("Unable to grant 
permission to account " + caller.getAccountName() + " as it is neither admin 
nor owner or the template");
+        }
+
         VMTemplateVO updatedTemplate = _tmpltDao.createForUpdate();
 
         if (isPublic != null) {

Reply via email to