diff options
author | Drew DeVault <[email protected]> | 2017-04-16 10:17:43 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-16 10:17:43 -0400 |
commit | 7494a48378bff3b11304ba4077bda5a84ed10087 (patch) | |
tree | 21abe14fe200099fffe5de9b7770cf2ca921e371 /sway/commands/ipc.c | |
parent | edb8075ae0c0986fb168b464b05e0b54537f8f30 (diff) | |
parent | 2ad8850398693cb572152e6d97c59de371996273 (diff) |
Merge pull request #1173 from JerziKaminsky/security_resolve_symlink
FOR_REVIEW: IPC security - Allow policy targets to be symlinks
Diffstat (limited to 'sway/commands/ipc.c')
-rw-r--r-- | sway/commands/ipc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sway/commands/ipc.c b/sway/commands/ipc.c index 8a7b849f..f0b3035a 100644 --- a/sway/commands/ipc.c +++ b/sway/commands/ipc.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include <stdio.h> #include <string.h> #include "sway/security.h" @@ -18,8 +19,14 @@ struct cmd_results *cmd_ipc(int argc, char **argv) { return error; } - const char *program = argv[0]; + char *program = NULL; + if (!strcmp(argv[0], "*")) { + program = strdup(argv[0]); + } else if (!(program = resolve_path(argv[0]))) { + return cmd_results_new( + CMD_INVALID, "ipc", "Unable to resolve IPC Policy target."); + } if (config->reading && strcmp("{", argv[1]) != 0) { return cmd_results_new(CMD_INVALID, "ipc", "Expected '{' at start of IPC config definition."); @@ -32,6 +39,7 @@ struct cmd_results *cmd_ipc(int argc, char **argv) { current_policy = alloc_ipc_policy(program); list_add(config->ipc_policies, current_policy); + free(program); return cmd_results_new(CMD_BLOCK_IPC, NULL, NULL); } |