diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-02 08:10:03 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-12-02 08:10:03 -0500 |
commit | f23880b1fdd70a21b04317c18208a1f3ce356839 (patch) | |
tree | 51a54d43531ac28ef014193abef8f4ccd7a78332 /sway/security.c | |
parent | Enforce mouse permissions (diff) | |
download | sway-f23880b1fdd70a21b04317c18208a1f3ce356839.tar.gz sway-f23880b1fdd70a21b04317c18208a1f3ce356839.tar.zst sway-f23880b1fdd70a21b04317c18208a1f3ce356839.zip |
Add support for command policies in config file
Diffstat (limited to 'sway/security.c')
-rw-r--r-- | sway/security.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sway/security.c b/sway/security.c index a4cecf16..670cae56 100644 --- a/sway/security.c +++ b/sway/security.c | |||
@@ -11,6 +11,13 @@ struct feature_policy *alloc_feature_policy(const char *program) { | |||
11 | return policy; | 11 | return policy; |
12 | } | 12 | } |
13 | 13 | ||
14 | struct command_policy *alloc_command_policy(const char *command) { | ||
15 | struct command_policy *policy = malloc(sizeof(struct command_policy)); | ||
16 | policy->command = strdup(command); | ||
17 | policy->context = CONTEXT_ALL; | ||
18 | return policy; | ||
19 | } | ||
20 | |||
14 | enum secure_feature get_feature_policy(pid_t pid) { | 21 | enum secure_feature get_feature_policy(pid_t pid) { |
15 | const char *fmt = "/proc/%d/exe"; | 22 | const char *fmt = "/proc/%d/exe"; |
16 | int pathlen = snprintf(NULL, 0, fmt, pid); | 23 | int pathlen = snprintf(NULL, 0, fmt, pid); |
@@ -50,9 +57,6 @@ enum command_context get_command_policy(const char *cmd) { | |||
50 | 57 | ||
51 | for (int i = 0; i < config->command_policies->length; ++i) { | 58 | for (int i = 0; i < config->command_policies->length; ++i) { |
52 | struct command_policy *policy = config->command_policies->items[i]; | 59 | struct command_policy *policy = config->command_policies->items[i]; |
53 | if (strcmp(policy->command, "*") == 0) { | ||
54 | default_policy = policy->context; | ||
55 | } | ||
56 | if (strcmp(policy->command, cmd) == 0) { | 60 | if (strcmp(policy->command, cmd) == 0) { |
57 | return policy->context; | 61 | return policy->context; |
58 | } | 62 | } |