aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Érico Rolim <erico.erc@gmail.com>2020-05-21 00:46:28 -0300
committerLibravatar Simon Ser <contact@emersion.fr>2020-05-21 10:57:00 +0200
commit1d3681f5213535c1f47ed8bd0cddb7df775dd75e (patch)
treeb9fce1efbd9b479832b0f1d3210602ec77e876b5
parentFix typos in comments (diff)
downloadsway-1d3681f5213535c1f47ed8bd0cddb7df775dd75e.tar.gz
sway-1d3681f5213535c1f47ed8bd0cddb7df775dd75e.tar.zst
sway-1d3681f5213535c1f47ed8bd0cddb7df775dd75e.zip
Remove code related to the security features
- Remove struct definitions - Remove struct members - Remove initializations and frees
-rw-r--r--include/sway/config.h60
-rw-r--r--include/sway/security.h18
-rw-r--r--sway/commands.c23
-rw-r--r--sway/config.c8
-rw-r--r--sway/ipc-server.c1
-rw-r--r--sway/meson.build1
-rw-r--r--sway/security.c18
7 files changed, 0 insertions, 129 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 85605ce4..b3fd6668 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -401,61 +401,6 @@ enum command_context {
401 CONTEXT_ALL = 0xFFFFFFFF, 401 CONTEXT_ALL = 0xFFFFFFFF,
402}; 402};
403 403
404struct command_policy {
405 char *command;
406 uint32_t context;
407};
408
409enum secure_feature {
410 FEATURE_LOCK = 1 << 0,
411 FEATURE_PANEL = 1 << 1,
412 FEATURE_BACKGROUND = 1 << 2,
413 FEATURE_SCREENSHOT = 1 << 3,
414 FEATURE_FULLSCREEN = 1 << 4,
415 FEATURE_KEYBOARD = 1 << 5,
416 FEATURE_MOUSE = 1 << 6,
417};
418
419struct feature_policy {
420 char *program;
421 uint32_t features;
422};
423
424enum ipc_feature {
425 IPC_FEATURE_COMMAND = 1 << 0,
426 IPC_FEATURE_GET_WORKSPACES = 1 << 1,
427 IPC_FEATURE_GET_OUTPUTS = 1 << 2,
428 IPC_FEATURE_GET_TREE = 1 << 3,
429 IPC_FEATURE_GET_MARKS = 1 << 4,
430 IPC_FEATURE_GET_BAR_CONFIG = 1 << 5,
431 IPC_FEATURE_GET_VERSION = 1 << 6,
432 IPC_FEATURE_GET_INPUTS = 1 << 7,
433 IPC_FEATURE_EVENT_WORKSPACE = 1 << 8,
434 IPC_FEATURE_EVENT_OUTPUT = 1 << 9,
435 IPC_FEATURE_EVENT_MODE = 1 << 10,
436 IPC_FEATURE_EVENT_WINDOW = 1 << 11,
437 IPC_FEATURE_EVENT_BINDING = 1 << 12,
438 IPC_FEATURE_EVENT_INPUT = 1 << 13,
439 IPC_FEATURE_GET_SEATS = 1 << 14,
440
441 IPC_FEATURE_ALL_COMMANDS = IPC_FEATURE_COMMAND |
442 IPC_FEATURE_GET_WORKSPACES | IPC_FEATURE_GET_OUTPUTS |
443 IPC_FEATURE_GET_TREE | IPC_FEATURE_GET_MARKS |
444 IPC_FEATURE_GET_BAR_CONFIG | IPC_FEATURE_GET_VERSION |
445 IPC_FEATURE_GET_INPUTS | IPC_FEATURE_GET_SEATS,
446 IPC_FEATURE_ALL_EVENTS = IPC_FEATURE_EVENT_WORKSPACE |
447 IPC_FEATURE_EVENT_OUTPUT | IPC_FEATURE_EVENT_MODE |
448 IPC_FEATURE_EVENT_WINDOW | IPC_FEATURE_EVENT_BINDING |
449 IPC_FEATURE_EVENT_INPUT,
450
451 IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS,
452};
453
454struct ipc_policy {
455 char *program;
456 uint32_t features;
457};
458
459enum focus_follows_mouse_mode { 404enum focus_follows_mouse_mode {
460 FOLLOWS_NO, 405 FOLLOWS_NO,
461 FOLLOWS_YES, 406 FOLLOWS_YES,
@@ -584,11 +529,6 @@ struct sway_config {
584 int32_t floating_minimum_width; 529 int32_t floating_minimum_width;
585 int32_t floating_minimum_height; 530 int32_t floating_minimum_height;
586 531
587 // Security
588 list_t *command_policies;
589 list_t *feature_policies;
590 list_t *ipc_policies;
591
592 // The keysym to keycode translation 532 // The keysym to keycode translation
593 struct xkb_state *keysym_translation_state; 533 struct xkb_state *keysym_translation_state;
594 534
diff --git a/include/sway/security.h b/include/sway/security.h
deleted file mode 100644
index 0edffdfa..00000000
--- a/include/sway/security.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef _SWAY_SECURITY_H
2#define _SWAY_SECURITY_H
3#include <unistd.h>
4#include "sway/config.h"
5
6uint32_t get_feature_policy_mask(pid_t pid);
7uint32_t get_ipc_policy_mask(pid_t pid);
8uint32_t get_command_policy_mask(const char *cmd);
9
10struct feature_policy *get_feature_policy(const char *name);
11
12const char *command_policy_str(enum command_context context);
13
14struct feature_policy *alloc_feature_policy(const char *program);
15struct ipc_policy *alloc_ipc_policy(const char *program);
16struct command_policy *alloc_command_policy(const char *command);
17
18#endif
diff --git a/sway/commands.c b/sway/commands.c
index afe05b26..f20a8baa 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -9,7 +9,6 @@
9#include "sway/commands.h" 9#include "sway/commands.h"
10#include "sway/config.h" 10#include "sway/config.h"
11#include "sway/criteria.h" 11#include "sway/criteria.h"
12#include "sway/security.h"
13#include "sway/input/input-manager.h" 12#include "sway/input/input-manager.h"
14#include "sway/input/seat.h" 13#include "sway/input/seat.h"
15#include "sway/tree/view.h" 14#include "sway/tree/view.h"
@@ -489,28 +488,6 @@ struct cmd_results *config_commands_command(char *exec) {
489 context |= context_names[j].context; 488 context |= context_names[j].context;
490 } 489 }
491 490
492 struct command_policy *policy = NULL;
493 for (int i = 0; i < config->command_policies->length; ++i) {
494 struct command_policy *p = config->command_policies->items[i];
495 if (strcmp(p->command, cmd) == 0) {
496 policy = p;
497 break;
498 }
499 }
500 if (!policy) {
501 policy = alloc_command_policy(cmd);
502 if (!sway_assert(policy, "Unable to allocate security policy")) {
503 results = cmd_results_new(CMD_INVALID,
504 "Unable to allocate memory");
505 goto cleanup;
506 }
507 list_add(config->command_policies, policy);
508 }
509 policy->context = context;
510
511 sway_log(SWAY_INFO, "Set command policy for %s to %d",
512 policy->command, policy->context);
513
514 results = cmd_results_new(CMD_SUCCESS, NULL); 491 results = cmd_results_new(CMD_SUCCESS, NULL);
515 492
516cleanup: 493cleanup:
diff --git a/sway/config.c b/sway/config.c
index fe811d27..bcf8d56f 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -154,9 +154,6 @@ void free_config(struct sway_config *config) {
154 list_free(config->no_focus); 154 list_free(config->no_focus);
155 list_free(config->active_bar_modifiers); 155 list_free(config->active_bar_modifiers);
156 list_free_items_and_destroy(config->config_chain); 156 list_free_items_and_destroy(config->config_chain);
157 list_free(config->command_policies);
158 list_free(config->feature_policies);
159 list_free(config->ipc_policies);
160 free(config->floating_scroll_up_cmd); 157 free(config->floating_scroll_up_cmd);
161 free(config->floating_scroll_down_cmd); 158 free(config->floating_scroll_down_cmd);
162 free(config->floating_scroll_left_cmd); 159 free(config->floating_scroll_left_cmd);
@@ -327,11 +324,6 @@ static void config_defaults(struct sway_config *config) {
327 324
328 color_to_rgba(config->border_colors.background, 0xFFFFFFFF); 325 color_to_rgba(config->border_colors.background, 0xFFFFFFFF);
329 326
330 // Security
331 if (!(config->command_policies = create_list())) goto cleanup;
332 if (!(config->feature_policies = create_list())) goto cleanup;
333 if (!(config->ipc_policies = create_list())) goto cleanup;
334
335 // The keysym to keycode translation 327 // The keysym to keycode translation
336 struct xkb_rule_names rules = {0}; 328 struct xkb_rule_names rules = {0};
337 config->keysym_translation_state = 329 config->keysym_translation_state =
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 5e1cca89..bd9f40bc 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -47,7 +47,6 @@ struct ipc_client {
47 struct wl_event_source *writable_event_source; 47 struct wl_event_source *writable_event_source;
48 struct sway_server *server; 48 struct sway_server *server;
49 int fd; 49 int fd;
50 uint32_t security_policy;
51 enum ipc_command_type subscribed_events; 50 enum ipc_command_type subscribed_events;
52 size_t write_buffer_len; 51 size_t write_buffer_len;
53 size_t write_buffer_size; 52 size_t write_buffer_size;
diff --git a/sway/meson.build b/sway/meson.build
index d71846a4..0db45836 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -6,7 +6,6 @@ sway_sources = files(
6 'ipc-json.c', 6 'ipc-json.c',
7 'ipc-server.c', 7 'ipc-server.c',
8 'main.c', 8 'main.c',
9 'security.c',
10 'server.c', 9 'server.c',
11 'swaynag.c', 10 'swaynag.c',
12 'xdg_decoration.c', 11 'xdg_decoration.c',
diff --git a/sway/security.c b/sway/security.c
deleted file mode 100644
index 6a00229e..00000000
--- a/sway/security.c
+++ /dev/null
@@ -1,18 +0,0 @@
1#define _POSIX_C_SOURCE 200809L
2#include <stdlib.h>
3#include <string.h>
4#include "sway/security.h"
5
6struct command_policy *alloc_command_policy(const char *command) {
7 struct command_policy *policy = malloc(sizeof(struct command_policy));
8 if (!policy) {
9 return NULL;
10 }
11 policy->command = strdup(command);
12 if (!policy->command) {
13 free(policy);
14 return NULL;
15 }
16 policy->context = 0;
17 return policy;
18}