diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index e9581e2427d..6e9af8a0441 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) {