mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
loginctl: show a nicer error message when no session/seat is available
When calling loginctl {seat,session}-status without arguments, show a nicer
error message in case there's no suitable session/seat attached to the calling
tty.
Before:
~# loginctl seat-status
Could not get properties: Unknown object '/org/freedesktop/login1/seat/auto'.
~# systemd-run -q -t loginctl seat-status
Could not get properties: Unknown object '/org/freedesktop/login1/seat/auto'.
~# systemd-run -q -t loginctl session-status
Could not get properties: Unknown object '/org/freedesktop/login1/session/auto'.
After:
~# build/loginctl seat-status
Failed to get path for seat 'auto': Session '1' has no seat.
~# systemd-run -q -t build/loginctl seat-status
Failed to get path for seat 'auto': Caller does not belong to any known session and doesn't own any suitable session.
~# systemd-run -q -t build/loginctl session-status
Failed to get path for session 'auto': Caller does not belong to any known session and doesn't own any suitable session.
Resolves: #25199
This commit is contained in:
committed by
Daan De Meyer
parent
3ed6f7a57e
commit
b28940ca10
@@ -992,11 +992,17 @@ static int show_session(int argc, char *argv[], void *userdata) {
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
if (properties)
|
||||
return show_properties(bus, "/org/freedesktop/login1");
|
||||
|
||||
return print_session_status_info(bus, "/org/freedesktop/login1/session/auto");
|
||||
r = get_bus_path_by_id(bus, "session", "GetSession", "auto", &path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return print_session_status_info(bus, path);
|
||||
}
|
||||
|
||||
for (int i = 1, first = true; i < argc; i++, first = false) {
|
||||
@@ -1083,11 +1089,17 @@ static int show_seat(int argc, char *argv[], void *userdata) {
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
if (properties)
|
||||
return show_properties(bus, "/org/freedesktop/login1");
|
||||
|
||||
return print_seat_status_info(bus, "/org/freedesktop/login1/seat/auto");
|
||||
r = get_bus_path_by_id(bus, "seat", "GetSeat", "auto", &path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return print_seat_status_info(bus, path);
|
||||
}
|
||||
|
||||
for (int i = 1, first = true; i < argc; i++, first = false) {
|
||||
|
||||
Reference in New Issue
Block a user