!825 systemd-logind button_dispatch add log to display devices that triggered the button

From: @fly_fzc 
Reviewed-by: @xujing99 
Signed-off-by: @xujing99
This commit is contained in:
openeuler-ci-bot 2025-01-03 02:26:51 +00:00 committed by Gitee
commit 18c3f3643b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From daebc1a8c4ef28c8a52f7549f18d42702abd7cdc Mon Sep 17 00:00:00 2001
From: huyubiao <huyubiao@huawei.com>
Date: Tue, 12 Nov 2024 15:36:21 +0800
Subject: [PATCH] systemd-logind button_dispatch add log to display devices that triggered the button
---
src/login/logind-action.c | 7 +++++++
src/login/logind-button.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index e678edd..17e8b26 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -191,6 +191,13 @@ static int handle_action_execute(
return is_edge ? -EPERM : 0;
}
+ // Extra log to console
+ LogTarget old_target = log_get_target();
+ log_set_always_reopen_console(true);
+ log_set_target_and_open(LOG_TARGET_CONSOLE);
+ log_info("%s", message_table[handle]);
+ log_set_always_reopen_console(false);
+ log_set_target_and_open(old_target);
log_info("%s", message_table[handle]);
r = bus_manager_shutdown_or_sleep_now_or_later(m, handle_action_lookup(handle), &error);
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 7f95fa7..54e877e 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -205,6 +205,13 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
assert(s);
assert(fd == b->fd);
+ LogTarget old_target = log_get_target();
+ log_set_always_reopen_console(true);
+ log_set_target_and_open(LOG_TARGET_CONSOLE);
+ log_info("button:%s event", b->name);
+ log_set_always_reopen_console(false);
+ log_set_target_and_open(old_target);
+
l = read(b->fd, &ev, sizeof(ev));
if (l < 0)
return errno != EAGAIN ? -errno : 0;
--
2.33.0

View File

@ -25,7 +25,7 @@
Name: systemd Name: systemd
Url: https://systemd.io/ Url: https://systemd.io/
Version: 255 Version: 255
Release: 35 Release: 36
License: MIT and LGPLv2+ and GPLv2+ License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager Summary: System and Service Manager
@ -149,6 +149,7 @@ Patch9056: set-the-cpuset.cpus-mems-of-machine.slice-to-all-by-.patch
Patch9057: add-a-new-switch-to-control-whether-udev-complies-wi.patch Patch9057: add-a-new-switch-to-control-whether-udev-complies-wi.patch
Patch9058: journal-don-t-enable-systemd-journald-audit.socket.patch Patch9058: journal-don-t-enable-systemd-journald-audit.socket.patch
Patch9059: systemd-fstab-generator-print-logs-only-to-kmsg.patch Patch9059: systemd-fstab-generator-print-logs-only-to-kmsg.patch
Patch9060: systemd-logind-add-log-to-display-devices.patch
Patch9801: Systemd-Add-sw64-architecture.patch Patch9801: Systemd-Add-sw64-architecture.patch
Patch9802: backport-repart-fix-memory-leak.patch Patch9802: backport-repart-fix-memory-leak.patch
@ -1689,6 +1690,9 @@ fi
%{_unitdir}/veritysetup.target %{_unitdir}/veritysetup.target
%changelog %changelog
* Tue Dec 31 2024 fuanan <fuanan3@h-partners.com> - 255-36
- systemd-logind button_dispatch add log to display devices that triggered the button
* Tue Dec 24 2024 wangyuhang <wangyuhang27@huawei.com> - 255-35 * Tue Dec 24 2024 wangyuhang <wangyuhang27@huawei.com> - 255-35
- sync patches from systemd community - sync patches from systemd community