From 9185198bf8561da875dc8e01b92481f4c1b95e57 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Jun 16 2020 15:09:10 +0000 Subject: [PATCH 1/2] Actually return results from is_sidetag()/_owner() Signed-off-by: Nils Philippsen --- diff --git a/plugins/hub/sidetag_hub.py b/plugins/hub/sidetag_hub.py index beb40ba..d50732d 100644 --- a/plugins/hub/sidetag_hub.py +++ b/plugins/hub/sidetag_hub.py @@ -34,6 +34,8 @@ def is_sidetag(taginfo, raise_error=False): if not result and raise_error: raise koji.GenericError("Not a sidetag: %(name)s" % taginfo) + return result + def is_sidetag_owner(taginfo, user, raise_error=False): """Check, that given user is owner of the sidetag""" @@ -42,6 +44,8 @@ def is_sidetag_owner(taginfo, user, raise_error=False): if not result and raise_error: raise koji.ActionNotAllowed("This is not your sidetag") + return result + # Policy tests class SidetagTest(koji.policy.MatchTest): From 0bd824fafd74d8d30c1f038f93a01b25a0bd243c Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Jun 16 2020 15:16:23 +0000 Subject: [PATCH 2/2] Allow admins to operate on all sidetags Fixes: #2321 Signed-off-by: Nils Philippsen --- diff --git a/plugins/hub/sidetag_hub.py b/plugins/hub/sidetag_hub.py index d50732d..eb6ad65 100644 --- a/plugins/hub/sidetag_hub.py +++ b/plugins/hub/sidetag_hub.py @@ -40,7 +40,8 @@ def is_sidetag(taginfo, raise_error=False): def is_sidetag_owner(taginfo, user, raise_error=False): """Check, that given user is owner of the sidetag""" result = (taginfo['extra'].get('sidetag') and - taginfo['extra'].get('sidetag_user_id') == user['id']) + (taginfo['extra'].get('sidetag_user_id') == user['id'] or + context.session.hasPerm('admin')))) if not result and raise_error: raise koji.ActionNotAllowed("This is not your sidetag")