Skip to content

Commit 5857cd4

Browse files
AZero13millert
authored andcommitted
Remove unreachable python code " raise sudo.PluginError("You are not allowed to run this command!")"
I know this is an example but still. We should do this the right way.
1 parent 23e7abc commit 5857cd4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

plugins/python/example_policy_plugin.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ def check_policy(self, argv: tuple, env_add: tuple):
6868
cmd = argv[0]
6969
# Example for a simple reject:
7070
if not self._is_command_allowed(cmd):
71-
sudo.log_error("You are not allowed to run this command!")
72-
return sudo.RC.REJECT
73-
74-
raise sudo.PluginError("You are not allowed to run this command!")
71+
error_msg = "You are not allowed to run this command!"
72+
sudo.log_error(error_msg)
73+
raise sudo.PluginReject(error_msg)
7574

7675
# The environment the command will be executed with (we allow any here)
7776
user_env_out = sudo.options_from_dict(self.user_env) + env_add

0 commit comments

Comments
 (0)