chiark / gitweb /
Prep v236 : Add missing SPDX-License-Identifier (5/9) src/login
authorSven Eden <yamakuzure@gmx.net>
Tue, 13 Mar 2018 18:14:05 +0000 (19:14 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 26 Mar 2018 16:25:59 +0000 (18:25 +0200)
43 files changed:
src/login/70-power-switch.rules
src/login/70-uaccess.rules
src/login/71-seat.rules.in
src/login/73-seat-late.rules.in
src/login/eloginctl.c
src/login/eloginctl.h
src/login/inhibit.c
src/login/loginctl.c
src/login/logind-acl.c
src/login/logind-acl.h
src/login/logind-action.c
src/login/logind-action.h
src/login/logind-button.c
src/login/logind-button.h
src/login/logind-core.c
src/login/logind-dbus.c
src/login/logind-device.c
src/login/logind-device.h
src/login/logind-inhibit.c
src/login/logind-inhibit.h
src/login/logind-seat-dbus.c
src/login/logind-seat.c
src/login/logind-seat.h
src/login/logind-session-dbus.c
src/login/logind-session-device.c
src/login/logind-session-device.h
src/login/logind-session.c
src/login/logind-session.h
src/login/logind-user-dbus.c
src/login/logind-user.c
src/login/logind-user.h
src/login/logind-utmp.c
src/login/logind.c
src/login/logind.h
src/login/org.freedesktop.login1.conf
src/login/org.freedesktop.login1.policy.in
src/login/pam_elogind.c
src/login/pam_elogind.sym
src/login/sysfs-show.c
src/login/sysfs-show.h
src/login/test-inhibit.c
src/login/test-login-shared.c
src/login/test-login-tables.c

index 394a80f1f8ffce7050093b0233d4945d5fb60f30..d69e65b3d52154d4b2280c9e436c295f94066698 100644 (file)
@@ -1,3 +1,5 @@
+#  SPDX-License-Identifier: LGPL-2.1+
+#
 #  This file is part of systemd.
 #
 #  systemd is free software; you can redistribute it and/or modify it
index e946bf2380be4c2bbd30658e6ae5a5b87e14a6fa..f2c838f3535d56b45e3a7ba5a388cbe3383490f1 100644 (file)
@@ -1,3 +1,5 @@
+#  SPDX-License-Identifier: LGPL-2.1+
+#
 #  This file is part of systemd.
 #
 #  systemd is free software; you can redistribute it and/or modify it
index de55c9a4ec2a2056f3fb3efdb43f2197171214fe..0db46adc84a04698ea718cd4f89692508692c569 100644 (file)
@@ -1,3 +1,5 @@
+#  SPDX-License-Identifier: LGPL-2.1+
+#
 #  This file is part of systemd.
 #
 #  systemd is free software; you can redistribute it and/or modify it
index a44976b6d07192fdc7a8ed67db13b0e194ee17bc..e758819609344e6bb66714236f97510ebfc85384 100644 (file)
@@ -1,3 +1,5 @@
+#  SPDX-License-Identifier: LGPL-2.1+
+#
 #  This file is part of systemd.
 #
 #  systemd is free software; you can redistribute it and/or modify it
index 8adfb62e9574c7561bdf1fce7700719113675bca..566c339c6e01a258a52e3ec71814305e0fe5cf41 100644 (file)
@@ -313,7 +313,7 @@ static int elogind_reboot(sd_bus *bus, enum elogind_action a) {
                 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]);
