loginctl.c revision 841aa8c0b484b96654b95d3c4e936e37da4c7dda
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick This file is part of systemd.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick Copyright 2010 Lennart Poettering
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick systemd is free software; you can redistribute it and/or modify it
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick under the terms of the GNU Lesser General Public License as published by
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick the Free Software Foundation; either version 2.1 of the License, or
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick (at your option) any later version.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick systemd is distributed in the hope that it will be useful, but
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick WITHOUT ANY WARRANTY; without even the implied warranty of
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick Lesser General Public License for more details.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick You should have received a copy of the GNU Lesser General Public License
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick along with systemd; If not, see <http://www.gnu.org/licenses/>.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic bool arg_all = false;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic bool arg_full = false;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic bool arg_no_pager = false;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic bool arg_legend = true;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic bool arg_ask_password = true;
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic 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;
int r, output_flags;
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, 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;
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.seat) {
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) {
UserStatusInfo i = {};
goto finish;
if (*new_line)
*new_line = true;
if (i.name)
if (s1)
else if (s2)
if (i.slice) {
SeatStatusInfo i = {};
goto finish;
if (*new_line)
*new_line = true;
c = columns();
if (*new_line)
*new_line = true;
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",
return bus_log_parse_error(r);
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",
static int help(void) {
return help();
case ARG_VERSION:
return log_oom();
arg_all = true;
arg_all = true;
arg_full = true;
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;
const char* verb;
MORE,
LESS,
} argc_cmp;
const int argc;
} verbs[] = {
int left;
if (left <= 0)
help();
return -EINVAL;
case EQUAL:
return -EINVAL;
case MORE:
return -EINVAL;
case LESS:
return -EINVAL;
log_open();
goto finish;
goto finish;
pager_close();