mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 09:56:51 +03:00
loginctl: also use $XDG_SESSION_ID for session-status
This commit is contained in:
parent
bdb07fa5ac
commit
9cf8e2087b
@ -907,6 +907,8 @@ static int show_session(int argc, char *argv[], void *userdata) {
|
||||
bool properties, new_line = false;
|
||||
sd_bus *bus = userdata;
|
||||
int r, i;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *path = NULL;
|
||||
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
@ -916,19 +918,27 @@ static int show_session(int argc, char *argv[], void *userdata) {
|
||||
pager_open(arg_no_pager, false);
|
||||
|
||||
if (argc <= 1) {
|
||||
/* If not argument is specified inspect the manager
|
||||
* itself */
|
||||
const char *session, *p = "/org/freedesktop/login1/session/self";
|
||||
|
||||
if (properties)
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
return show_properties(bus, "/org/freedesktop/login1", &new_line);
|
||||
|
||||
/* And in the pretty case, show data of the calling session */
|
||||
return print_session_status_info(bus, "/org/freedesktop/login1/session/self", &new_line);
|
||||
session = getenv("XDG_SESSION_ID");
|
||||
if (session) {
|
||||
r = get_session_path(bus, session, &error, &path);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get session path: %s", bus_error_message(&error, r));
|
||||
return r;
|
||||
}
|
||||
p = path;
|
||||
}
|
||||
|
||||
return print_session_status_info(bus, p, &new_line);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *path = NULL;
|
||||
|
||||
r = get_session_path(bus, argv[i], &error, &path);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get session path: %s", bus_error_message(&error, r));
|
||||
|
Loading…
Reference in New Issue
Block a user