aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 0bfe9d13..5d5087b1 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -323,7 +323,7 @@ static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
323 return res; 323 return res;
324} 324}
325 325
326struct cmd_results *handle_command(char *_exec) { 326struct cmd_results *handle_command(char *_exec, enum command_context context) {
327 // Even though this function will process multiple commands we will only 327 // Even though this function will process multiple commands we will only
328 // return the last error, if any (for now). (Since we have access to an 328 // return the last error, if any (for now). (Since we have access to an
329 // error string we could e.g. concatonate all errors there.) 329 // error string we could e.g. concatonate all errors there.)
@@ -397,6 +397,16 @@ struct cmd_results *handle_command(char *_exec) {
397 free_argv(argc, argv); 397 free_argv(argc, argv);
398 goto cleanup; 398 goto cleanup;
399 } 399 }
400 if (!(get_command_policy(argv[0]) & context)) {
401 if (results) {
402 free_cmd_results(results);
403 }
404 results = cmd_results_new(CMD_INVALID, cmd,
405 "Permission denied for %s via %s", cmd,
406 command_policy_str(context));
407 free_argv(argc, argv);
408 goto cleanup;
409 }
400 struct cmd_results *res = handler->handle(argc-1, argv+1); 410 struct cmd_results *res = handler->handle(argc-1, argv+1);
401 if (res->status != CMD_SUCCESS) { 411 if (res->status != CMD_SUCCESS) {
402 free_argv(argc, argv); 412 free_argv(argc, argv);