mirror of
https://github.com/labwc/labwc.git
synced 2026-04-17 06:46:28 -04:00
add permissions to actions
This commit is contained in:
parent
589ea47920
commit
bed325a7ff
6 changed files with 28 additions and 7 deletions
12
src/action.c
12
src/action.c
|
|
@ -27,6 +27,7 @@
|
|||
#include "menu/menu.h"
|
||||
#include "output.h"
|
||||
#include "output-virtual.h"
|
||||
#include "permissions.h"
|
||||
#include "regions.h"
|
||||
#include "ssd.h"
|
||||
#include "theme.h"
|
||||
|
|
@ -302,6 +303,9 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
|||
if (!strcmp(argument, "command") || !strcmp(argument, "execute")) {
|
||||
action_arg_add_str(action, "command", content);
|
||||
goto cleanup;
|
||||
} else if (!strcmp(argument, "allow")) {
|
||||
action->allowed_interfaces |= parse_privileged_interface(content);
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
case ACTION_TYPE_MOVE_TO_EDGE:
|
||||
|
|
@ -570,6 +574,7 @@ action_create(const char *action_name)
|
|||
|
||||
struct action *action = znew(*action);
|
||||
action->type = action_type;
|
||||
action->allowed_interfaces = 0;
|
||||
wl_list_init(&action->args);
|
||||
return action;
|
||||
}
|
||||
|
|
@ -1077,7 +1082,12 @@ run_action(struct view *view, struct action *action,
|
|||
struct buf cmd = BUF_INIT;
|
||||
buf_add(&cmd, action_get_str(action, "command", NULL));
|
||||
buf_expand_tilde(&cmd);
|
||||
spawn_async_no_shell(cmd.data);
|
||||
int socket_fd = -1;
|
||||
if (action->allowed_interfaces) {
|
||||
socket_fd = permissions_context_create(
|
||||
server.wl_display, action->allowed_interfaces);
|
||||
}
|
||||
spawn_async_no_shell(cmd.data, socket_fd);
|
||||
buf_reset(&cmd);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,11 @@ set_cloexec(int fd)
|
|||
}
|
||||
|
||||
void
|
||||
spawn_async_no_shell(char const *command)
|
||||
spawn_async_no_shell(char const *command, int socket_fd)
|
||||
{
|
||||
GError *err = NULL;
|
||||
gchar **argv = NULL;
|
||||
char socket_str[32];
|
||||
|
||||
assert(command);
|
||||
|
||||
|
|
@ -73,6 +74,12 @@ spawn_async_no_shell(char const *command)
|
|||
reset_signals_and_limits();
|
||||
|
||||
setsid();
|
||||
if (socket_fd != -1) {
|
||||
snprintf(socket_str, sizeof(socket_str), "%d", socket_fd);
|
||||
if (setenv("WAYLAND_SOCKET", socket_str, 1) != 0) {
|
||||
wlr_log(WLR_ERROR, "unable to setenv() WAYLAND_SOCKET");
|
||||
}
|
||||
}
|
||||
grandchild = fork();
|
||||
if (grandchild == 0) {
|
||||
execvp(argv[0], argv);
|
||||
|
|
@ -84,6 +91,9 @@ spawn_async_no_shell(char const *command)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (socket_fd != -1) {
|
||||
close(socket_fd);
|
||||
}
|
||||
waitpid(child, NULL, 0);
|
||||
out:
|
||||
g_strfreev(argv);
|
||||
|
|
|
|||
|
|
@ -219,12 +219,12 @@ execute_update(const char *env_keys, const char *env_unset_keys, bool initialize
|
|||
char *cmd =
|
||||
strdup_printf("dbus-update-activation-environment %s",
|
||||
initialize ? env_keys : env_unset_keys);
|
||||
spawn_async_no_shell(cmd);
|
||||
spawn_async_no_shell(cmd, -1);
|
||||
free(cmd);
|
||||
|
||||
cmd = strdup_printf("systemctl --user %s %s",
|
||||
initialize ? "import-environment" : "unset-environment", env_keys);
|
||||
spawn_async_no_shell(cmd);
|
||||
spawn_async_no_shell(cmd, -1);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ session_run_script(const char *script)
|
|||
}
|
||||
wlr_log(WLR_INFO, "run session script %s", path->string);
|
||||
char *cmd = strdup_printf("sh %s", path->string);
|
||||
spawn_async_no_shell(cmd);
|
||||
spawn_async_no_shell(cmd, -1);
|
||||
free(cmd);
|
||||
|
||||
if (!should_merge_config) {
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ idle_callback(void *data)
|
|||
|
||||
session_autostart_init();
|
||||
if (ctx->startup_cmd) {
|
||||
spawn_async_no_shell(ctx->startup_cmd);
|
||||
spawn_async_no_shell(ctx->startup_cmd, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue