1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-21 18:03:41 +03:00

machined: pass shell command line to polkit

Pass the joined arguments to polkit as command_line property like
pkexec does. Obviously not exactly perfect as it lacks quoting. Good
enough for polkit rules to check whether a program was called with
or without arguments though.
This commit is contained in:
Ludwig Nussel 2022-12-28 14:00:35 +01:00 committed by Luca Boccassi
parent 7900968527
commit d353fcceb5

View File

@ -590,6 +590,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
sd_bus *container_bus = NULL;
_cleanup_close_ int master = -EBADF, slave = -EBADF;
_cleanup_strv_free_ char **env = NULL, **args_wire = NULL, **args = NULL;
_cleanup_free_ char *command_line = NULL;
Machine *m = ASSERT_PTR(userdata);
const char *p, *unit, *user, *path, *description, *utmp_id;
int r;
@ -642,10 +643,14 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
if (!strv_env_is_valid(env))
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
command_line = strv_join(args, " ");
if (!command_line)
return -ENOMEM;
const char *details[] = {
"machine", m->name,
"user", user,
"program", path,
"command_line", command_line,
NULL
};