Accepting request 1189605 from Base:System

OBS-URL: https://build.opensuse.org/request/show/1189605
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rsyslog?expand=0&rev=178
This commit is contained in:
Dominique Leuenberger 2024-07-26 14:15:04 +00:00 committed by Git OBS Bridge
commit ccd2fd161f
7 changed files with 70 additions and 213 deletions

View File

@ -1,204 +0,0 @@
From 87c31b946d8d0a230f2db842328067eb5d8c5b08 Mon Sep 17 00:00:00 2001
From: Thomas Blume <Thomas.Blume@suse.com>
Date: Wed, 18 Oct 2023 16:22:45 +0200
Subject: [PATCH] use logind instead of utmp for wall messages with systemd
Future SUSE versions will get rid of utmp due to a 32bit time_t counter
overflow in 2038.
See details at:
https://github.com/thkukuk/utmpx/blob/main/Y2038.md
On systemd based systems logind is an alternative to utmp.
---
tools/omusrmsg.c | 142 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 110 insertions(+), 32 deletions(-)
diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c
index 6086d2d6b..aaa36d9e5 100644
--- a/tools/omusrmsg.c
+++ b/tools/omusrmsg.c
@@ -56,6 +56,11 @@
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
+#ifdef HAVE_LIBSYSTEMD
+#include <systemd/sd-daemon.h>
+#include <systemd/sd-login.h>
+#include <pwd.h>
+#endif
#include "rsyslog.h"
#include "srUtils.h"
#include "stringbuf.h"
@@ -201,6 +206,42 @@ void endutent(void)
#endif /* #ifdef OS_BSD */
+static void sendwallmsg(const char *tty, uchar* pMsg)
+{
+ uchar szErr[512];
+ int errnoSave;
+ char p[sizeof(_PATH_DEV) + UNAMESZ];
+ int ttyf;
+ struct stat statb;
+ int wrRet;
+
+ /* compute the device name */
+ strcpy(p, _PATH_DEV);
+ strncat(p, tty, UNAMESZ);
+
+ /* we must be careful when writing to the terminal. A terminal may block
+ * (for example, a user has pressed <ctl>-s). In that case, we can not
+ * wait indefinitely. So we need to use non-blocking I/O. In case we would
+ * block, we simply do not send the message, because that's the best we can
+ * do. -- rgerhards, 2008-07-04
+ */
+
+ /* open the terminal */
+ if((ttyf = open(p, O_WRONLY|O_NOCTTY|O_NONBLOCK)) >= 0) {
+ if(fstat(ttyf, &statb) == 0 && (statb.st_mode & S_IWRITE)) {
+ wrRet = write(ttyf, pMsg, strlen((char*)pMsg));
+ if(Debug && wrRet == -1) {
+ /* we record the state to the debug log */
+ errnoSave = errno;
+ rs_strerror_r(errno, (char*)szErr, sizeof(szErr));
+ dbgprintf("write to terminal '%s' failed with [%d]:%s\n",
+ p, errnoSave, szErr);
+ }
+ }
+ close(ttyf);
+ }
+}
+
/* WALLMSG -- Write a message to the world at large
*
* Write the specified message to either the entire
@@ -215,20 +256,78 @@ void endutent(void)
*/
static rsRetVal wallmsg(uchar* pMsg, instanceData *pData)
{
-
- uchar szErr[512];
- char p[sizeof(_PATH_DEV) + UNAMESZ];
register int i;
- int errnoSave;
- int ttyf;
- int wrRet;
STRUCTUTMP ut;
STRUCTUTMP *uptr;
- struct stat statb;
DEFiRet;
assert(pMsg != NULL);
+#ifdef HAVE_LIBSYSTEMD
+ if (sd_booted() > 0) {
+ register int j;
+ int sdRet;
+ char **sessions_list;
+ int sessions = sd_get_sessions(&sessions_list);
+
+ for (j = 0; j < sessions; j++) {
+ uchar szErr[512];
+ char *user = NULL, *tty;
+ uid_t uid;
+ struct passwd *pws;
+
+ sdRet = sd_session_get_uid(sessions_list[j], &uid);
+ if (sdRet >= 0) {
+ pws = getpwuid(uid);
+ user = pws->pw_name;
+
+ if (user == NULL) {
+ dbgprintf("failed to get username for userid '%d'\n", uid);
+ continue;
+ }
+ } else {
+ /* we record the state to the debug log */
+ rs_strerror_r(-sdRet, (char*)szErr, sizeof(szErr));
+ dbgprintf("get userid for session '%s' failed with [%d]:%s\n",
+ sessions_list[j], -sdRet, szErr);
+ continue; /* try next session */
+ }
+ /* should we send the message to this user? */
+ if(pData->bIsWall == 0) {
+ for(i = 0; i < MAXUNAMES; i++) {
+ if(!pData->uname[i][0]) {
+ i = MAXUNAMES;
+ break;
+ }
+ if(strncmp(pData->uname[i], user, UNAMESZ) == 0)
+ break;
+ }
+ if(i == MAXUNAMES) { /* user not found? */
+ free(user);
+ free(sessions_list[j]);
+ continue; /* on to next user! */
+ }
+ }
+ if ((sdRet = sd_session_get_tty(sessions_list[j], &tty)) < 0) {
+ /* we record the state to the debug log */
+ rs_strerror_r(-sdRet, (char*)szErr, sizeof(szErr));
+ dbgprintf("get tty for session '%s' failed with [%d]:%s\n",
+ sessions_list[j], -sdRet, szErr);
+ free(user);
+ free(sessions_list[j]);
+ continue; /* try next session */
+ }
+
+ sendwallmsg(tty, pMsg);
+
+ free(user);
+ free(tty);
+ free(sessions_list[j]);
+ }
+ free(sessions_list);
+ } else {
+#endif
+
/* open the user login file */
setutent();
@@ -259,35 +358,14 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData)
continue; /* on to next user! */
}
- /* compute the device name */
- strcpy(p, _PATH_DEV);
- strncat(p, ut.ut_line, UNAMESZ);
-
- /* we must be careful when writing to the terminal. A terminal may block
- * (for example, a user has pressed <ctl>-s). In that case, we can not
- * wait indefinitely. So we need to use non-blocking I/O. In case we would
- * block, we simply do not send the message, because that's the best we can
- * do. -- rgerhards, 2008-07-04
- */
-
- /* open the terminal */
- if((ttyf = open(p, O_WRONLY|O_NOCTTY|O_NONBLOCK)) >= 0) {
- if(fstat(ttyf, &statb) == 0 && (statb.st_mode & S_IWRITE)) {
- wrRet = write(ttyf, pMsg, strlen((char*)pMsg));
- if(Debug && wrRet == -1) {
- /* we record the state to the debug log */
- errnoSave = errno;
- rs_strerror_r(errno, (char*)szErr, sizeof(szErr));
- dbgprintf("write to terminal '%s' failed with [%d]:%s\n",
- p, errnoSave, szErr);
- }
- }
- close(ttyf);
- }
+ sendwallmsg(ut.ut_line, pMsg);
}
/* close the user login file */
endutent();
+#ifdef HAVE_LIBSYSTEMD
+ }
+#endif
RETiRet;
}
--
2.42.0

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f6283efaadc609540a56e6bec88a362c966e77f29fe48e6b734bd6c1123e0be5
size 3293380

