loginctl.c revision 0b452006de98294d1690f045f6ea2f7f6630ec3b
f0528cfc93da36692a5fb7898d7e4a9e95150318nd/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
f0528cfc93da36692a5fb7898d7e4a9e95150318nd This file is part of systemd.
f0528cfc93da36692a5fb7898d7e4a9e95150318nd Copyright 2010 Lennart Poettering
f0528cfc93da36692a5fb7898d7e4a9e95150318nd systemd is free software; you can redistribute it and/or modify it
f0528cfc93da36692a5fb7898d7e4a9e95150318nd under the terms of the GNU Lesser General Public License as published by
f0528cfc93da36692a5fb7898d7e4a9e95150318nd the Free Software Foundation; either version 2.1 of the License, or
f0528cfc93da36692a5fb7898d7e4a9e95150318nd (at your option) any later version.
f0528cfc93da36692a5fb7898d7e4a9e95150318nd systemd is distributed in the hope that it will be useful, but
f0528cfc93da36692a5fb7898d7e4a9e95150318nd WITHOUT ANY WARRANTY; without even the implied warranty of
f0528cfc93da36692a5fb7898d7e4a9e95150318nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f0528cfc93da36692a5fb7898d7e4a9e95150318nd Lesser General Public License for more details.
f0528cfc93da36692a5fb7898d7e4a9e95150318nd You should have received a copy of the GNU Lesser General Public License
f0528cfc93da36692a5fb7898d7e4a9e95150318nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
f0528cfc93da36692a5fb7898d7e4a9e95150318ndstatic bool arg_all = false;
f0528cfc93da36692a5fb7898d7e4a9e95150318ndstatic bool arg_full = false;
f0528cfc93da36692a5fb7898d7e4a9e95150318ndstatic bool arg_no_pager = false;
static bool arg_legend = true;
static bool arg_ask_password = true;
static void pager_open_if_enabled(void) {
if (arg_no_pager)
pager_open(false);
static void polkit_agent_open_if_enabled(void) {
if (!arg_ask_password)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (arg_legend)
return bus_log_parse_error(r);
if (arg_legend)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (arg_legend)
return bus_log_parse_error(r);
if (arg_legend)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (arg_legend)
return bus_log_parse_error(r);
if (arg_legend)
const char *cgroup;
if (!path)
return -ENOMEM;
r = sd_bus_get_property(
bus,
"org.freedesktop.systemd1",
path,
c = columns();
show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, cgroup, "\t\t ", c, false, &leader, leader > 0, get_output_flags());
typedef struct SessionStatusInfo {
const char *id;
const char *name;
unsigned int vtnr;
const char *seat;
const char *tty;
const char *display;
bool remote;
const char *remote_host;
const char *remote_user;
const char *service;
const char *type;
const char *class;
const char *state;
const char *scope;
const char *desktop;
typedef struct UserStatusInfo {
const char *name;
const char *state;
char **sessions;
const char *display;
const char *slice;
typedef struct SeatStatusInfo {
const char *id;
const char *active_session;
char **sessions;
static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
const char *contents;
char **p = (char **) userdata;
free(*p);
*p = strdup(s);
return -ENOMEM;
r = sd_bus_message_exit_container(m);
static int prop_map_sessions_strv(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
const char *name;
assert(m);
return sd_bus_message_exit_container(m);
SessionStatusInfo i = {};
if (*new_line)
*new_line = true;
if (i.name)
if (s1)
else if (s2)
if (i.leader > 0) {
if (i.vtnr > 0)
if (i.tty)
else if (i.display)
else if (i.remote_host)
else if (i.remote_user)
else if (i.remote)
if (i.service) {
if (i.type)
if (i.class)
} else if (i.type) {
if (i.class)
} else if (i.class)
if (i.state)
if (i.scope) {
i.scope,
NULL);
UserStatusInfo i = {};
goto finish;
if (*new_line)
*new_line = true;
if (i.name)
if (s1)
else if (s2)
if (i.slice) {
i.slice,
NULL);
SeatStatusInfo i = {};
goto finish;
if (*new_line)
*new_line = true;
c = columns();
if (*new_line)
*new_line = true;
if (properties)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (properties)
if (properties)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (properties)
if (properties)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
return bus_log_parse_error(r);
if (properties)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
if (!arg_kill_who)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
if (!arg_kill_who)
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
NULL);
r = sd_bus_call_method(
bus,
"/org/freedesktop/login1",
case ARG_VERSION:
return log_oom();
arg_all = true;
arg_all = true;
arg_full = true;
return -EINVAL;
if (arg_output < 0) {
return -EINVAL;
case ARG_NO_PAGER:
arg_no_pager = true;
case ARG_NO_LEGEND:
arg_legend = false;
case ARG_NO_ASK_PASSWORD:
arg_ask_password = false;
case ARG_KILL_WHO:
if (arg_signal < 0) {
return -EINVAL;
return -EINVAL;
log_open();
goto finish;
goto finish;
pager_close();