+# SPDX-License-Identifier: LGPL-2.1+
+#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
+# SPDX-License-Identifier: LGPL-2.1+
+#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
+# SPDX-License-Identifier: LGPL-2.1+
+#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
+# SPDX-License-Identifier: LGPL-2.1+
+#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
return -EINVAL;
}
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if ( IN_SET(a, ACTION_POWEROFF, ACTION_REBOOT) )
(void) elogind_set_wall_message(bus, table[a]);
return 0;
}
-/* Original:
- * systemctl/systemctl.c:270:polkit_agent_open_if_enabled()
- */
-void polkit_agent_open_if_enabled(void) {
-
- /* Open the polkit agent as a child process if necessary */
-
- if (!arg_ask_password)
- return;
-
- if (arg_transport != BUS_TRANSPORT_LOCAL)
- return;
-
- polkit_agent_open();
-}
-
/* Original:
* systemctl/systemctl.c:3482:start_special()
* However, this elogind variant is very different from the original.
int elogind_cancel_shutdown(sd_bus *bus);
void elogind_cleanup(void);
-void polkit_agent_open_if_enabled(void);
int start_special(int argc, char *argv[], void *userdata);
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
#include "pager.h"
#include "parse-util.h"
#include "process-util.h"
+#include "sigbus.h"
#include "signal-util.h"
-//#include "spawn-polkit-agent.h"
+#include "spawn-polkit-agent.h"
#include "strv.h"
#include "sysfs-show.h"
#include "terminal-util.h"
extern elogind_action arg_action;
#endif // 0
-#if 0 /// UNNEEDED by elogind
-static void polkit_agent_open_if_enabled(void) {
-
- /* Open the polkit agent as a child process if necessary */
-
- if (!arg_ask_password)
- return;
-
- if (arg_transport != BUS_TRANSPORT_LOCAL)
- return;
-
- polkit_agent_open();
-}
-
static OutputFlags get_output_flags(void) {
return
arg_all * OUTPUT_SHOW_ALL |
- arg_full * OUTPUT_FULL_WIDTH |
- (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
+ (arg_full || !on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
colors_enabled() * OUTPUT_COLOR;
}
-#endif // 0
static int get_session_path(sd_bus *bus, const char *session_id, sd_bus_error *error, char **path) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
printf("\t Devices:\n");
- show_sysfs(i.id, "\t\t ", c);
+ show_sysfs(i.id, "\t\t ", c, get_output_flags());
}
return 0;
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (argc < 2) {
/* No argument? Let's either use $XDG_SESSION_ID (if specified), or an empty
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (!arg_kill_who)
arg_kill_who = "all";
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
b = streq(argv[0], "enable-linger");
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (i = 1; i < argc; i++) {
uid_t uid;
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (!arg_kill_who)
arg_kill_who = "all";
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (i = 2; i < argc; i++) {
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call_method(
bus,
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call_method(
bus,
assert(bus);
assert(argv);
- polkit_agent_open_if_enabled();
+ polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (i = 1; i < argc; i++) {
}
int main(int argc, char *argv[]) {
- sd_bus *bus = NULL;
+ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
setlocale(LC_ALL, "");
elogind_set_program_name(argv[0]);
log_parse_environment();
log_open();
+ sigbus_install();
r = parse_argv(argc, argv);
if (r <= 0)
r = loginctl_main(argc, argv, bus);
finish:
- sd_bus_flush_close_unref(bus);
-
pager_close();
#if 0 /// elogind does that in elogind_cleanup()
polkit_agent_close();
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
/// Additional includes needed by elogind
#include "elogind-dbus.h"
+static int get_sender_session(Manager *m, sd_bus_message *message, sd_bus_error *error, Session **ret) {
-int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
+ const char *name;
Session *session;
int r;
+ /* Get client login session. This is not what you are looking for these days,
+ * as apps may instead belong to a user service unit. This includes terminal
+ * emulators and hence command-line apps. */
+ r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_creds_get_session(creds, &name);
+ if (r == -ENXIO)
+ goto err_no_session;
+ if (r < 0)
+ return r;
+
+ session = hashmap_get(m->sessions, name);
+ if (!session)
+ goto err_no_session;
+
+ *ret = session;
+ return 0;
+
+err_no_session:
+ return sd_bus_error_setf(error, BUS_ERROR_NO_SESSION_FOR_PID,
+ "Caller does not belong to any known session");
+}
+
+int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
+ Session *session;
+
assert(m);
assert(message);
assert(ret);
- if (isempty(name)) {
- r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds);
- if (r < 0)
- return r;
-
- r = sd_bus_creds_get_session(creds, &name);
- if (r == -ENXIO)
- return sd_bus_error_setf(error, BUS_ERROR_NO_SESSION_FOR_PID,
- "Caller does not belong to any known session");
- if (r < 0)
- return r;
- }
+ if (isempty(name))
+ return get_sender_session(m, message, error, ret);
session = hashmap_get(m->sessions, name);
if (!session)
return 0;
}
-int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret) {
+static int get_sender_user(Manager *m, sd_bus_message *message, sd_bus_error *error, User **ret) {
+
+ _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
+ uid_t uid;
User *user;
int r;
+ /* Note that we get the owner UID of the session, not the actual client UID here! */
+ r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_OWNER_UID|SD_BUS_CREDS_AUGMENT, &creds);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_creds_get_owner_uid(creds, &uid);
+ if (r == -ENXIO)
+ goto err_no_user;
+ if (r < 0)
+ return r;
+
+ user = hashmap_get(m->users, UID_TO_PTR(uid));
+ if (!user)
+ goto err_no_user;
+
+ *ret = user;
+ return 0;
+
+err_no_user:
+ return sd_bus_error_setf(error, BUS_ERROR_NO_USER_FOR_PID, "Caller does not belong to any logged in user or lingering user");
+}
+
+int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret) {
+ User *user;
+
assert(m);
assert(message);
assert(ret);
- if (!uid_is_valid(uid)) {
- _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
-
- /* Note that we get the owner UID of the session, not the actual client UID here! */
- r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_OWNER_UID|SD_BUS_CREDS_AUGMENT, &creds);
- if (r < 0)
- return r;
-
- r = sd_bus_creds_get_owner_uid(creds, &uid);
- if (r < 0)
- return r;
- }
+ if (!uid_is_valid(uid))
+ return get_sender_user(m, message, error, ret);
user = hashmap_get(m->users, UID_TO_PTR(uid));
if (!user)
- return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user "UID_FMT" known or logged in", uid);
+ return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "User ID "UID_FMT" is not logged in or lingering", uid);
*ret = user;
return 0;
return sd_bus_reply_method_return(message, "o", p);
}
+/* Get login session of a process. This is not what you are looking for these days,
+ * as apps may instead belong to a user service unit. This includes terminal
+ * emulators and hence command-line apps. */
static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Session *session = NULL;
if (r < 0)
return r;
if (!user)
- return sd_bus_error_setf(error, BUS_ERROR_NO_USER_FOR_PID, "PID "PID_FMT" does not belong to any known or logged in user", pid);
+ return sd_bus_error_setf(error, BUS_ERROR_NO_USER_FOR_PID,
+ "PID "PID_FMT" does not belong to any logged in user or lingering user",
+ pid);
}
p = user_bus_path(user);
mkdir_p_label("/var/lib/systemd", 0755);
- r = mkdir_safe_label("/var/lib/systemd/linger", 0755, 0, 0);
+ r = mkdir_safe_label("/var/lib/elogind/linger", 0755, 0, 0, false);
if (r < 0)
return r;
assert(m);
- r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/shutdown", 0755, 0, 0, false);
if (r < 0)
return log_error_errno(r, "Failed to create shutdown subdirectory: %m");
r = efi_get_reboot_to_firmware();
if (r < 0 && r != -EOPNOTSUPP)
- return r;
+ log_warning_errno(r, "Failed to determine reboot-to-firmware state: %m");
return sd_bus_message_append(reply, "b", r > 0);
#else
assert(m);
r = efi_reboot_to_firmware_supported();
- if (r == -EOPNOTSUPP)
+ if (r < 0) {
+ if (r != -EOPNOTSUPP)
+ log_warning_errno(errno, "Failed to determine whether reboot to firmware is supported: %m");
+
return sd_bus_reply_method_return(message, "s", "na");
- else if (r < 0)
- return r;
+ }
r = bus_test_polkit(message,
CAP_SYS_ADMIN,
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
assert(i);
- r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/inhibit", 0755, 0, 0, false);
if (r < 0)
goto fail;
/* Create FIFO */
if (!i->fifo_path) {
- r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/inhibit", 0755, 0, 0, false);
if (r < 0)
return r;
Session *s;
int r;
+ /* Get client session. This is not what you are looking for these days.
+ * FIXME #6852 */
r = manager_get_session_by_pid(m, pid, &s);
if (r < 0)
return r;
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
#include <errno.h>
#include <fcntl.h>
+#include <stdio_ext.h>
#include <string.h>
#include <unistd.h>
if (!s->started)
return 0;
- r = mkdir_safe_label("/run/systemd/seats", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/seats", 0755, 0, 0, false);
if (r < 0)
goto fail;
if (r < 0)
goto fail;
- fchmod(fileno(f), 0644);
+ (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
+ (void) fchmod(fileno(f), 0644);
fprintf(f,
"# This is private data. Do not parse.\n"
if (s->sessions) {
Session *i;
- fputs_unlocked("SESSIONS=", f);
+ fputs("SESSIONS=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions) {
fprintf(f,
"%s%c",
i->sessions_by_seat_next ? ' ' : '\n');
}
- fputs_unlocked("UIDS=", f);
+ fputs("UIDS=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions)
fprintf(f,
UID_FMT"%c",
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
if (!s->started)
return 0;
- r = mkdir_safe_label("/run/systemd/sessions", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/sessions", 0755, 0, 0, false);
if (r < 0)
goto fail;
/* Create FIFO */
if (!s->fifo_path) {
- r = mkdir_safe_label("/run/systemd/sessions", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/sessions", 0755, 0, 0, false);
if (r < 0)
return r;
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
#include <string.h>
#include <sys/mount.h>
#include <unistd.h>
+#include <stdio_ext.h>
#include "alloc-util.h"
#include "bus-common-errors.h"
assert(u);
assert(u->state_file);
- r = mkdir_safe_label("/run/systemd/users", 0755, 0, 0);
+ r = mkdir_safe_label("/run/elogind/users", 0755, 0, 0, false);
if (r < 0)
goto fail;
if (r < 0)
goto fail;
- fchmod(fileno(f), 0644);
+ (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
+ (void) fchmod(fileno(f), 0644);
fprintf(f,
"# This is private data. Do not parse.\n"
Session *i;
bool first;
- fputs_unlocked("SESSIONS=", f);
+ fputs("SESSIONS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->id, f);
+ fputs(i->id, f);
}
- fputs_unlocked("\nSEATS=", f);
+ fputs("\nSEATS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (!i->seat)
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->seat->id, f);
+ fputs(i->seat->id, f);
}
- fputs_unlocked("\nACTIVE_SESSIONS=", f);
+ fputs("\nACTIVE_SESSIONS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (!session_is_active(i))
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->id, f);
+ fputs(i->id, f);
}
- fputs_unlocked("\nONLINE_SESSIONS=", f);
+ fputs("\nONLINE_SESSIONS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (session_get_state(i) == SESSION_CLOSING)
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->id, f);
+ fputs(i->id, f);
}
- fputs_unlocked("\nACTIVE_SEATS=", f);
+ fputs("\nACTIVE_SEATS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (!session_is_active(i) || !i->seat)
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->seat->id, f);
+ fputs(i->seat->id, f);
}
- fputs_unlocked("\nONLINE_SEATS=", f);
+ fputs("\nONLINE_SEATS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
if (session_get_state(i) == SESSION_CLOSING || !i->seat)
if (first)
first = false;
else
- fputc_unlocked(' ', f);
+ fputc(' ', f);
- fputs_unlocked(i->seat->id, f);
+ fputs(i->seat->id, f);
}
- fputc_unlocked('\n', f);
+ fputc('\n', f);
}
r = fflush_and_check(f);
assert(u);
- r = mkdir_safe_label("/run/user", 0755, 0, 0);
+ r = mkdir_safe_label("/run/user", 0755, 0, 0, false);
if (r < 0)
return log_error_errno(r, "Failed to create /run/user: %m");
u->service,
&error,
&job);
- if (r < 0) {
+ if (r < 0)
/* we don't fail due to this, let's try to continue */
log_error_errno(r, "Failed to start user service, ignoring: %s", bus_error_message(&error, r));
- } else {
+ else
u->service_job = job;
- }
#else
assert(u);
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
CONF_PATHS_NULSTR("systemd/logind.conf.d"),
"Login\0",
config_item_perf_lookup, logind_gperf_lookup,
- false, m);
#else
const char* logind_conf = getenv("ELOGIND_CONF_FILE");
return config_parse(NULL, logind_conf, NULL, "Login\0Sleep\0",
config_item_perf_lookup, logind_gperf_lookup,
- false, false, true, m);
#endif // 0
+ CONFIG_PARSE_WARN, m);
}
static int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
<!--
This file is part of elogind.
+ SPDX-License-Identifier: LGPL-2.1+
elogind is free software; you can redistribute it and/or modify it
+
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
<!--
This file is part of elogind.
+ SPDX-License-Identifier: LGPL-2.1+
elogind is free software; you can redistribute it and/or modify it
+
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
<!-- // 0 -->
<action id="org.freedesktop.login1.inhibit-block-shutdown">
- <_description>Allow applications to inhibit system shutdown</_description>
- <_message>Authentication is required for an application to inhibit system shutdown.</_message>
+ <description>Allow applications to inhibit system shutdown</description>
+ <message>Authentication is required for an application to inhibit system shutdown.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-delay-shutdown">
- <_description>Allow applications to delay system shutdown</_description>
- <_message>Authentication is required for an application to delay system shutdown.</_message>
+ <description>Allow applications to delay system shutdown</description>
+ <message>Authentication is required for an application to delay system shutdown.</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-block-sleep">
- <_description>Allow applications to inhibit system sleep</_description>
- <_message>Authentication is required for an application to inhibit system sleep.</_message>
+ <description>Allow applications to inhibit system sleep</description>
+ <message>Authentication is required for an application to inhibit system sleep.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-delay-sleep">
- <_description>Allow applications to delay system sleep</_description>
- <_message>Authentication is required for an application to delay system sleep.</_message>
+ <description>Allow applications to delay system sleep</description>
+ <message>Authentication is required for an application to delay system sleep.</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-block-idle">
- <_description>Allow applications to inhibit automatic system suspend</_description>
- <_message>Authentication is required for an application to inhibit automatic system suspend.</_message>
+ <description>Allow applications to inhibit automatic system suspend</description>
+ <message>Authentication is required for an application to inhibit automatic system suspend.</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-handle-power-key">
- <_description>Allow applications to inhibit system handling of the power key</_description>
- <_message>Authentication is required for an application to inhibit system handling of the power key.</_message>
+ <description>Allow applications to inhibit system handling of the power key</description>
+ <message>Authentication is required for an application to inhibit system handling of the power key.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-handle-suspend-key">
- <_description>Allow applications to inhibit system handling of the suspend key</_description>
- <_message>Authentication is required for an application to inhibit system handling of the suspend key.</_message>
+ <description>Allow applications to inhibit system handling of the suspend key</description>
+ <message>Authentication is required for an application to inhibit system handling of the suspend key.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-handle-hibernate-key">
- <_description>Allow applications to inhibit system handling of the hibernate key</_description>
- <_message>Authentication is required for an application to inhibit system handling of the hibernate key.</_message>
+ <description>Allow applications to inhibit system handling of the hibernate key</description>
+ <message>Authentication is required for an application to inhibit system handling of the hibernate key.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.inhibit-handle-lid-switch">
- <_description>Allow applications to inhibit system handling of the lid switch</_description>
- <_message>Authentication is required for an application to inhibit system handling of the lid switch.</_message>
+ <description>Allow applications to inhibit system handling of the lid switch</description>
+ <message>Authentication is required for an application to inhibit system handling of the lid switch.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.set-self-linger">
- <_description>Allow non-logged-in user to run programs</_description>
- <_message>Explicit request is required to run programs as a non-logged-in user.</_message>
+ <description>Allow non-logged-in user to run programs</description>
+ <message>Explicit request is required to run programs as a non-logged-in user.</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
</action>
<action id="org.freedesktop.login1.set-user-linger">
- <_description>Allow non-logged-in users to run programs</_description>
- <_message>Authentication is required to run programs as a non-logged-in user.</_message>
+ <description>Allow non-logged-in users to run programs</description>
+ <message>Authentication is required to run programs as a non-logged-in user.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.attach-device">
- <_description>Allow attaching devices to seats</_description>
- <_message>Authentication is required for attaching a device to a seat.</_message>
+ <description>Allow attaching devices to seats</description>
+ <message>Authentication is required for attaching a device to a seat.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.flush-devices">
- <_description>Flush device to seat attachments</_description>
- <_message>Authentication is required for resetting how devices are attached to seats.</_message>
+ <description>Flush device to seat attachments</description>
+ <message>Authentication is required for resetting how devices are attached to seats.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.power-off">
- <_description>Power off the system</_description>
- <_message>Authentication is required for powering off the system.</_message>
+ <description>Power off the system</description>
+ <message>Authentication is required for powering off the system.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.power-off-multiple-sessions">
- <_description>Power off the system while other users are logged in</_description>
- <_message>Authentication is required for powering off the system while other users are logged in.</_message>
+ <description>Power off the system while other users are logged in</description>
+ <message>Authentication is required for powering off the system while other users are logged in.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.power-off-ignore-inhibit">
- <_description>Power off the system while an application asked to inhibit it</_description>
- <_message>Authentication is required for powering off the system while an application asked to inhibit it.</_message>
+ <description>Power off the system while an application asked to inhibit it</description>
+ <message>Authentication is required for powering off the system while an application asked to inhibit it.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.reboot">
- <_description>Reboot the system</_description>
- <_message>Authentication is required for rebooting the system.</_message>
+ <description>Reboot the system</description>
+ <message>Authentication is required for rebooting the system.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.reboot-multiple-sessions">
- <_description>Reboot the system while other users are logged in</_description>
- <_message>Authentication is required for rebooting the system while other users are logged in.</_message>
+ <description>Reboot the system while other users are logged in</description>
+ <message>Authentication is required for rebooting the system while other users are logged in.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.reboot-ignore-inhibit">
- <_description>Reboot the system while an application asked to inhibit it</_description>
- <_message>Authentication is required for rebooting the system while an application asked to inhibit it.</_message>
+ <description>Reboot the system while an application asked to inhibit it</description>
+ <message>Authentication is required for rebooting the system while an application asked to inhibit it.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.halt">
- <_description>Halt the system</_description>
- <_message>Authentication is required for halting the system.</_message>
+ <description>Halt the system</description>
+ <message>Authentication is required for halting the system.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.halt-multiple-sessions">
- <_description>Halt the system while other users are logged in</_description>
- <_message>Authentication is required for halting the system while other users are logged in.</_message>
+ <description>Halt the system while other users are logged in</description>
+ <message>Authentication is required for halting the system while other users are logged in.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.halt-ignore-inhibit">
- <_description>Halt the system while an application asked to inhibit it</_description>
- <_message>Authentication is required for halting the system while an application asked to inhibit it.</_message>
+ <description>Halt the system while an application asked to inhibit it</description>
+ <message>Authentication is required for halting the system while an application asked to inhibit it.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.suspend">
- <_description>Suspend the system</_description>
- <_message>Authentication is required for suspending the system.</_message>
+ <description>Suspend the system</description>
+ <message>Authentication is required for suspending the system.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.suspend-multiple-sessions">
- <_description>Suspend the system while other users are logged in</_description>
- <_message>Authentication is required for suspending the system while other users are logged in.</_message>
+ <description>Suspend the system while other users are logged in</description>
+ <message>Authentication is required for suspending the system while other users are logged in.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.suspend-ignore-inhibit">
- <_description>Suspend the system while an application asked to inhibit it</_description>
- <_message>Authentication is required for suspending the system while an application asked to inhibit it.</_message>
+ <description>Suspend the system while an application asked to inhibit it</description>
+ <message>Authentication is required for suspending the system while an application asked to inhibit it.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.hibernate">
- <_description>Hibernate the system</_description>
- <_message>Authentication is required for hibernating the system.</_message>
+ <description>Hibernate the system</description>
+ <message>Authentication is required for hibernating the system.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.hibernate-multiple-sessions">
- <_description>Hibernate the system while other users are logged in</_description>
- <_message>Authentication is required for hibernating the system while other users are logged in.</_message>
+ <description>Hibernate the system while other users are logged in</description>
+ <message>Authentication is required for hibernating the system while other users are logged in.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.hibernate-ignore-inhibit">
- <_description>Hibernate the system while an application asked to inhibit it</_description>
- <_message>Authentication is required for hibernating the system while an application asked to inhibit it.</_message>
+ <description>Hibernate the system while an application asked to inhibit it</description>
+ <message>Authentication is required for hibernating the system while an application asked to inhibit it.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.manage">
- <_description>Manage active sessions, users and seats</_description>
- <_message>Authentication is required for managing active sessions, users and seats.</_message>
+ <description>Manage active sessions, users and seats</description>
+ <message>Authentication is required for managing active sessions, users and seats.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.lock-sessions">
- <_description>Lock or unlock active sessions</_description>
- <_message>Authentication is required to lock or unlock active sessions.</_message>
+ <description>Lock or unlock active sessions</description>
+ <message>Authentication is required to lock or unlock active sessions.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.set-reboot-to-firmware-setup">
- <_description>Allow indication to the firmware to boot to setup interface</_description>
- <_message>Authentication is required to indicate to the firmware to boot to setup interface.</_message>
+ <description>Allow indication to the firmware to boot to setup interface</description>
+ <message>Authentication is required to indicate to the firmware to boot to setup interface.</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
</action>
<action id="org.freedesktop.login1.set-wall-message">
- <_description>Set a wall message</_description>
- <_message>Authentication is required to set a wall message</_message>
+ <description>Set a wall message</description>
+ <message>Authentication is required to set a wall message</message>
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive>
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
/***
+ SPDX-License-Identifier: LGPL-2.1+
+
This file is part of systemd.
systemd is free software; you can redistribute it and/or modify it
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
struct udev_list_entry **item,
const char *sub,
const char *prefix,
- unsigned n_columns) {
+ unsigned n_columns,
+ OutputFlags flags) {
+
+ size_t max_width;
assert(udev);
assert(seat);
assert(item);
assert(prefix);
+ if (flags & OUTPUT_FULL_WIDTH)
+ max_width = (size_t) -1;
+ else if (n_columns < 10)
+ max_width = 10;
+ else
+ max_width = n_columns;
+
while (*item) {
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
struct udev_list_entry *next, *lookahead;
lookahead = udev_list_entry_get_next(lookahead);
}
- k = ellipsize(sysfs, n_columns, 20);
+ k = ellipsize(sysfs, max_width, 20);
if (!k)
return -ENOMEM;
return -ENOMEM;
free(k);
- k = ellipsize(l, n_columns, 70);
+ k = ellipsize(l, max_width, 70);
if (!k)
return -ENOMEM;
if (!p)
return -ENOMEM;
- show_sysfs_one(udev, seat, item, sysfs, p, n_columns - 2);
+ show_sysfs_one(udev, seat, item, sysfs, p,
+ n_columns == (unsigned) -1 || n_columns < 2 ? n_columns : n_columns - 2,
+ flags);
}
}
return 0;
}
-int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) {
+int show_sysfs(const char *seat, const char *prefix, unsigned n_columns, OutputFlags flags) {
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
_cleanup_udev_unref_ struct udev *udev = NULL;
struct udev_list_entry *first = NULL;
if (n_columns <= 0)
n_columns = columns();
- if (!prefix)
- prefix = "";
+ prefix = strempty(prefix);
if (isempty(seat))
seat = "seat0";
first = udev_enumerate_get_list_entry(e);
if (first)
- show_sysfs_one(udev, seat, &first, "/", prefix, n_columns);
+ show_sysfs_one(udev, seat, &first, "/", prefix, n_columns, flags);
else
printf("%s%s%s\n", prefix, special_glyph(TREE_RIGHT), "(none)");
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-int show_sysfs(const char *seat, const char *prefix, unsigned columns);
+#include <sys/types.h>
+
+#include "output-mode.h"
+
+int show_sysfs(const char *seat, const char *prefix, unsigned columns, OutputFlags flags);
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd