[oe-commits] [openembedded-core] 15/37: rpm: prevent race in tempdir creation
git at git.openembedded.org
git at git.openembedded.org
Tue Nov 8 23:48:01 UTC 2016
rpurdie pushed a commit to branch krogoth
in repository openembedded-core.
commit 1ae228ee5181f12955356c1fe10d341373dd5fcc
Author: Markus Lehtonen <markus.lehtonen at linux.intel.com>
AuthorDate: Fri Oct 14 13:41:26 2016 +0300
rpm: prevent race in tempdir creation
This patch fixes an extramely rare race condition in creation of rpmdb
temporary directory. The "rpmdb-more-verbose-error-logging" patch is
still left in place, just for the case.
[YOCTO #9416]
(From OE-Core rev: 84de3283fa2a2908d367eb58953903ae685b0298)
Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808 at gmail.com>
---
...more-verbose-error-logging-in-rpmTempFile.patch | 26 ++----------------
...=> rpmdb-prevent-race-in-tmpdir-creation.patch} | 32 +++++++---------------
meta/recipes-devtools/rpm/rpm_5.4.16.bb | 1 +
3 files changed, 13 insertions(+), 46 deletions(-)
diff --git a/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch b/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch
index 809e54e..3a6f874 100644
--- a/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch
+++ b/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch
@@ -5,32 +5,10 @@ Upstream-Status: Inappropriate [debugging]
Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
diff --git a/rpmdb/signature.c b/rpmdb/signature.c
-index dce6c4e..a1d0f06 100644
+index 100204b..e56ab3d 100644
--- a/rpmdb/signature.c
+++ b/rpmdb/signature.c
-@@ -37,6 +37,7 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
- int temput;
- FD_t fd = NULL;
- unsigned int ran;
-+ int ret = 0;
-
- if (!prefix) prefix = "";
-
-@@ -44,8 +45,11 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
- if (!_initialized) {
- _initialized = 1;
- tempfn = rpmGenPath(prefix, tpmacro, NULL);
-- if (rpmioMkpath(tempfn, 0755, (uid_t) -1, (gid_t) -1))
-- goto errxit;
-+ ret = rpmioMkpath(tempfn, 0755, (uid_t) -1, (gid_t) -1);
-+ if (ret) {
-+ rpmlog(RPMLOG_ERR, _("error creating temporary directory %s: %d\n"), tempfn, ret);
-+ goto errxit;
-+ }
- }
-
- /* XXX should probably use mkstemp here */
-@@ -68,12 +72,16 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
+@@ -72,12 +72,16 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
#endif
temput = urlPath(tempfn, &tfn);
diff --git a/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch b/meta/recipes-devtools/rpm/rpm/rpmdb-prevent-race-in-tmpdir-creation.patch
similarity index 54%
copy from meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch
copy to meta/recipes-devtools/rpm/rpm/rpmdb-prevent-race-in-tmpdir-creation.patch
index 809e54e..f483f3a 100644
--- a/meta/recipes-devtools/rpm/rpm/rpmdb-more-verbose-error-logging-in-rpmTempFile.patch
+++ b/meta/recipes-devtools/rpm/rpm/rpmdb-prevent-race-in-tmpdir-creation.patch
@@ -1,11 +1,17 @@
-rpmdb: more verbose error logging in rpmTempFile()
+rpmdb: prevent race in tmpdir creation
-Upstream-Status: Inappropriate [debugging]
+If two (or more) instances of rpm are running at the same time they may
+be trying to create the same (base-)temporary directory at the same time
+which causes the other mkdir to fail with EEXIST. This patch prevents a
+failure caused by this race by ignoring EEXIST error on directory
+creation.
+
+Upstream-Status: Pending
Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
diff --git a/rpmdb/signature.c b/rpmdb/signature.c
-index dce6c4e..a1d0f06 100644
+index dce6c4e..100204b 100644
--- a/rpmdb/signature.c
+++ b/rpmdb/signature.c
@@ -37,6 +37,7 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
@@ -23,31 +29,13 @@ index dce6c4e..a1d0f06 100644
- if (rpmioMkpath(tempfn, 0755, (uid_t) -1, (gid_t) -1))
- goto errxit;
+ ret = rpmioMkpath(tempfn, 0755, (uid_t) -1, (gid_t) -1);
-+ if (ret) {
++ if (ret && ret != EEXIST) {
+ rpmlog(RPMLOG_ERR, _("error creating temporary directory %s: %d\n"), tempfn, ret);
+ goto errxit;
+ }
}
/* XXX should probably use mkstemp here */
-@@ -68,12 +72,16 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
- #endif
-
- temput = urlPath(tempfn, &tfn);
-- if (*tfn == '\0') goto errxit;
-+ if (*tfn == '\0') {
-+ rpmlog(RPMLOG_ERR, _("error creating tempfile: empty filename\n"));
-+ goto errxit;
-+ }
-
- switch (temput) {
- case URL_IS_DASH:
- case URL_IS_HKP:
- case URL_IS_MONGO: /* XXX FIXME */
-+ rpmlog(RPMLOG_ERR, _("error creating temporary file, invalid uri type: %d\n"), temput);
- goto errxit;
- /*@notreached@*/ /*@switchbreak@*/ break;
- case URL_IS_HTTPS:
--
2.6.6
diff --git a/meta/recipes-devtools/rpm/rpm_5.4.16.bb b/meta/recipes-devtools/rpm/rpm_5.4.16.bb
index 71ebace..eb2d4f9 100644
--- a/meta/recipes-devtools/rpm/rpm_5.4.16.bb
+++ b/meta/recipes-devtools/rpm/rpm_5.4.16.bb
@@ -154,6 +154,7 @@ SRC_URI += " \
file://rpm-rpmdb-grammar.patch \
file://rpm-disable-blaketest.patch \
file://rpm-autogen-force.patch \
+ file://rpmdb-prevent-race-in-tmpdir-creation.patch \
file://rpmdb-more-verbose-error-logging-in-rpmTempFile.patch \
"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list