From d353fcceb56634d0b05e83c2051f90785d98c646 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Wed, 28 Dec 2022 14:00:35 +0100 Subject: [PATCH] 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. --- src/machine/machine-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 7a45811614c..45bc056326b 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -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 }; -- 2.47.3