@@ -476,22 +476,6 @@ static int parse_shutdown_time_spec(const char *t, usec_t *_u) {
         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.
index b6e96930bba8e9a9106b3f683afc43903153863f..cf8ce83340bb47406f0d2b575136a500b3d74634 100644 (file)
@@ -41,7 +41,6 @@ typedef enum elogind_action {
 
 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);
 
 
index 896fd570a5b6eabd8b6e58e20b6efca009a4c8cb..7c48e7cee148b351699181b11470c0bf9edd8286 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 7343fecaab6a334ac7c524bc69c5041773dab959..11bd99069859a2364373838d179bade540b96b17 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -37,8 +38,9 @@
 #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"
@@ -75,29 +77,13 @@ extern bool arg_ignore_inhibitors;
 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;
@@ -749,7 +735,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
 
                 printf("\t Devices:\n");
 
-                show_sysfs(i.id, "\t\t  ", c);
+                show_sysfs(i.id, "\t\t  ", c, get_output_flags());
         }
 
         return 0;
@@ -1103,7 +1089,7 @@ static int activate(int argc, char *argv[], void *userdata) {
         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
@@ -1147,7 +1133,7 @@ static int kill_session(int argc, char *argv[], void *userdata) {
         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";
@@ -1181,7 +1167,7 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
         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");
 
@@ -1232,7 +1218,7 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
         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;
@@ -1266,7 +1252,7 @@ static int kill_user(int argc, char *argv[], void *userdata) {
         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";
@@ -1303,7 +1289,7 @@ static int attach(int argc, char *argv[], void *userdata) {
         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++) {
 
@@ -1333,7 +1319,7 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
         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,
@@ -1357,7 +1343,7 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
         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,
@@ -1381,7 +1367,7 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
         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++) {
 
@@ -1688,13 +1674,14 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) {
 }
 
 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)
@@ -1711,8 +1698,6 @@ int main(int argc, char *argv[]) {
         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();
index 1b69f4b9ca77b449f1abeac11c2f9c7c8e757058..d785f67ca31021e0aaf12088b5ec710a938d45e9 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index df25beca2fb87515b94e836d5fca806fa97c71fb..d50b887bc2151e7691e90fa33621248f67068011 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 48d9fb856e2a83f35cd0c0c62e0dfab5af12d379..bae42db999dad0340a23a2255750fcd8975ef3cb 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index fb40ae48d2cf660a35b103fb1ba7ada15160efa7..8c31ec42becd7606168e5cb929cee0cb993cf08f 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index e53dd63c29756e79088cf83c70f9dd361ffd2bbf..94945f0bcb3dcca8383689d1ec711459e2d4f85d 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index f30cba29594d712e59de1c5ba1d70b2a743d73b4..b47eb47571621eab6ab2bbafb8ca7d119119f811 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 95e2363dd0589ae182fe44d0c1c060ea79c8cb61..71b9c76d31f723cd5664e5c27193a49ac24afb8f 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 0ac16de2d6a754e0ab6c9f261ce48860a354716f..aff699674d6f7fcf62b2bc8d0f79e9d4251a0381 100644 (file)
@@ -1,3 +1,4 @@
+/* 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)
@@ -83,30 +103,48 @@ int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const ch
         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;
@@ -332,6 +370,9 @@ static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_er
         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;
@@ -422,7 +463,9 @@ static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bu
                 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);
@@ -1186,7 +1229,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
 
         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;
 
@@ -1946,7 +1989,7 @@ static int update_schedule_file(Manager *m) {
 
         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");
 
@@ -2417,7 +2460,7 @@ static int property_get_reboot_to_firmware_setup(
 
         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
@@ -2477,10 +2520,12 @@ static int method_can_reboot_to_firmware_setup(
         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,
index 6537fa04bfcbd6685fa5132d28ca508aea81b591..758ba73c2bb38478510c5baf8c3379adaa3f2f21 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 927068e00abe9edd81b157f2f63a64996a57bea1..d0911560ddc88f9011628f378bcf6dadd95c67e6 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 1e6f3837382fe163fed58bbeda901abdda364d91..9bfde30ab801f3f260a5617958f77464ff5f6200 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -86,7 +87,7 @@ int inhibitor_save(Inhibitor *i) {
 
         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;
 
@@ -290,7 +291,7 @@ int inhibitor_create_fifo(Inhibitor *i) {
 
         /* 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;
 
@@ -357,6 +358,8 @@ static int pid_is_active(Manager *m, pid_t pid) {
         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;
index 70de199c602a7495205f3d69eed61e56b2154a83..cc6c62ab18ad129bdd5051bca5a4e80efe46d6e3 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 2154b878dd900ca5a873fd4b0f6d6e8f5400461d..8e4e4efc81bae57c0e5a5630587e2d54cb4888c8 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index eacea3c39d804b6b071136cd2d72e421a410fa4a..0301d670a6a5e130f4b786c6fa224e1e594c70fb 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -19,6 +20,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <stdio_ext.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -93,7 +95,7 @@ int seat_save(Seat *s) {
         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;
 
@@ -101,7 +103,8 @@ int seat_save(Seat *s) {
         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"
@@ -127,7 +130,7 @@ int seat_save(Seat *s) {
         if (s->sessions) {
                 Session *i;
 
-                fputs_unlocked("SESSIONS=", f);
+                fputs("SESSIONS=", f);
                 LIST_FOREACH(sessions_by_seat, i, s->sessions) {
                         fprintf(f,
                                 "%s%c",
@@ -135,7 +138,7 @@ int seat_save(Seat *s) {
                                 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",
index d7096a5e32d6426b8223d020710861b8b1fa2736..caf9708c15896a2aa4a12d30d3ce87592f45f38b 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 4e3162d8f6ff3fe5dc450d857f79f44430c2e801..b49b8b92ddb9b9ad3c7cc574b6024c6ba5dfb645 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index c48889c3e50e340b6361e098d88822332e0852ba..9d1256dca6ea9d8750f426852eae600195754af0 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 84b1e6ad23e8160ca335a8978c24c778cd175e51..a1cf17af926303f95749bfa1881e145c2316a8c1 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index e9834c9bd7beb23bda509b707261d786ec239464..6ae45f45a379db51bf8ca6e9838896e77ce18e79 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -184,7 +185,7 @@ int session_save(Session *s) {
         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;
 
@@ -1006,7 +1007,7 @@ int session_create_fifo(Session *s) {
 
         /* 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;
 
index 1e7f3ad4999ad396f8d4406664f0486bc4f5438a..d53975acc0246f265cb3d0ec0481551e3aa665ea 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 921f1e0f91181cc08ab64a0274ee508971563d3d..9fca5ce0cda1096d25a59414bae12eea5a15463d 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 3bbd9644c947fa2f07784b96c5f21c402330eb39..ab6aef5146f90535e023edfd6f516a368431af6f 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -21,6 +22,7 @@
 #include <string.h>
 #include <sys/mount.h>
 #include <unistd.h>
+#include <stdio_ext.h>
 
 #include "alloc-util.h"
 #include "bus-common-errors.h"
@@ -146,7 +148,7 @@ static int user_save_internal(User *u) {
         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;
 
@@ -154,7 +156,8 @@ static int user_save_internal(User *u) {
         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"
@@ -189,18 +192,18 @@ static int user_save_internal(User *u) {
                 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)
@@ -209,12 +212,12 @@ static int user_save_internal(User *u) {
                         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))
@@ -223,12 +226,12 @@ static int user_save_internal(User *u) {
                         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)
@@ -237,12 +240,12 @@ static int user_save_internal(User *u) {
                         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)
@@ -251,12 +254,12 @@ static int user_save_internal(User *u) {
                         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)
@@ -265,11 +268,11 @@ static int user_save_internal(User *u) {
                         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);
@@ -343,7 +346,7 @@ static int user_mkdir_runtime_path(User *u) {
 
         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");
 
@@ -441,12 +444,11 @@ static int user_start_service(User *u) {
                         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);
 
index 043870b2417d8352c836a4af68b665e6e8e54499..cc8fb26b45b040e7413b8d0e2eafb3a6774b40bb 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index 2185db4b265353bddebac8ec2b51d75b42784f36..f6667609fa342a0437828c5636433b56c5b312ff 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index d711c9d89923bbe5a9b85af5c66ab2bbfbd53697..b76100bfcb0324501f52d3b34bcc570bf41501db 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -1113,7 +1114,6 @@ static int manager_parse_config_file(Manager *m) {
                                         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");
 
@@ -1124,8 +1124,8 @@ static int manager_parse_config_file(Manager *m) {
 
          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) {
index 9b90049ab8a7ef4b6b20c92116f6fa7a910d19ab..95de51a6556dde98373ccad4025d5ca6fe1e954c 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
index f1d8cce53bc31a8126c404686c977506e88c2c74..a25eb44016d9af9f8b3193565cf73eec39c3aa8a 100644 (file)
@@ -4,8 +4,10 @@
 
 <!--
   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.
index b0825a33f405b98e478cdad62ce0a17a6130e54d..997a7d70f2417f4014a299073fc9c9e97245bee6 100644 (file)
@@ -4,8 +4,10 @@
 
 <!--
   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.
@@ -21,8 +23,8 @@
         <!-- // 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>
@@ -32,8 +34,8 @@
         </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>
@@ -43,8 +45,8 @@
         </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>
@@ -54,8 +56,8 @@
         </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>
@@ -64,8 +66,8 @@
         </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>
@@ -74,8 +76,8 @@
         </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>
@@ -85,8 +87,8 @@
         </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>
@@ -96,8 +98,8 @@
         </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>
index 221badce616df567f3b773284218b928cd0ed59d..80b73769407c729d5f82c7eb074efe0de75d5ae7 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 23ff75f688951345a212755108eae4608f82429a..d48b9e8ccdcbd20bdcc4e7af9506a3241f838348 100644 (file)
@@ -1,4 +1,6 @@
 /***
+  SPDX-License-Identifier: LGPL-2.1+
+
   This file is part of systemd.
 
   systemd is free software; you can redistribute it and/or modify it
index cb5bb5e5f7e63374e1caab40f3ff63a2fbacedcd..16bb5118ba4c1be3fe2a9f24a085d610999cd9d9 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -41,13 +42,23 @@ static int show_sysfs_one(
                 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;
@@ -110,7 +121,7 @@ static int show_sysfs_one(
                         lookahead = udev_list_entry_get_next(lookahead);
                 }
 
-                k = ellipsize(sysfs, n_columns, 20);
+                k = ellipsize(sysfs, max_width, 20);
                 if (!k)
                         return -ENOMEM;
 
@@ -124,7 +135,7 @@ static int show_sysfs_one(
                         return -ENOMEM;
 
                 free(k);
-                k = ellipsize(l, n_columns, 70);
+                k = ellipsize(l, max_width, 70);
                 if (!k)
                         return -ENOMEM;
 
@@ -138,14 +149,16 @@ static int show_sysfs_one(
                         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;
@@ -154,8 +167,7 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) {
         if (n_columns <= 0)
                 n_columns = columns();
 
-        if (!prefix)
-                prefix = "";
+        prefix = strempty(prefix);
 
         if (isempty(seat))
                 seat = "seat0";
@@ -185,7 +197,7 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) {
 
         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)");
 
index 3e94bc3ed55a78a0245a925b7e381f3f99671117..15c902cc3aa63491afd004d09ec8314490f8531a 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
@@ -19,4 +20,8 @@
   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);
index a3cf9d293b4d5c1b39040d5f50a7da6e66a1b6a6..ad4700f328f4d18194b59d95d4d47dbd197cf338 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 47d8bf077a6a25bbdd243411bf283083b0f848c8..5f1e463232bb929c2fa2540a816da278b09c5e6c 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
index 4fbc893a9a0ae7d90cac44945dfa7d0bd4daed67..7772f4b85484346fa56062ed997b95793b03c8c1 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd