RHEL-9.9: script: fix use of utempter (utmp registration)
Resolves: RHEL-192480 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
cae3dd3fd5
commit
1f1e41b7ce
122
0089-llib-pty-session-split-PTY-and-signalfd-setup.patch
Normal file
122
0089-llib-pty-session-split-PTY-and-signalfd-setup.patch
Normal file
@ -0,0 +1,122 @@
|
||||
From 8f330878a51d5fd65ec44756ba101392e5ea5ab6 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Wed, 16 Nov 2022 09:17:52 +0100
|
||||
Subject: [PATCH 89/90] llib/pty-session: split PTY and signalfd setup
|
||||
|
||||
In some cases applications need to use PTY before signalfd is enabled.
|
||||
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
(cherry picked from commit 4681d88ba1034d488814bbbb6e7d06d17e33322d)
|
||||
---
|
||||
include/pty-session.h | 1 +
|
||||
lib/pty-session.c | 29 +++++++++++++++++++++++++----
|
||||
login-utils/su-common.c | 2 ++
|
||||
term-utils/scriptlive.c | 2 ++
|
||||
4 files changed, 30 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/include/pty-session.h b/include/pty-session.h
|
||||
index 09eff43fd..3242992da 100644
|
||||
--- a/include/pty-session.h
|
||||
+++ b/include/pty-session.h
|
||||
@@ -98,6 +98,7 @@ void ul_pty_set_child(struct ul_pty *pty, pid_t child);
|
||||
struct ul_pty_callbacks *ul_pty_get_callbacks(struct ul_pty *pty);
|
||||
int ul_pty_is_running(struct ul_pty *pty);
|
||||
int ul_pty_setup(struct ul_pty *pty);
|
||||
+int ul_pty_signals_setup(struct ul_pty *pty);
|
||||
void ul_pty_cleanup(struct ul_pty *pty);
|
||||
int ul_pty_chownmod_slave(struct ul_pty *pty, uid_t uid, gid_t gid, mode_t mode);
|
||||
void ul_pty_init_slave(struct ul_pty *pty);
|
||||
diff --git a/lib/pty-session.c b/lib/pty-session.c
|
||||
index 6f038e1c5..d89dfbb29 100644
|
||||
--- a/lib/pty-session.c
|
||||
+++ b/lib/pty-session.c
|
||||
@@ -149,12 +149,12 @@ static void pty_signals_cleanup(struct ul_pty *pty)
|
||||
int ul_pty_setup(struct ul_pty *pty)
|
||||
{
|
||||
struct termios attrs;
|
||||
- sigset_t ourset;
|
||||
int rc = 0;
|
||||
|
||||
assert(pty->sigfd == -1);
|
||||
|
||||
- /* save the current signals setting */
|
||||
+ /* save the current signals setting (to make ul_pty_cleanup() usable,
|
||||
+ * otherwise see ul_pty_signals_setup() */
|
||||
sigprocmask(0, NULL, &pty->orgsig);
|
||||
|
||||
if (pty->isterm) {
|
||||
@@ -198,6 +198,26 @@ int ul_pty_setup(struct ul_pty *pty)
|
||||
tcsetattr(pty->slave, TCSANOW, &attrs);
|
||||
}
|
||||
|
||||
+done:
|
||||
+ if (rc)
|
||||
+ ul_pty_cleanup(pty);
|
||||
+
|
||||
+ DBG(SETUP, ul_debugobj(pty, "pty setup done [master=%d, slave=%d, rc=%d]",
|
||||
+ pty->master, pty->slave, rc));
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/* call me before fork() */
|
||||
+int ul_pty_signals_setup(struct ul_pty *pty)
|
||||
+{
|
||||
+ sigset_t ourset;
|
||||
+ int rc = 0;
|
||||
+
|
||||
+ assert(pty->sigfd == -1);
|
||||
+
|
||||
+ /* save the current signals setting */
|
||||
+ sigprocmask(0, NULL, &pty->orgsig);
|
||||
+
|
||||
sigfillset(&ourset);
|
||||
if (sigprocmask(SIG_BLOCK, &ourset, NULL)) {
|
||||
rc = -errno;
|
||||
@@ -221,8 +241,7 @@ done:
|
||||
if (rc)
|
||||
ul_pty_cleanup(pty);
|
||||
|
||||
- DBG(SETUP, ul_debugobj(pty, "pty setup done [master=%d, slave=%d, rc=%d]",
|
||||
- pty->master, pty->slave, rc));
|
||||
+ DBG(SETUP, ul_debugobj(pty, "pty signals setup done [rc=%d]", rc));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -692,6 +711,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (ul_pty_setup(pty))
|
||||
err(EXIT_FAILURE, "failed to create pseudo-terminal");
|
||||
+ if (ul_pty_signals_setup(pty))
|
||||
+ err(EXIT_FAILURE, "failed to initialize signals handler");
|
||||
|
||||
fflush(stdout); /* ??? */
|
||||
|
||||
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
|
||||
index 7d4826bbc..bde412b94 100644
|
||||
--- a/login-utils/su-common.c
|
||||
+++ b/login-utils/su-common.c
|
||||
@@ -536,6 +536,8 @@ static void create_watching_parent(struct su_context *su)
|
||||
/* create pty */
|
||||
if (ul_pty_setup(su->pty))
|
||||
err(EXIT_FAILURE, _("failed to create pseudo-terminal"));
|
||||
+ if (ul_pty_signals_setup(su->pty))
|
||||
+ err(EXIT_FAILURE, _("failed to initialize signals handler"));
|
||||
}
|
||||
#endif
|
||||
fflush(stdout); /* ??? */
|
||||
diff --git a/term-utils/scriptlive.c b/term-utils/scriptlive.c
|
||||
index 37f092c1f..d25ab77db 100644
|
||||
--- a/term-utils/scriptlive.c
|
||||
+++ b/term-utils/scriptlive.c
|
||||
@@ -294,6 +294,8 @@ main(int argc, char *argv[])
|
||||
|
||||
if (ul_pty_setup(ss.pty))
|
||||
err(EXIT_FAILURE, _("failed to create pseudo-terminal"));
|
||||
+ if (ul_pty_signals_setup(ss.pty))
|
||||
+ err(EXIT_FAILURE, _("failed to initialize signals handler"));
|
||||
|
||||
fflush(stdout); /* ??? */
|
||||
|
||||
--
|
||||
2.55.0
|
||||
|
||||
44
0090-script-fix-use-of-utempter.patch
Normal file
44
0090-script-fix-use-of-utempter.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From e547bdcbd4196114c512cf6d2fe1cecf5bbcfcbb Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Wed, 16 Nov 2022 09:19:18 +0100
|
||||
Subject: [PATCH 90/90] script: fix use of utempter
|
||||
|
||||
libutempter uses SIGCHLD, but script(1) pty implementation completely
|
||||
control all signals by signalfd and utempter does not work.
|
||||
|
||||
The solution is to setup signalfd later (after libutempter use).
|
||||
|
||||
Fixes: https://github.com/util-linux/util-linux/issues/1904
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
(cherry picked from commit 6ed644fbf4869a7e042826900eff531cf6660cfb)
|
||||
---
|
||||
term-utils/script.c | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/term-utils/script.c b/term-utils/script.c
|
||||
index c8b55c8ef..be2c935d5 100644
|
||||
--- a/term-utils/script.c
|
||||
+++ b/term-utils/script.c
|
||||
@@ -938,13 +938,16 @@ int main(int argc, char **argv)
|
||||
printf(_(".\n"));
|
||||
}
|
||||
|
||||
-#ifdef HAVE_LIBUTEMPTER
|
||||
- utempter_add_record(ul_pty_get_childfd(ctl.pty), NULL);
|
||||
-#endif
|
||||
|
||||
if (ul_pty_setup(ctl.pty))
|
||||
err(EXIT_FAILURE, _("failed to create pseudo-terminal"));
|
||||
|
||||
+#ifdef HAVE_LIBUTEMPTER
|
||||
+ utempter_add_record(ul_pty_get_childfd(ctl.pty), NULL);
|
||||
+#endif
|
||||
+
|
||||
+ if (ul_pty_signals_setup(ctl.pty))
|
||||
+ err(EXIT_FAILURE, _("failed to initialize signals handler"));
|
||||
fflush(stdout);
|
||||
|
||||
/*
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Summary: A collection of basic system utilities
|
||||
Name: util-linux
|
||||
Version: 2.37.4
|
||||
Release: 25%{?dist}
|
||||
Release: 26%{?dist}
|
||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
||||
URL: http://en.wikipedia.org/wiki/Util-linux
|
||||
|
||||
@ -253,6 +253,9 @@ Patch86: 0086-libblkid-use-snprintf-instead-of-sprintf.patch
|
||||
Patch87: 0087-libfdisk-dos-fix-off-by-one-in-maximum-last-sector-c.patch
|
||||
# RHEL-133956 - login-utils: fix setpwnam() buffer use [CVE-2025-14104]
|
||||
Patch88: 0088-login-utils-fix-setpwnam-buffer-use-CVE-2025-14104.patch
|
||||
# RHEL-192480 - script: fix use of utempter (utmp registration)
|
||||
Patch89: 0089-llib-pty-session-split-PTY-and-signalfd-setup.patch
|
||||
Patch90: 0090-script-fix-use-of-utempter.patch
|
||||
|
||||
|
||||
%description
|
||||
@ -1088,6 +1091,9 @@ fi
|
||||
%{_libdir}/python*/site-packages/libmount/
|
||||
|
||||
%changelog
|
||||
* Thu Jul 16 2026 Karel Zak <kzak@redhat.com> 2.37.4-26
|
||||
- fix RHEL-192480 - script: fix use of utempter (utmp registration)
|
||||
|
||||
* Mon Jan 19 2026 Karel Zak <kzak@redhat.com> 2.37.4-25
|
||||
- fix RHEL-132706 - use sysusers.d for uuidd
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user