diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-02-20 07:42:08 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-02-20 07:51:31 -0500 |
commit | 126ce571dab09d84d8ee1b760981dbba7cbc1000 (patch) | |
tree | c13e957c752e3ae0798945e2e0be2af99da7dc68 /sway/ipc-server.c | |
parent | Add * policies and fix bug (diff) | |
download | sway-126ce571dab09d84d8ee1b760981dbba7cbc1000.tar.gz sway-126ce571dab09d84d8ee1b760981dbba7cbc1000.tar.zst sway-126ce571dab09d84d8ee1b760981dbba7cbc1000.zip |
Read configs from /etc/sway/security.d/*
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 20a19b44..eddae461 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -241,8 +241,7 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) { | |||
241 | return 0; | 241 | return 0; |
242 | } | 242 | } |
243 | 243 | ||
244 | void ipc_client_disconnect(struct ipc_client *client) | 244 | void ipc_client_disconnect(struct ipc_client *client) { |
245 | { | ||
246 | if (!sway_assert(client != NULL, "client != NULL")) { | 245 | if (!sway_assert(client != NULL, "client != NULL")) { |
247 | return; | 246 | return; |
248 | } | 247 | } |
@@ -326,8 +325,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
326 | ipc_client_disconnect(client); | 325 | ipc_client_disconnect(client); |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | if (client->payload_length > 0) | 328 | if (client->payload_length > 0) { |
330 | { | ||
331 | ssize_t received = recv(client->fd, buf, client->payload_length, 0); | 329 | ssize_t received = recv(client->fd, buf, client->payload_length, 0); |
332 | if (received == -1) | 330 | if (received == -1) |
333 | { | 331 | { |
@@ -397,7 +395,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
397 | 395 | ||
398 | case IPC_GET_WORKSPACES: | 396 | case IPC_GET_WORKSPACES: |
399 | { | 397 | { |
400 | if (!(client->security_policy & IPC_FEATURE_GET_TREE)) { | 398 | if (!(client->security_policy & IPC_FEATURE_GET_WORKSPACES)) { |
401 | goto exit_denied; | 399 | goto exit_denied; |
402 | } | 400 | } |
403 | json_object *workspaces = json_object_new_array(); | 401 | json_object *workspaces = json_object_new_array(); |
@@ -410,7 +408,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
410 | 408 | ||
411 | case IPC_GET_INPUTS: | 409 | case IPC_GET_INPUTS: |
412 | { | 410 | { |
413 | if (!(client->security_policy & IPC_FEATURE_GET_TREE)) { | 411 | if (!(client->security_policy & IPC_FEATURE_GET_INPUTS)) { |
414 | goto exit_denied; | 412 | goto exit_denied; |
415 | } | 413 | } |
416 | json_object *inputs = json_object_new_array(); | 414 | json_object *inputs = json_object_new_array(); |
@@ -436,7 +434,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
436 | 434 | ||
437 | case IPC_GET_OUTPUTS: | 435 | case IPC_GET_OUTPUTS: |
438 | { | 436 | { |
439 | if (!(client->security_policy & IPC_FEATURE_GET_TREE)) { | 437 | if (!(client->security_policy & IPC_FEATURE_GET_OUTPUTS)) { |
440 | goto exit_denied; | 438 | goto exit_denied; |
441 | } | 439 | } |
442 | json_object *outputs = json_object_new_array(); | 440 | json_object *outputs = json_object_new_array(); |
@@ -561,6 +559,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
561 | 559 | ||
562 | exit_denied: | 560 | exit_denied: |
563 | ipc_send_reply(client, error_denied, (uint32_t)strlen(error_denied)); | 561 | ipc_send_reply(client, error_denied, (uint32_t)strlen(error_denied)); |
562 | sway_log(L_DEBUG, "Denied IPC client access to %i", client->current_command); | ||
564 | 563 | ||
565 | exit_cleanup: | 564 | exit_cleanup: |
566 | client->payload_length = 0; | 565 | client->payload_length = 0; |
@@ -588,6 +587,8 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay | |||
588 | return false; | 587 | return false; |
589 | } | 588 | } |
590 | 589 | ||
590 | sway_log(L_DEBUG, "Send IPC reply: %s", payload); | ||
591 | |||
591 | return true; | 592 | return true; |
592 | } | 593 | } |
593 | 594 | ||