diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-23 21:28:22 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-23 21:28:48 +0100 |
commit | d04c1fb8e215600b4950c6778c6c16ddafc14024 (patch) | |
tree | 796dc9260b6f0419c747a5b115f7307751d354d2 /src/machine/machinectl.c | |
parent | 18d703816300790b041c4fd6991e3561aa2704cb (diff) |
machined: introduce polkit for OpenLogin() call
This way "machinectl login" can be opened up to run without privileges.
Diffstat (limited to 'src/machine/machinectl.c')
-rw-r--r-- | src/machine/machinectl.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index f558c8495f..472fab6e49 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1012,7 +1012,7 @@ finish: static int login_machine(int argc, char *argv[], void *userdata) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; + _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL; _cleanup_(pty_forward_freep) PTYForward *forward = NULL; _cleanup_event_unref_ sd_event *event = NULL; int master = -1, r, ret = 0; @@ -1037,14 +1037,24 @@ static int login_machine(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to attach bus to event loop: %m"); - r = sd_bus_call_method(bus, - "org.freedesktop.machine1", - "/org/freedesktop/machine1", - "org.freedesktop.machine1.Manager", - "OpenMachineLogin", - &error, - &reply, - "s", argv[1]); + r = sd_bus_message_new_method_call(bus, + &m, + "org.freedesktop.machine1", + "/org/freedesktop/machine1", + "org.freedesktop.machine1.Manager", + "OpenMachineLogin"); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_set_allow_interactive_authorization(m, true); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_append(m, "s", argv[1]); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_call(bus, m, 0, &error, &reply); if (r < 0) { log_error("Failed to get machine PTY: %s", bus_error_message(&error, -r)); return r; |