aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Jerzi Kaminsky <JerziKaminsky@users.noreply.github.com>2017-04-15 17:16:32 +0300
committerLibravatar Jerzi Kaminsky <JerziKaminsky@users.noreply.github.com>2017-04-16 17:09:53 +0300
commitbfb99235e323e31689e280867103d3bc2e39ac22 (patch)
tree8332d7d88a2bcca48bf62a212ad55ee01ff87f6b /sway
parentRename get_policy to get_feature_policy (diff)
downloadsway-bfb99235e323e31689e280867103d3bc2e39ac22.tar.gz
sway-bfb99235e323e31689e280867103d3bc2e39ac22.tar.zst
sway-bfb99235e323e31689e280867103d3bc2e39ac22.zip
Move get_feature_policy to sway/security.c
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/permit.c19
-rw-r--r--sway/security.c20
2 files changed, 20 insertions, 19 deletions
diff --git a/sway/commands/permit.c b/sway/commands/permit.c
index 4a78ef0d..c55f46d8 100644
--- a/sway/commands/permit.c
+++ b/sway/commands/permit.c
@@ -38,25 +38,6 @@ static enum secure_feature get_features(int argc, char **argv,
38 return features; 38 return features;
39} 39}
40 40
41static struct feature_policy *get_feature_policy(const char *name) {
42 struct feature_policy *policy = NULL;
43 for (int i = 0; i < config->feature_policies->length; ++i) {
44 struct feature_policy *p = config->feature_policies->items[i];
45 if (strcmp(p->program, name) == 0) {
46 policy = p;
47 break;
48 }
49 }
50 if (!policy) {
51 policy = alloc_feature_policy(name);
52 if (!policy) {
53 sway_abort("Unable to allocate security policy");
54 }
55 list_add(config->feature_policies, policy);
56 }
57 return policy;
58}
59
60struct cmd_results *cmd_permit(int argc, char **argv) { 41struct cmd_results *cmd_permit(int argc, char **argv) {
61 struct cmd_results *error = NULL; 42 struct cmd_results *error = NULL;
62 if ((error = checkarg(argc, "permit", EXPECTED_MORE_THAN, 1))) { 43 if ((error = checkarg(argc, "permit", EXPECTED_MORE_THAN, 1))) {
diff --git a/sway/security.c b/sway/security.c
index 5b762b07..96af2b88 100644
--- a/sway/security.c
+++ b/sway/security.c
@@ -94,6 +94,26 @@ static const char *get_pid_exe(pid_t pid) {
94 return link; 94 return link;
95} 95}
96 96
97struct feature_policy *get_feature_policy(const char *name) {
98 struct feature_policy *policy = NULL;
99
100 for (int i = 0; i < config->feature_policies->length; ++i) {
101 struct feature_policy *p = config->feature_policies->items[i];
102 if (strcmp(p->program, name) == 0) {
103 policy = p;
104 break;
105 }
106 }
107 if (!policy) {
108 policy = alloc_feature_policy(name);
109 if (!policy) {
110 sway_abort("Unable to allocate security policy");
111 }
112 list_add(config->feature_policies, policy);
113 }
114 return policy;
115}
116
97uint32_t get_feature_policy_mask(pid_t pid) { 117uint32_t get_feature_policy_mask(pid_t pid) {
98 uint32_t default_policy = 0; 118 uint32_t default_policy = 0;
99 const char *link = get_pid_exe(pid); 119 const char *link = get_pid_exe(pid);