Skip to content

Commit f7e8d44

Browse files
author
Maneesha.P
committed
Implemented condition that only admin or owner of the template can change its permissions using updateTemplatePermissions API
1 parent 3df847d commit f7e8d44

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/src/com/cloud/template/TemplateManagerImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,11 @@ public boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissions
13241324
throw new InvalidParameterValueException("Update template permissions is an invalid operation on template " + template.getName());
13251325
}
13261326

1327+
//Only admin or owner of the template should be able to change its permissions
1328+
if (caller.getId() != ownerId && !isAdmin) {
1329+
throw new InvalidParameterValueException("Unable to grant permission to account " + caller.getAccountName() + " as it is neither admin nor owner or the template");
1330+
}
1331+
13271332
VMTemplateVO updatedTemplate = _tmpltDao.createForUpdate();
13281333

13291334
if (isPublic != null) {

0 commit comments

Comments
 (0)