From 9b29ea960f6728070faf0d62f0eb5f2b2c41bfff Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 23 Dec 2024 23:01:48 -0800 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/actions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plinth/actions.py b/plinth/actions.py index 02cad2bd3..aa1c67c76 100644 --- a/plinth/actions.py +++ b/plinth/actions.py @@ -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)