Disambiguate get_*_policy() and get_*_policy_mask()

master
Jerzi Kaminsky 8 years ago
parent edb8075ae0
commit cf5e764c7f

@ -3,9 +3,9 @@
#include <unistd.h> #include <unistd.h>
#include "sway/config.h" #include "sway/config.h"
uint32_t get_feature_policy(pid_t pid); uint32_t get_feature_policy_mask(pid_t pid);
uint32_t get_ipc_policy(pid_t pid); uint32_t get_ipc_policy_mask(pid_t pid);
uint32_t get_command_policy(const char *cmd); uint32_t get_command_policy_mask(const char *cmd);
const char *command_policy_str(enum command_context context); const char *command_policy_str(enum command_context context);

@ -437,7 +437,7 @@ struct cmd_results *handle_command(char *_exec, enum command_context context) {
free_argv(argc, argv); free_argv(argc, argv);
goto cleanup; goto cleanup;
} }
if (!(get_command_policy(argv[0]) & context)) { if (!(get_command_policy_mask(argv[0]) & context)) {
if (results) { if (results) {
free_cmd_results(results); free_cmd_results(results);
} }

@ -86,7 +86,7 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc
struct wl_resource *_output, struct wl_resource *surface) { struct wl_resource *_output, struct wl_resource *surface) {
pid_t pid; pid_t pid;
wl_client_get_credentials(client, &pid, NULL, NULL); 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); sway_log(L_INFO, "Denying background feature to %d", pid);
return; 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) { struct wl_resource *_output, struct wl_resource *surface) {
pid_t pid; pid_t pid;
wl_client_get_credentials(client, &pid, NULL, NULL); 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); sway_log(L_INFO, "Denying panel feature to %d", pid);
return; 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) { static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) {
pid_t pid; pid_t pid;
wl_client_get_credentials(client, &pid, NULL, NULL); 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); sway_log(L_INFO, "Denying panel feature to %d", pid);
return; 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) { struct wl_resource *_output, struct wl_resource *surface) {
pid_t pid; pid_t pid;
wl_client_get_credentials(client, &pid, NULL, NULL); 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); sway_log(L_INFO, "Denying lock feature to %d", pid);
return; return;
} }

@ -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); pid_t pid = wlc_view_get_pid(view);
switch (state) { switch (state) {
case WLC_BIT_FULLSCREEN: 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); sway_log(L_INFO, "Denying fullscreen to %d (%s)", pid, c->name);
break; 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); swayc_t *focused = get_focused_container(&root_container);
if (focused->type == C_VIEW) { if (focused->type == C_VIEW) {
pid_t pid = wlc_view_get_pid(focused->handle); 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; 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); swayc_t *focused = get_focused_container(&root_container);
if (focused->type == C_VIEW) { if (focused->type == C_VIEW) {
pid_t pid = wlc_view_get_pid(focused->handle); 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; 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 (swayc_is_fullscreen(focused)) {
if (focused->type == C_VIEW) { if (focused->type == C_VIEW) {
pid_t pid = wlc_view_get_pid(focused->handle); 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; 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) { if (focused->type == C_VIEW) {
pid_t pid = wlc_view_get_pid(focused->handle); 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; return EVENT_HANDLED;
} }
} }

@ -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); 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); 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); list_add(ipc_client_list, client);

@ -94,7 +94,7 @@ static const char *get_pid_exe(pid_t pid) {
return link; return link;
} }
uint32_t get_feature_policy(pid_t pid) { uint32_t get_feature_policy_mask(pid_t pid) {
uint32_t default_policy = 0; uint32_t default_policy = 0;
const char *link = get_pid_exe(pid); const char *link = get_pid_exe(pid);
@ -111,7 +111,7 @@ uint32_t get_feature_policy(pid_t pid) {
return default_policy; 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; uint32_t default_policy = 0;
const char *link = get_pid_exe(pid); const char *link = get_pid_exe(pid);
@ -128,7 +128,7 @@ uint32_t get_ipc_policy(pid_t pid) {
return default_policy; 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; uint32_t default_policy = 0;
for (int i = 0; i < config->command_policies->length; ++i) { for (int i = 0; i < config->command_policies->length; ++i) {

Loading…
Cancel
Save