diff options
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch | 19 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch | 22 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0001-Factor-out-and-unify-setting-CLOEXEC.patch | 148 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0001-configure.ac-add-option-for-dbus.patch | 42 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0002-Optimize-rpmSetCloseOnExec.patch | 100 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch | 53 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/files/0004-build-pack.c-remove-static-local-variables-from-buil.patch | 17 | ||||
| -rw-r--r-- | meta/recipes-devtools/rpm/rpm_4.14.2.bb (renamed from meta/recipes-devtools/rpm/rpm_4.14.1.bb) | 10 |
8 files changed, 23 insertions, 388 deletions
diff --git a/meta/recipes-devtools/rpm/files/0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch b/meta/recipes-devtools/rpm/files/0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch index 5604cb9037..82e7328757 100644 --- a/meta/recipes-devtools/rpm/files/0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch +++ b/meta/recipes-devtools/rpm/files/0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | From c82c19dc583843b1a975f2e3f2e151656a6f377c Mon Sep 17 00:00:00 2001 | 1 | From bd08eb0ae1312f347f49949481daa7c923752df2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Mon, 27 Feb 2017 09:43:30 +0200 | 3 | Date: Mon, 27 Feb 2017 09:43:30 +0200 |
| 4 | Subject: [PATCH 06/14] Do not hardcode "lib/rpm" as the installation path for | 4 | Subject: [PATCH] Do not hardcode "lib/rpm" as the installation path for |
| 5 | default configuration and macros. | 5 | default configuration and macros. |
| 6 | 6 | ||
| 7 | Upstream-Status: Denied [https://github.com/rpm-software-management/rpm/pull/263] | 7 | Upstream-Status: Denied [https://github.com/rpm-software-management/rpm/pull/263] |
| @@ -14,10 +14,10 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | |||
| 14 | 3 files changed, 4 insertions(+), 4 deletions(-) | 14 | 3 files changed, 4 insertions(+), 4 deletions(-) |
| 15 | 15 | ||
| 16 | diff --git a/configure.ac b/configure.ac | 16 | diff --git a/configure.ac b/configure.ac |
| 17 | index 7155d9f00..21b95ae5f 100644 | 17 | index 09af7c4..9bd6903 100644 |
| 18 | --- a/configure.ac | 18 | --- a/configure.ac |
| 19 | +++ b/configure.ac | 19 | +++ b/configure.ac |
| 20 | @@ -1047,7 +1047,7 @@ else | 20 | @@ -1055,7 +1055,7 @@ else |
| 21 | usrprefix=$prefix | 21 | usrprefix=$prefix |
| 22 | fi | 22 | fi |
| 23 | 23 | ||
| @@ -27,10 +27,10 @@ index 7155d9f00..21b95ae5f 100644 | |||
| 27 | 27 | ||
| 28 | AC_SUBST(OBJDUMP) | 28 | AC_SUBST(OBJDUMP) |
| 29 | diff --git a/macros.in b/macros.in | 29 | diff --git a/macros.in b/macros.in |
| 30 | index d08624856..68a972f1e 100644 | 30 | index a3aa7a9..62cee5c 100644 |
| 31 | --- a/macros.in | 31 | --- a/macros.in |
| 32 | +++ b/macros.in | 32 | +++ b/macros.in |
| 33 | @@ -954,7 +954,7 @@ package or when debugging this package.\ | 33 | @@ -970,7 +970,7 @@ package or when debugging this package.\ |
| 34 | %_sharedstatedir %{_prefix}/com | 34 | %_sharedstatedir %{_prefix}/com |
| 35 | %_localstatedir %{_prefix}/var | 35 | %_localstatedir %{_prefix}/var |
| 36 | %_lib lib | 36 | %_lib lib |
| @@ -40,7 +40,7 @@ index d08624856..68a972f1e 100644 | |||
| 40 | %_infodir %{_datadir}/info | 40 | %_infodir %{_datadir}/info |
| 41 | %_mandir %{_datadir}/man | 41 | %_mandir %{_datadir}/man |
| 42 | diff --git a/rpm.am b/rpm.am | 42 | diff --git a/rpm.am b/rpm.am |
| 43 | index 51225892d..e0c834d37 100644 | 43 | index 82c2d7c..6341b51 100644 |
| 44 | --- a/rpm.am | 44 | --- a/rpm.am |
| 45 | +++ b/rpm.am | 45 | +++ b/rpm.am |
| 46 | @@ -1,10 +1,10 @@ | 46 | @@ -1,10 +1,10 @@ |
| @@ -55,7 +55,4 @@ index 51225892d..e0c834d37 100644 | |||
| 55 | +rpmconfigdir = $(libdir)/rpm | 55 | +rpmconfigdir = $(libdir)/rpm |
| 56 | 56 | ||
| 57 | # Libtool version (current-revision-age) for all our libraries | 57 | # Libtool version (current-revision-age) for all our libraries |
| 58 | rpm_version_info = 8:1:0 | 58 | rpm_version_info = 9:0:1 |
| 59 | -- | ||
| 60 | 2.15.1 | ||
| 61 | |||
diff --git a/meta/recipes-devtools/rpm/files/0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch b/meta/recipes-devtools/rpm/files/0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch index bf24d43eb9..41cdf6ed77 100644 --- a/meta/recipes-devtools/rpm/files/0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch +++ b/meta/recipes-devtools/rpm/files/0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch | |||
| @@ -1,25 +1,23 @@ | |||
| 1 | From ffb5301a8594140ad7a58bc0f2053be8ca2b2946 Mon Sep 17 00:00:00 2001 | 1 | From a674b9cc7af448d7c6748bc163bf37dc14a57f09 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Fri, 20 Jan 2017 13:32:06 +0200 | 3 | Date: Fri, 20 Jan 2017 13:32:06 +0200 |
| 4 | Subject: [PATCH 1/2] Do not reset the PATH environment variable before running | 4 | Subject: [PATCH] Do not reset the PATH environment variable before running |
| 5 | scriptlets. | 5 | scriptlets. |
| 6 | 6 | ||
| 7 | We add lots of native stuff into it and scriptlets rely on that. | 7 | We add lots of native stuff into it and scriptlets rely on that. |
| 8 | 8 | ||
| 9 | Also need to remove the xx test later in the function since the | ||
| 10 | value could now be used un-initialised. | ||
| 11 | |||
| 12 | Upstream-Status: Inappropriate [oe-core specific] | 9 | Upstream-Status: Inappropriate [oe-core specific] |
| 13 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | 10 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 11 | |||
| 14 | --- | 12 | --- |
| 15 | lib/rpmscript.c | 2 +- | 13 | lib/rpmscript.c | 2 +- |
| 16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 17 | 15 | ||
| 18 | diff --git a/lib/rpmscript.c b/lib/rpmscript.c | 16 | diff --git a/lib/rpmscript.c b/lib/rpmscript.c |
| 19 | index 92f949fa2..7c1aa75a8 100644 | 17 | index 6a31e0d..2b0e438 100644 |
| 20 | --- a/lib/rpmscript.c | 18 | --- a/lib/rpmscript.c |
| 21 | +++ b/lib/rpmscript.c | 19 | +++ b/lib/rpmscript.c |
| 22 | @@ -201,7 +201,7 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes, | 20 | @@ -184,7 +184,7 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes, |
| 23 | if (ipath && ipath[5] != '%') | 21 | if (ipath && ipath[5] != '%') |
| 24 | path = ipath; | 22 | path = ipath; |
| 25 | 23 | ||
| @@ -28,13 +26,3 @@ index 92f949fa2..7c1aa75a8 100644 | |||
| 28 | free(ipath); | 26 | free(ipath); |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | @@ -206,9 +206,7 @@ static void doScriptExec(ARGV_const_t ar | ||
| 32 | /* XXX Don't mtrace into children. */ | ||
| 33 | unsetenv("MALLOC_CHECK_"); | ||
| 34 | |||
| 35 | - if (xx == 0) { | ||
| 36 | xx = execv(argv[0], argv); | ||
| 37 | - } | ||
| 38 | } | ||
| 39 | _exit(127); /* exit 127 for compatibility with bash(1) */ | ||
| 40 | } | ||
diff --git a/meta/recipes-devtools/rpm/files/0001-Factor-out-and-unify-setting-CLOEXEC.patch b/meta/recipes-devtools/rpm/files/0001-Factor-out-and-unify-setting-CLOEXEC.patch deleted file mode 100644 index 6f440c6178..0000000000 --- a/meta/recipes-devtools/rpm/files/0001-Factor-out-and-unify-setting-CLOEXEC.patch +++ /dev/null | |||
| @@ -1,148 +0,0 @@ | |||
| 1 | From 9c3e5de3240554c8ea1b29d52eeadee4840fefac Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 3 | Date: Tue, 29 May 2018 17:37:05 -0700 | ||
| 4 | Subject: [PATCH 1/3] Factor out and unify setting CLOEXEC | ||
| 5 | |||
| 6 | Commit 7a7c31f5 ("Set FD_CLOEXEC on opened files before exec from | ||
| 7 | lua script is called") copied the code that sets CLOEXEC flag on all | ||
| 8 | possible file descriptors from lib/rpmscript.c to luaext/lposix.c, | ||
| 9 | essentially creating two copies of the same code (modulo comments | ||
| 10 | and the unused assignment). | ||
| 11 | |||
| 12 | This commit moves the functionality into its own function, without | ||
| 13 | any code modifications, using the version from luaext/lposix.c. | ||
| 14 | |||
| 15 | Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 16 | Upstream-Status: Accepted [https://github.com/rpm-software-management/rpm/pull/444] | ||
| 17 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> | ||
| 18 | --- | ||
| 19 | lib/rpmscript.c | 18 ++---------------- | ||
| 20 | luaext/lposix.c | 13 ++----------- | ||
| 21 | rpmio/rpmio.c | 16 ++++++++++++++++ | ||
| 22 | rpmio/rpmio_internal.h | 6 ++++++ | ||
| 23 | 4 files changed, 26 insertions(+), 27 deletions(-) | ||
| 24 | |||
| 25 | diff --git a/lib/rpmscript.c b/lib/rpmscript.c | ||
| 26 | index 747385a5b..b4ccd3246 100644 | ||
| 27 | --- a/lib/rpmscript.c | ||
| 28 | +++ b/lib/rpmscript.c | ||
| 29 | @@ -3,7 +3,6 @@ | ||
| 30 | #include <sys/types.h> | ||
| 31 | #include <sys/wait.h> | ||
| 32 | #include <errno.h> | ||
| 33 | -#include <unistd.h> | ||
| 34 | |||
| 35 | #include <rpm/rpmfileutil.h> | ||
| 36 | #include <rpm/rpmmacro.h> | ||
| 37 | @@ -14,6 +13,7 @@ | ||
| 38 | |||
| 39 | #include "rpmio/rpmlua.h" | ||
| 40 | #include "lib/rpmscript.h" | ||
| 41 | +#include "rpmio/rpmio_internal.h" | ||
| 42 | |||
| 43 | #include "lib/rpmplugins.h" /* rpm plugins hooks */ | ||
| 44 | |||
| 45 | @@ -170,26 +170,12 @@ static const char * const SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr | ||
| 46 | static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes, | ||
| 47 | FD_t scriptFd, FD_t out) | ||
| 48 | { | ||
| 49 | - int flag; | ||
| 50 | - int fdno; | ||
| 51 | int xx; | ||
| 52 | - int open_max; | ||
| 53 | |||
| 54 | /* SIGPIPE is ignored in rpm, reset to default for the scriptlet */ | ||
| 55 | (void) signal(SIGPIPE, SIG_DFL); | ||
| 56 | |||
| 57 | - /* XXX Force FD_CLOEXEC on all inherited fdno's. */ | ||
| 58 | - open_max = sysconf(_SC_OPEN_MAX); | ||
| 59 | - if (open_max == -1) { | ||
| 60 | - open_max = 1024; | ||
| 61 | - } | ||
| 62 | - for (fdno = 3; fdno < open_max; fdno++) { | ||
| 63 | - flag = fcntl(fdno, F_GETFD); | ||
| 64 | - if (flag == -1 || (flag & FD_CLOEXEC)) | ||
| 65 | - continue; | ||
| 66 | - xx = fcntl(fdno, F_SETFD, FD_CLOEXEC); | ||
| 67 | - /* XXX W2DO? debug msg for inheirited fdno w/o FD_CLOEXEC */ | ||
| 68 | - } | ||
| 69 | + rpmSetCloseOnExec(); | ||
| 70 | |||
| 71 | if (scriptFd != NULL) { | ||
| 72 | int sfdno = Fileno(scriptFd); | ||
| 73 | diff --git a/luaext/lposix.c b/luaext/lposix.c | ||
| 74 | index 0a7c26c71..5d7ad3c87 100644 | ||
| 75 | --- a/luaext/lposix.c | ||
| 76 | +++ b/luaext/lposix.c | ||
| 77 | @@ -27,6 +27,7 @@ | ||
| 78 | #include <unistd.h> | ||
| 79 | #include <utime.h> | ||
| 80 | #include <rpm/rpmutil.h> | ||
| 81 | +#include "rpmio/rpmio_internal.h" | ||
| 82 | |||
| 83 | #define MYNAME "posix" | ||
| 84 | #define MYVERSION MYNAME " library for " LUA_VERSION " / Nov 2003" | ||
| 85 | @@ -335,21 +336,11 @@ static int Pexec(lua_State *L) /** exec(path,[args]) */ | ||
| 86 | const char *path = luaL_checkstring(L, 1); | ||
| 87 | int i,n=lua_gettop(L); | ||
| 88 | char **argv; | ||
| 89 | - int flag, fdno, open_max; | ||
| 90 | |||
| 91 | if (!have_forked) | ||
| 92 | return luaL_error(L, "exec not permitted in this context"); | ||
| 93 | |||
| 94 | - open_max = sysconf(_SC_OPEN_MAX); | ||
| 95 | - if (open_max == -1) { | ||
| 96 | - open_max = 1024; | ||
| 97 | - } | ||
| 98 | - for (fdno = 3; fdno < open_max; fdno++) { | ||
| 99 | - flag = fcntl(fdno, F_GETFD); | ||
| 100 | - if (flag == -1 || (flag & FD_CLOEXEC)) | ||
| 101 | - continue; | ||
| 102 | - fcntl(fdno, F_SETFD, FD_CLOEXEC); | ||
| 103 | - } | ||
| 104 | + rpmSetCloseOnExec(); | ||
| 105 | |||
| 106 | argv = malloc((n+1)*sizeof(char*)); | ||
| 107 | if (argv==NULL) return luaL_error(L,"not enough memory"); | ||
| 108 | diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c | ||
| 109 | index c7cbc32aa..ea111d2ec 100644 | ||
| 110 | --- a/rpmio/rpmio.c | ||
| 111 | +++ b/rpmio/rpmio.c | ||
| 112 | @@ -1759,3 +1759,19 @@ DIGEST_CTX fdDupDigest(FD_t fd, int id) | ||
| 113 | |||
| 114 | return ctx; | ||
| 115 | } | ||
| 116 | + | ||
| 117 | +void rpmSetCloseOnExec(void) | ||
| 118 | +{ | ||
| 119 | + int flag, fdno, open_max; | ||
| 120 | + | ||
| 121 | + open_max = sysconf(_SC_OPEN_MAX); | ||
| 122 | + if (open_max == -1) { | ||
| 123 | + open_max = 1024; | ||
| 124 | + } | ||
| 125 | + for (fdno = 3; fdno < open_max; fdno++) { | ||
| 126 | + flag = fcntl(fdno, F_GETFD); | ||
| 127 | + if (flag == -1 || (flag & FD_CLOEXEC)) | ||
| 128 | + continue; | ||
| 129 | + fcntl(fdno, F_SETFD, FD_CLOEXEC); | ||
| 130 | + } | ||
| 131 | +} | ||
| 132 | diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h | ||
| 133 | index fbed183b0..370cbdc75 100644 | ||
| 134 | --- a/rpmio/rpmio_internal.h | ||
| 135 | +++ b/rpmio/rpmio_internal.h | ||
| 136 | @@ -41,6 +41,12 @@ DIGEST_CTX fdDupDigest(FD_t fd, int id); | ||
| 137 | int rpmioSlurp(const char * fn, | ||
| 138 | uint8_t ** bp, ssize_t * blenp); | ||
| 139 | |||
| 140 | +/** | ||
| 141 | + * Set close-on-exec flag for all opened file descriptors, except | ||
| 142 | + * stdin/stdout/stderr. | ||
| 143 | + */ | ||
| 144 | +void rpmSetCloseOnExec(void); | ||
| 145 | + | ||
| 146 | #ifdef __cplusplus | ||
| 147 | } | ||
| 148 | #endif | ||
diff --git a/meta/recipes-devtools/rpm/files/0001-configure.ac-add-option-for-dbus.patch b/meta/recipes-devtools/rpm/files/0001-configure.ac-add-option-for-dbus.patch deleted file mode 100644 index dc71d9b18b..0000000000 --- a/meta/recipes-devtools/rpm/files/0001-configure.ac-add-option-for-dbus.patch +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 1 | From dfb422c744fdc1838afc40b8e1f161bb46093d92 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Chen Qi <Qi.Chen@windriver.com> | ||
| 3 | Date: Sun, 8 Apr 2018 12:06:42 +0800 | ||
| 4 | Subject: [PATCH] configure.ac: add option for dbus | ||
| 5 | |||
| 6 | Add option for dbus so that users could choose to build with dbus | ||
| 7 | or with no dbus. | ||
| 8 | |||
| 9 | Upstream-Status: Pending | ||
| 10 | |||
| 11 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
| 12 | --- | ||
| 13 | configure.ac | 11 +++++++---- | ||
| 14 | 1 file changed, 7 insertions(+), 4 deletions(-) | ||
| 15 | |||
| 16 | diff --git a/configure.ac b/configure.ac | ||
| 17 | index 4db15c7909..493f393d31 100644 | ||
| 18 | --- a/configure.ac | ||
| 19 | +++ b/configure.ac | ||
| 20 | @@ -976,12 +976,15 @@ AS_IF([test "$enable_plugins" = yes],[ | ||
| 21 | ]) | ||
| 22 | AM_CONDITIONAL(ENABLE_PLUGINS,[test "$enable_plugins" = yes]) | ||
| 23 | |||
| 24 | -with_dbus=no | ||
| 25 | -AS_IF([test "$enable_plugins" != no],[ | ||
| 26 | +AC_ARG_WITH([dbus], [AS_HELP_STRING([--with-dbus], [build with dbus support])], | ||
| 27 | + [], | ||
| 28 | + [with_dbus=yes]) | ||
| 29 | + | ||
| 30 | +AS_IF([test "$with_dbus" != no],[ | ||
| 31 | PKG_CHECK_MODULES([DBUS], | ||
| 32 | [dbus-1 >= 1.3], | ||
| 33 | - [AC_DEFINE(DBUS, 1, [Build with dbus support?]) with_dbus=yes], | ||
| 34 | - [with_dbus=no]) | ||
| 35 | + [AC_DEFINE(DBUS, 1, [Build with dbus support?])], | ||
| 36 | + [AC_MSG_ERROR([dbus not present (--without-dbus to disable)])]) | ||
| 37 | AC_SUBST(DBUS_CFLAGS) | ||
| 38 | AC_SUBST(DBUS_LIBS) | ||
| 39 | ]) | ||
| 40 | -- | ||
| 41 | 2.11.0 | ||
| 42 | |||
diff --git a/meta/recipes-devtools/rpm/files/0002-Optimize-rpmSetCloseOnExec.patch b/meta/recipes-devtools/rpm/files/0002-Optimize-rpmSetCloseOnExec.patch deleted file mode 100644 index a27f8e6237..0000000000 --- a/meta/recipes-devtools/rpm/files/0002-Optimize-rpmSetCloseOnExec.patch +++ /dev/null | |||
| @@ -1,100 +0,0 @@ | |||
| 1 | From 5e6f05cd8dad6c1ee6bd1e6e43f176976c9c3416 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 3 | Date: Tue, 29 May 2018 17:52:56 -0700 | ||
| 4 | Subject: [PATCH 2/3] Optimize rpmSetCloseOnExec | ||
| 5 | |||
| 6 | In case maximum number of open files limit is set too high, both | ||
| 7 | luaext/Pexec() and lib/doScriptExec() spend way too much time | ||
| 8 | trying to set FD_CLOEXEC flag for all those file descriptors, | ||
| 9 | resulting in severe increase of time it takes to execute say | ||
| 10 | rpm or dnf. | ||
| 11 | |||
| 12 | This becomes increasingly noticeable when running with e.g. under | ||
| 13 | Docker, the reason being: | ||
| 14 | |||
| 15 | > $ docker run fedora ulimit -n | ||
| 16 | > 1048576 | ||
| 17 | |||
| 18 | One obvious fix is to use procfs to get the actual list of opened fds | ||
| 19 | and iterate over it. My quick-n-dirty benchmark shows the /proc approach | ||
| 20 | is about 10x faster than iterating through a list of just 1024 fds, | ||
| 21 | so it's an improvement even for default ulimit values. | ||
| 22 | |||
| 23 | Note that the old method is still used in case /proc is not available. | ||
| 24 | |||
| 25 | While at it, | ||
| 26 | |||
| 27 | 1. fix the function by making sure we modify (rather than set) | ||
| 28 | the existing flags. As the only known flag is FD_CLOEXEC, | ||
| 29 | this change is currently purely aesthetical, but in case | ||
| 30 | other flags will appear it will become a real bug fix. | ||
| 31 | |||
| 32 | 2. get rid of magic number 3; use STDERR_FILENO | ||
| 33 | |||
| 34 | Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 35 | |||
| 36 | Fixes #444 | ||
| 37 | |||
| 38 | Upstream-Status: Accepted [https://github.com/rpm-software-management/rpm/pull/444] | ||
| 39 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> | ||
| 40 | --- | ||
| 41 | rpmio/rpmio.c | 43 ++++++++++++++++++++++++++++++++++--------- | ||
| 42 | 1 file changed, 34 insertions(+), 9 deletions(-) | ||
| 43 | |||
| 44 | diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c | ||
| 45 | index ea111d2ec..55351c221 100644 | ||
| 46 | --- a/rpmio/rpmio.c | ||
| 47 | +++ b/rpmio/rpmio.c | ||
| 48 | @@ -1760,18 +1760,43 @@ DIGEST_CTX fdDupDigest(FD_t fd, int id) | ||
| 49 | return ctx; | ||
| 50 | } | ||
| 51 | |||
| 52 | +static void set_cloexec(int fd) | ||
| 53 | +{ | ||
| 54 | + int flags = fcntl(fd, F_GETFD); | ||
| 55 | + | ||
| 56 | + if (flags == -1 || (flags & FD_CLOEXEC)) | ||
| 57 | + return; | ||
| 58 | + | ||
| 59 | + fcntl(fd, F_SETFD, flags | FD_CLOEXEC); | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | void rpmSetCloseOnExec(void) | ||
| 63 | { | ||
| 64 | - int flag, fdno, open_max; | ||
| 65 | + const int min_fd = STDERR_FILENO; /* don't touch stdin/out/err */ | ||
| 66 | + int fd; | ||
| 67 | + | ||
| 68 | + DIR *dir = opendir("/proc/self/fd"); | ||
| 69 | + if (dir == NULL) { /* /proc not available */ | ||
| 70 | + /* iterate over all possible fds, might be slow */ | ||
| 71 | + int open_max = sysconf(_SC_OPEN_MAX); | ||
| 72 | + if (open_max == -1) | ||
| 73 | + open_max = 1024; | ||
| 74 | |||
| 75 | - open_max = sysconf(_SC_OPEN_MAX); | ||
| 76 | - if (open_max == -1) { | ||
| 77 | - open_max = 1024; | ||
| 78 | + for (fd = min_fd + 1; fd < open_max; fd++) | ||
| 79 | + set_cloexec(fd); | ||
| 80 | + | ||
| 81 | + return; | ||
| 82 | } | ||
| 83 | - for (fdno = 3; fdno < open_max; fdno++) { | ||
| 84 | - flag = fcntl(fdno, F_GETFD); | ||
| 85 | - if (flag == -1 || (flag & FD_CLOEXEC)) | ||
| 86 | - continue; | ||
| 87 | - fcntl(fdno, F_SETFD, FD_CLOEXEC); | ||
| 88 | + | ||
| 89 | + /* iterate over fds obtained from /proc */ | ||
| 90 | + struct dirent *entry; | ||
| 91 | + while ((entry = readdir(dir)) != NULL) { | ||
| 92 | + fd = atoi(entry->d_name); | ||
| 93 | + if (fd > min_fd) | ||
| 94 | + set_cloexec(fd); | ||
| 95 | } | ||
| 96 | + | ||
| 97 | + closedir(dir); | ||
| 98 | + | ||
| 99 | + return; | ||
| 100 | } | ||
diff --git a/meta/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch b/meta/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch deleted file mode 100644 index 389b41b42c..0000000000 --- a/meta/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | From 307e28b4cb08b05bc044482058eeebc9f59bb9a9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 3 | Date: Tue, 29 May 2018 18:09:27 -0700 | ||
| 4 | Subject: [PATCH 3/3] rpmSetCloseOnExec: use getrlimit() | ||
| 5 | |||
| 6 | In case /proc is not available to get the actual list of opened fds, | ||
| 7 | we fall back to iterating through the list of all possible fds. | ||
| 8 | |||
| 9 | It is possible that during the course of the program execution the limit | ||
| 10 | on number of open file descriptors might be lowered, so using the | ||
| 11 | current limit, as returned by sysconf(_SC_OPEN_MAX), might omit some | ||
| 12 | fds. Therefore, it is better to use rlim_max from the structure | ||
| 13 | filled in by gertlimit(RLIMIT_NOFILE) to make sure we're checking | ||
| 14 | all fds. | ||
| 15 | |||
| 16 | This slows down the function, but only in the case /proc is not | ||
| 17 | available, which should be rare in practice. | ||
| 18 | |||
| 19 | Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> | ||
| 20 | Upstream-Status: Accepted [https://github.com/rpm-software-management/rpm/pull/444] | ||
| 21 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> | ||
| 22 | --- | ||
| 23 | rpmio/rpmio.c | 10 +++++++++- | ||
| 24 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
| 25 | |||
| 26 | diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c | ||
| 27 | index 55351c221..e051c9863 100644 | ||
| 28 | --- a/rpmio/rpmio.c | ||
| 29 | +++ b/rpmio/rpmio.c | ||
| 30 | @@ -10,6 +10,7 @@ | ||
| 31 | #include <sys/personality.h> | ||
| 32 | #endif | ||
| 33 | #include <sys/utsname.h> | ||
| 34 | +#include <sys/resource.h> | ||
| 35 | |||
| 36 | #include <rpm/rpmlog.h> | ||
| 37 | #include <rpm/rpmmacro.h> | ||
| 38 | @@ -1778,7 +1779,14 @@ void rpmSetCloseOnExec(void) | ||
| 39 | DIR *dir = opendir("/proc/self/fd"); | ||
| 40 | if (dir == NULL) { /* /proc not available */ | ||
| 41 | /* iterate over all possible fds, might be slow */ | ||
| 42 | - int open_max = sysconf(_SC_OPEN_MAX); | ||
| 43 | + struct rlimit rl; | ||
| 44 | + int open_max; | ||
| 45 | + | ||
| 46 | + if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY) | ||
| 47 | + open_max = rl.rlim_max; | ||
| 48 | + else | ||
| 49 | + open_max = sysconf(_SC_OPEN_MAX); | ||
| 50 | + | ||
| 51 | if (open_max == -1) | ||
| 52 | open_max = 1024; | ||
| 53 | |||
diff --git a/meta/recipes-devtools/rpm/files/0004-build-pack.c-remove-static-local-variables-from-buil.patch b/meta/recipes-devtools/rpm/files/0004-build-pack.c-remove-static-local-variables-from-buil.patch index 8989dcebd1..652e30b3e4 100644 --- a/meta/recipes-devtools/rpm/files/0004-build-pack.c-remove-static-local-variables-from-buil.patch +++ b/meta/recipes-devtools/rpm/files/0004-build-pack.c-remove-static-local-variables-from-buil.patch | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | From 8ce9fbab2990609bdace457e146160334e931c89 Mon Sep 17 00:00:00 2001 | 1 | From 792693bb90768cfde4898e8dd31ee1b5de803d2f Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Thu, 8 Jun 2017 17:08:09 +0300 | 3 | Date: Thu, 8 Jun 2017 17:08:09 +0300 |
| 4 | Subject: [PATCH 14/15] build/pack.c: remove static local variables from | 4 | Subject: [PATCH] build/pack.c: remove static local variables from buildHost() |
| 5 | buildHost() and getBuildTime() | 5 | and getBuildTime() |
| 6 | 6 | ||
| 7 | Their use is causing difficult to diagnoze data races when building multiple | 7 | Their use is causing difficult to diagnoze data races when building multiple |
| 8 | packages in parallel, and is a bad idea in general, as it also makes it more | 8 | packages in parallel, and is a bad idea in general, as it also makes it more |
| @@ -20,7 +20,7 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | |||
| 20 | 3 files changed, 74 insertions(+), 72 deletions(-) | 20 | 3 files changed, 74 insertions(+), 72 deletions(-) |
| 21 | 21 | ||
| 22 | diff --git a/build/build.c b/build/build.c | 22 | diff --git a/build/build.c b/build/build.c |
| 23 | index 81152e53e..6001f9e52 100644 | 23 | index 13c3df2..b154f08 100644 |
| 24 | --- a/build/build.c | 24 | --- a/build/build.c |
| 25 | +++ b/build/build.c | 25 | +++ b/build/build.c |
| 26 | @@ -6,6 +6,8 @@ | 26 | @@ -6,6 +6,8 @@ |
| @@ -99,7 +99,7 @@ index 81152e53e..6001f9e52 100644 | |||
| 99 | if (((what & RPMBUILD_PACKAGESOURCE) && !test) && | 99 | if (((what & RPMBUILD_PACKAGESOURCE) && !test) && |
| 100 | - (rc = packageSources(spec, &cookie))) | 100 | - (rc = packageSources(spec, &cookie))) |
| 101 | + (rc = packageSources(spec, &cookie, buildTime, host))) | 101 | + (rc = packageSources(spec, &cookie, buildTime, host))) |
| 102 | return rc; | 102 | goto exit; |
| 103 | 103 | ||
| 104 | if (((what & RPMBUILD_PACKAGEBINARY) && !test) && | 104 | if (((what & RPMBUILD_PACKAGEBINARY) && !test) && |
| 105 | - (rc = packageBinaries(spec, cookie, (didBuild == 0)))) | 105 | - (rc = packageBinaries(spec, cookie, (didBuild == 0)))) |
| @@ -116,7 +116,7 @@ index 81152e53e..6001f9e52 100644 | |||
| 116 | spec->rootDir = NULL; | 116 | spec->rootDir = NULL; |
| 117 | if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) { | 117 | if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) { |
| 118 | diff --git a/build/pack.c b/build/pack.c | 118 | diff --git a/build/pack.c b/build/pack.c |
| 119 | index df15876ff..17a4b0905 100644 | 119 | index df15876..17a4b09 100644 |
| 120 | --- a/build/pack.c | 120 | --- a/build/pack.c |
| 121 | +++ b/build/pack.c | 121 | +++ b/build/pack.c |
| 122 | @@ -6,8 +6,6 @@ | 122 | @@ -6,8 +6,6 @@ |
| @@ -305,7 +305,7 @@ index df15876ff..17a4b0905 100644 | |||
| 305 | /* Do check SRPM package if enabled */ | 305 | /* Do check SRPM package if enabled */ |
| 306 | if (rc == RPMRC_OK && pkgcheck[0] != ' ') { | 306 | if (rc == RPMRC_OK && pkgcheck[0] != ' ') { |
| 307 | diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h | 307 | diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h |
| 308 | index 439b7d3b5..07e8338ad 100644 | 308 | index 439b7d3..07e8338 100644 |
| 309 | --- a/build/rpmbuild_internal.h | 309 | --- a/build/rpmbuild_internal.h |
| 310 | +++ b/build/rpmbuild_internal.h | 310 | +++ b/build/rpmbuild_internal.h |
| 311 | @@ -427,19 +427,23 @@ rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags); | 311 | @@ -427,19 +427,23 @@ rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags); |
| @@ -334,6 +334,3 @@ index 439b7d3b5..07e8338ad 100644 | |||
| 334 | 334 | ||
| 335 | RPM_GNUC_INTERNAL | 335 | RPM_GNUC_INTERNAL |
| 336 | int addLangTag(rpmSpec spec, Header h, rpmTagVal tag, | 336 | int addLangTag(rpmSpec spec, Header h, rpmTagVal tag, |
| 337 | -- | ||
| 338 | 2.14.2 | ||
| 339 | |||
diff --git a/meta/recipes-devtools/rpm/rpm_4.14.1.bb b/meta/recipes-devtools/rpm/rpm_4.14.2.bb index e5e87d3903..46f88375ff 100644 --- a/meta/recipes-devtools/rpm/rpm_4.14.1.bb +++ b/meta/recipes-devtools/rpm/rpm_4.14.2.bb | |||
| @@ -39,14 +39,10 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.14.x \ | |||
| 39 | file://0003-rpmstrpool.c-make-operations-over-string-pools-threa.patch \ | 39 | file://0003-rpmstrpool.c-make-operations-over-string-pools-threa.patch \ |
| 40 | file://0004-build-pack.c-remove-static-local-variables-from-buil.patch \ | 40 | file://0004-build-pack.c-remove-static-local-variables-from-buil.patch \ |
| 41 | file://0001-perl-disable-auto-reqs.patch \ | 41 | file://0001-perl-disable-auto-reqs.patch \ |
| 42 | file://0001-configure.ac-add-option-for-dbus.patch \ | ||
| 43 | file://0001-Factor-out-and-unify-setting-CLOEXEC.patch \ | ||
| 44 | file://0002-Optimize-rpmSetCloseOnExec.patch \ | ||
| 45 | file://0003-rpmSetCloseOnExec-use-getrlimit.patch \ | ||
| 46 | " | 42 | " |
| 47 | 43 | ||
| 48 | PE = "1" | 44 | PE = "1" |
| 49 | SRCREV = "bfee1410af51c1cc9724791fb8d985260a62102b" | 45 | SRCREV = "753f6941dc32e94047b7cfe713ddd604a810b4db" |
| 50 | 46 | ||
| 51 | S = "${WORKDIR}/git" | 47 | S = "${WORKDIR}/git" |
| 52 | 48 | ||
| @@ -68,8 +64,8 @@ EXTRA_OECONF_append_libc-musl = " --disable-nls" | |||
| 68 | # | 64 | # |
| 69 | # Disable dbus for native, so that rpm doesn't attempt to inhibit shutdown via session dbus even when plugins support is enabled. | 65 | # Disable dbus for native, so that rpm doesn't attempt to inhibit shutdown via session dbus even when plugins support is enabled. |
| 70 | # Also disable plugins by default for native. | 66 | # Also disable plugins by default for native. |
| 71 | EXTRA_OECONF_append_class-native = " --sysconfdir=/etc --localstatedir=/var --without-dbus --disable-plugins" | 67 | EXTRA_OECONF_append_class-native = " --sysconfdir=/etc --localstatedir=/var --disable-plugins" |
| 72 | EXTRA_OECONF_append_class-nativesdk = " --sysconfdir=/etc --localstatedir=/var --without-dbus --disable-plugins" | 68 | EXTRA_OECONF_append_class-nativesdk = " --sysconfdir=/etc --localstatedir=/var --disable-plugins" |
| 73 | 69 | ||
| 74 | BBCLASSEXTEND = "native nativesdk" | 70 | BBCLASSEXTEND = "native nativesdk" |
| 75 | 71 | ||
