fix rpm is blocked when open fifo file

This commit is contained in:
renxichen 2022-11-16 10:31:44 +08:00
parent 6d1a82dd03
commit 6517998347
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 988df03f8a293f7aa1d6bb872b981c5dfc6493d9 Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Tue, 8 Nov 2022 10:36:36 +0800
Subject: [PATCH] rpm: fix rpm is blocked when open fifo file
---
lib/fsm.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/fsm.c b/lib/fsm.c
index c9ab3e1..c1c86b0 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1137,8 +1137,13 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
if (!rc && fd == -1 && !S_ISLNK(fp->sb.st_mode)) {
/* Only follow safe symlinks, and never on temporary files */
- fd = fsmOpenat(di.dirfd, fp->fpath,
- fp->suffix ? AT_SYMLINK_NOFOLLOW : 0);
+ int flags = fp->suffix ? AT_SYMLINK_NOFOLLOW : 0;
+
+ /* Open the FIFO file in O_RDWR mode to prevent process blocking */
+ if (S_ISFIFO(fp->sb.st_mode))
+ flags |= O_RDWR;
+
+ fd = fsmOpenat(di.dirfd, fp->fpath, flags);
if (fd < 0)
rc = RPMERR_OPEN_FAILED;
}
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: rpm
Version: 4.17.0
Release: 15
Release: 16
Summary: RPM Package Manager
License: GPLv2+
URL: http://www.rpm.org/
@ -84,6 +84,8 @@ Patch6048: backport-Fix-rpm-lua-rpm_vercmp-error-message-if-second-argum.patch
Patch6049: backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch
Patch6050: backport-Fix-possible-descriptor-leak-in-fsmOpenat.patch
Patch9000: rpm-fix-rpm-is-blocked-when-open-fifo-file.patch
BuildRequires: gcc autoconf automake libtool make gawk popt-devel openssl-devel readline-devel
BuildRequires: zlib-devel zstd-devel >= 1.3.8 xz-devel bzip2-devel libarchive-devel ima-evm-utils-devel
BuildRequires: dbus-devel fakechroot elfutils-devel elfutils-libelf-devel ima-evm-utils
@ -361,6 +363,9 @@ make check || (cat tests/rpmtests.log; exit 0)
%exclude %{_mandir}/man8/rpmspec.8.gz
%changelog
* Wed Nov 16 2022 xujing<xujing125@huawei.com> - 4.17.0-16
- rpm: fix rpm is blocked when open fifo file
* Tue Nov 15 2022 yuelg<yuelg@chinaunicom.cn> - 4.17.0-15
- Move rpm-build's help to rpm binary package