diff --git a/rpm-4.13.0-redirect2null.patch b/rpm-4.13.0-redirect2null.patch new file mode 100644 index 0000000..36d3885 --- /dev/null +++ b/rpm-4.13.0-redirect2null.patch @@ -0,0 +1,71 @@ +From 19fe0d9ae12644b8af9513aa2a8cf7d16f7caa61 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 4 Mar 2016 16:40:30 -0500 +Subject: [PATCH] Add posix.redirect2null + +This is useful to silence output in forked programs: +https://bugzilla.redhat.com/show_bug.cgi?id=1287918 + +Tested with the following scriptlet: +%post -p +pid = posix.fork() +if pid == 0 then + assert(posix.exec("/bin/sed")) +elseif pid > 0 then + posix.wait(pid) +end +pid = posix.fork() +if pid == 0 then + posix.redirect2null(2) + assert(posix.exec("/bin/awk")) +elseif pid > 0 then + posix.wait(pid) +end + +As expected, the error message from sed is printed, the error message +from awk is not. +--- + luaext/lposix.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/luaext/lposix.c b/luaext/lposix.c +index 51ea2b3..c578c5a 100644 +--- a/luaext/lposix.c ++++ b/luaext/lposix.c +@@ -819,6 +819,25 @@ static int Pmkstemp(lua_State *L) + return 2; + } + ++static int Predirect2null(lua_State *L) ++{ ++ int target_fd, fd, r, e; ++ ++ if (!have_forked) ++ return luaL_error(L, "silence_file_descriptor not permitted in this context"); ++ ++ target_fd = luaL_checkinteger(L, 1); ++ ++ r = fd = open("/dev/null", O_WRONLY); ++ if (fd >= 0 && fd != target_fd) { ++ r = dup2(fd, target_fd); ++ e = errno; ++ (void) close(fd); ++ errno = e; ++ } ++ return pushresult(L, r, NULL); ++} ++ + static const luaL_Reg R[] = + { + {"access", Paccess}, +@@ -861,6 +880,7 @@ static const luaL_Reg R[] = + {"wait", Pwait}, + {"setenv", Psetenv}, + {"unsetenv", Punsetenv}, ++ {"redirect2null", Predirect2null}, + {NULL, NULL} + }; + +-- +1.9.3 + diff --git a/rpm.spec b/rpm.spec index ff7f83a..744e63e 100644 --- a/rpm.spec +++ b/rpm.spec @@ -29,7 +29,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}26%{?dist} +Release: %{?snapver:0.%{snapver}.}27%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2 @@ -72,6 +72,7 @@ Patch116: rpm-4.13.0-idle-and-sleep-in-systemd-inhibit.patch Patch117: rpm-4.13.0-add-mipsr6-support.patch Patch118: rpm-4.13.0-Use-pkg-dpaths-during-dependency-generation.patch Patch119: rpm-4.13.0-Noarch-ExclusiveArch.patch +Patch120: rpm-4.13.0-redirect2null.patch # These are not yet upstream Patch302: rpm-4.7.1-geode-i686.patch @@ -583,6 +584,9 @@ exit 0 %doc doc/librpm/html/* %changelog +* Thu Mar 10 2016 Lubos Kardos 4.13.0-0.rc1.27 +- Add posix.redirect2null (#1287918) + * Fri Feb 26 2016 Florian Festi - 4.4.13.0-0.rc1.26 - Fix ExclusiveArch/ExcludeArch for noarch packages (#1298668)