]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machined: pass shell command line to polkit
authorLudwig Nussel <ludwig.nussel@suse.de>
Wed, 28 Dec 2022 13:00:35 +0000 (14:00 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 29 Dec 2022 12:29:25 +0000 (13:29 +0100)
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

index 7a45811614cbf94b2a4b0e981552f085f261783e..45bc056326b5f1c9ce218261bcd77d37e2288acc 100644 (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
         };