diff --git a/include/sway/security.h b/include/sway/security.h index c3a5cfd4..d60f264a 100644 --- a/include/sway/security.h +++ b/include/sway/security.h @@ -3,9 +3,9 @@ #include #include "sway/config.h" -uint32_t get_feature_policy(pid_t pid); -uint32_t get_ipc_policy(pid_t pid); -uint32_t get_command_policy(const char *cmd); +uint32_t get_feature_policy_mask(pid_t pid); +uint32_t get_ipc_policy_mask(pid_t pid); +uint32_t get_command_policy_mask(const char *cmd); const char *command_policy_str(enum command_context context); diff --git a/sway/commands.c b/sway/commands.c index 17c7d717..4d7af301 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -437,7 +437,7 @@ struct cmd_results *handle_command(char *_exec, enum command_context context) { free_argv(argc, argv); goto cleanup; } - if (!(get_command_policy(argv[0]) & context)) { + if (!(get_command_policy_mask(argv[0]) & context)) { if (results) { free_cmd_results(results); } diff --git a/sway/extensions.c b/sway/extensions.c index 15d2f971..96957dbf 100644 --- a/sway/extensions.c +++ b/sway/extensions.c @@ -86,7 +86,7 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc struct wl_resource *_output, struct wl_resource *surface) { pid_t pid; wl_client_get_credentials(client, &pid, NULL, NULL); - if (!(get_feature_policy(pid) & FEATURE_BACKGROUND)) { + if (!(get_feature_policy_mask(pid) & FEATURE_BACKGROUND)) { sway_log(L_INFO, "Denying background feature to %d", pid); return; } @@ -114,7 +114,7 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource, struct wl_resource *_output, struct wl_resource *surface) { pid_t pid; wl_client_get_credentials(client, &pid, NULL, NULL); - if (!(get_feature_policy(pid) & FEATURE_PANEL)) { + if (!(get_feature_policy_mask(pid) & FEATURE_PANEL)) { sway_log(L_INFO, "Denying panel feature to %d", pid); return; } @@ -152,7 +152,7 @@ static void desktop_ready(struct wl_client *client, struct wl_resource *resource static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { pid_t pid; wl_client_get_credentials(client, &pid, NULL, NULL); - if (!(get_feature_policy(pid) & FEATURE_PANEL)) { + if (!(get_feature_policy_mask(pid) & FEATURE_PANEL)) { sway_log(L_INFO, "Denying panel feature to %d", pid); return; } @@ -191,7 +191,7 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou struct wl_resource *_output, struct wl_resource *surface) { pid_t pid; wl_client_get_credentials(client, &pid, NULL, NULL); - if (!(get_feature_policy(pid) & FEATURE_LOCK)) { + if (!(get_feature_policy_mask(pid) & FEATURE_LOCK)) { sway_log(L_INFO, "Denying lock feature to %d", pid); return; } diff --git a/sway/handlers.c b/sway/handlers.c index b61c0a19..a8de135f 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -595,7 +595,7 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s pid_t pid = wlc_view_get_pid(view); switch (state) { case WLC_BIT_FULLSCREEN: - if (!(get_feature_policy(pid) & FEATURE_FULLSCREEN)) { + if (!(get_feature_policy_mask(pid) & FEATURE_FULLSCREEN)) { sway_log(L_INFO, "Denying fullscreen to %d (%s)", pid, c->name); break; } @@ -811,7 +811,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier swayc_t *focused = get_focused_container(&root_container); if (focused->type == C_VIEW) { pid_t pid = wlc_view_get_pid(focused->handle); - if (!(get_feature_policy(pid) & FEATURE_KEYBOARD)) { + if (!(get_feature_policy_mask(pid) & FEATURE_KEYBOARD)) { return EVENT_HANDLED; } } @@ -875,7 +875,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct swayc_t *focused = get_focused_container(&root_container); if (focused->type == C_VIEW) { pid_t pid = wlc_view_get_pid(focused->handle); - if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { + if (!(get_feature_policy_mask(pid) & FEATURE_MOUSE)) { return EVENT_HANDLED; } } @@ -953,7 +953,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w if (swayc_is_fullscreen(focused)) { if (focused->type == C_VIEW) { pid_t pid = wlc_view_get_pid(focused->handle); - if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { + if (!(get_feature_policy_mask(pid) & FEATURE_MOUSE)) { return EVENT_HANDLED; } } @@ -1001,7 +1001,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w if (focused->type == C_VIEW) { pid_t pid = wlc_view_get_pid(focused->handle); - if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { + if (!(get_feature_policy_mask(pid) & FEATURE_MOUSE)) { return EVENT_HANDLED; } } diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 67a3cdc8..dca881fa 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -181,7 +181,7 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) { client->event_source = wlc_event_loop_add_fd(client_fd, WLC_EVENT_READABLE, ipc_client_handle_readable, client); pid_t pid = get_client_pid(client->fd); - client->security_policy = get_ipc_policy(pid); + client->security_policy = get_ipc_policy_mask(pid); list_add(ipc_client_list, client); diff --git a/sway/security.c b/sway/security.c index f8a96ba7..5b762b07 100644 --- a/sway/security.c +++ b/sway/security.c @@ -94,7 +94,7 @@ static const char *get_pid_exe(pid_t pid) { return link; } -uint32_t get_feature_policy(pid_t pid) { +uint32_t get_feature_policy_mask(pid_t pid) { uint32_t default_policy = 0; const char *link = get_pid_exe(pid); @@ -111,7 +111,7 @@ uint32_t get_feature_policy(pid_t pid) { return default_policy; } -uint32_t get_ipc_policy(pid_t pid) { +uint32_t get_ipc_policy_mask(pid_t pid) { uint32_t default_policy = 0; const char *link = get_pid_exe(pid); @@ -128,7 +128,7 @@ uint32_t get_ipc_policy(pid_t pid) { return default_policy; } -uint32_t get_command_policy(const char *cmd) { +uint32_t get_command_policy_mask(const char *cmd) { uint32_t default_policy = 0; for (int i = 0; i < config->command_policies->length; ++i) {