actions: Allow privileged methods to be decorated again

- So that we write decorators that can handle errors as needed by backups app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-12-23 23:01:48 -08:00 committed by James Valleroy
parent 3a0db947b2
commit 9b29ea960f
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -383,7 +383,14 @@ def _privileged_call(module_name, action_name, arguments):
if not getattr(action, '_privileged', None):
raise SyntaxError('Specified action is not privileged action')
func = getattr(action, '__wrapped__')
# Get the original function that may have been wrapped/decorated multiple
# times
func = action
while True:
try:
func = getattr(func, '__wrapped__')
except AttributeError:
break
_privileged_assert_valid_arguments(func, arguments)