mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 09:49:35 +02:00
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@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
901e632a49
commit
5dba35767e
@@ -5,32 +5,10 @@ Upstream-Status: Inappropriate [debugging]
|
|||||||
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
|
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
|
||||||
|
|
||||||
diff --git a/rpmdb/signature.c b/rpmdb/signature.c
|
diff --git a/rpmdb/signature.c b/rpmdb/signature.c
|
||||||
index dce6c4e..a1d0f06 100644
|
index 100204b..e56ab3d 100644
|
||||||
--- a/rpmdb/signature.c
|
--- a/rpmdb/signature.c
|
||||||
+++ b/rpmdb/signature.c
|
+++ b/rpmdb/signature.c
|
||||||
@@ -37,6 +37,7 @@ int rpmTempFile(const char * prefix, const char ** fnptr, void * fdptr)
|
@@ -72,12 +72,16 @@ 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)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
temput = urlPath(tempfn, &tfn);
|
temput = urlPath(tempfn, &tfn);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
rpmdb: prevent race in tmpdir creation
|
||||||
|
|
||||||
|
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@linux.intel.com>
|
||||||
|
|
||||||
|
diff --git a/rpmdb/signature.c b/rpmdb/signature.c
|
||||||
|
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)
|
||||||
|
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 && ret != EEXIST) {
|
||||||
|
+ rpmlog(RPMLOG_ERR, _("error creating temporary directory %s: %d\n"), tempfn, ret);
|
||||||
|
+ goto errxit;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX should probably use mkstemp here */
|
||||||
|
--
|
||||||
|
2.6.6
|
||||||
|
|
||||||
@@ -154,6 +154,7 @@ SRC_URI += " \
|
|||||||
file://rpm-rpmdb-grammar.patch \
|
file://rpm-rpmdb-grammar.patch \
|
||||||
file://rpm-disable-blaketest.patch \
|
file://rpm-disable-blaketest.patch \
|
||||||
file://rpm-autogen-force.patch \
|
file://rpm-autogen-force.patch \
|
||||||
|
file://rpmdb-prevent-race-in-tmpdir-creation.patch \
|
||||||
file://rpmdb-more-verbose-error-logging-in-rpmTempFile.patch \
|
file://rpmdb-more-verbose-error-logging-in-rpmTempFile.patch \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user