3
rsyslog-8.2406.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1343e0269dd32166ffde04d7ceebfa0e7146cf1dbc6962c56bf428c61f01a7df
size 3412827

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b8c6831305462c80cc13d9a7991c82d86ea229c3bdec2ccef6a6db2fce751445
size 6637017

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5b4629d51651bcc4b10b9576c02add4a30d41871c3a56e11e442a7806889f1ef
size 6568856

View File

@ -1,3 +1,66 @@
-------------------------------------------------------------------
Wed Jul 24 06:48:46 UTC 2024 - Thomas Blume <Thomas.Blume@suse.com>
- Upgrade to rsyslog 8.2406.0
-patches replaced by upgrade (see details in upgrade logs below)
0001-use-logind-instead-of-utmp-for-wall-messages-with-sy.patch
* 2023-11-29: Revert "Update omlibdbi.c"
* 2023-11-21: imkmsg: add params "readMode" and "expectedBootCompleteSeconds"
* 2023-11-10: testbench: fix "typo" in test case
* 2023-11-08: omazureeventhubs: Corrected handling of transport closed failures
* 2023-10-31: imkmsg: add module param parseKernelTimestamp
* 2023-11-03: imfile: remove state file on file delete fix
* 2023-10-30: imklog bugfix: keepKernelTimestamp=off config param did not work
* 2023-10-30: Netstreamdriver: deallocate certificate related resources
* 2023-10-20: TLS subsystem: add remote hostname to error reporting
* 2023-10-21: Fix forking issue do to close_range call
* 2023-10-23: replace debian sample systemd service file by readme
* 2023-10-20: testbench: bump zookeeper version to match current offering
* 2023-10-20: Update rsyslog.service sample unit to the latest version used in Debian Trixie
* 2023-10-20: Only keep a single rsyslog.service for Debian
* 2023-10-20: Remove no longer used --with-systemdsystemunitdir configure switch
* 2023-10-18: use logind instead of utmp for wall messages with systemd
- replaces 0001-use-logind-instead-of-utmp-for-wall-messages-with-sy.patch
* 2023-10-11: Typo fixes
* 2023-10-11: Drop CAP_IPC_LOCK capability
* 2023-10-04: Add CAP_NET_RAW capability due to the omudpspoof module
* 2023-10-03: Add new global config option "libcapng.enable"
* 2023-10-02: tcp net subsystem: handle data race gracefully
* 2023-08-31: Avoid crash on restart in imrelp SIGTTIN handler
* 2023-09-26: fix startup issue on modern systemd systems
* 2023-09-14: Fix misspeling in message.
* 2023-09-13: tcpflood bugfix: plain tcp send error not properly reported
* 2023-09-12: omprog bugfix: Add CAP_DAC_OVERRIDE to the bounding set
* 2023-08-02: testbench: cleanup and improve some more imfile tests
* 2023-08-02: lookup tables: fix static analyzer issue
* 2023-08-02: lookup tables bugfix: reload on HUP did not work when backgrounded
* 2023-07-28: CI: fix and cleaup github workflow
* 2023-03-07: imjournal: Support input module
* 2023-07-28: testbench: make test more reliable
* 2023-07-28: tcpflood: add -A option to NOT abort when sending fails
* 2023-07-28: tcpflood: fix today's programming error
* 2023-07-28: openssl: Replaced depreceated method SSLv23_method with TLS_method
* 2023-07-27: testbench improvement: define state file directories for imfile tests
* 2023-07-28: testbench: cleanup a test and some nitfixes to it
* 2023-07-27: tcpflood bugfix: TCP sending was not implemented properly
* 2023-07-26: testbench: make waiting for HUP processing more reliable
* 2023-07-25: build system: make rsyslogd execute when --disable-inet is configured
* 2023-07-25: CI: update zookeper download to newer version
* 2023-07-10: ossl driver: Using newer INIT API for OpenSSL 1.1+ Versions
* 2023-07-11: ossl: Fix CRL File Expire from 1 day to 100 years.
* 2023-07-06: PR5175: Add TLS CRL Support for GnuTLS driver and OpenSSL 1.0.2+
* 2022-05-13: omazureeventhubs: Initial implementation of new output module
* 2023-07-03: TLS CRL Support Issue 5081
* 2023-06-29: action.resumeintervalmax: the parameter was not respected
* 2023-06-28: IMHIREDIS::FIXED:: Restore compatiblity with hiredis < v1.0.0
* 2023-05-15: Add the 'batchsize' parameter to imhiredis
* 2023-06-28: Clear undefined behavior in libgcry.c (GH #5167)
* 2023-06-22: Do not try to drop capabilities when we don't have any
* 2023-06-22: testbench: use newer zookeeper version in tests
* 2023-06-22: build system: more precise error message on too-old lib
* 2023-05-17: Fix quoting for omprog, improg, mmexternal
-------------------------------------------------------------------
Thu Mar 14 13:15:09 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -30,7 +30,7 @@
%define requires_file() %( readlink -f '%*' | LC_ALL=C xargs -r rpm -q --qf 'Requires: %%{name} >= %%{epoch}:%%{version}\\n' -f | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
# drop this with next release when doc tarball version lines up
%define rsyslog_major 8.2306
%define rsyslog_major 8.2406
%define rsyslog_patch 0
Name: rsyslog
Summary: The enhanced syslogd for Linux and Unix
@ -219,8 +219,6 @@ Source17: acpid.frule
Source18: firewall.frule
Source19: NetworkManager.frule
Patch1: 0001-use-logind-instead-of-utmp-for-wall-messages-with-sy.patch
# this is a dirty hack since % dir does only work for the specified directory and nothing above
# but I want to be able to switch this to /etc/apparmor.d once the profiles received more testing
%define APPARMOR_PROFILE_PATH /usr/share/apparmor/extra-profiles