|
Panu Matilainen |
5430e2 |
commit 431afe5167675a89682eb7e07baa3a627ceb8770
|
|
Panu Matilainen |
5430e2 |
Author: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
5430e2 |
Date: Fri Jan 28 13:15:09 2011 +0200
|
|
Panu Matilainen |
5430e2 |
|
|
Panu Matilainen |
5430e2 |
Add an error message + comments on open(".") behavior (RhBug:672576)
|
|
Panu Matilainen |
5430e2 |
- Bail out early and complain if current directory can't be open()'ed,
|
|
Panu Matilainen |
5430e2 |
as we'll need it for reliable cwd restoration after running Lua
|
|
Panu Matilainen |
5430e2 |
scripts.
|
|
Panu Matilainen |
5430e2 |
- Technically we'd only need open(".") succeeding for chroot operations
|
|
Panu Matilainen |
5430e2 |
and running Lua-scripts, but there's no easy way to determine whether
|
|
Panu Matilainen |
5430e2 |
a transaction will run Lua-scripts. They could be in-db triggers
|
|
Panu Matilainen |
5430e2 |
which will only be evaluated in the middle of transaction, better
|
|
Panu Matilainen |
5430e2 |
to fail early for consistent behavior.
|
|
Panu Matilainen |
5430e2 |
(cherry picked from commit fbdfe8e5bf1ef7044de7a14cff9205c4d845f90b)
|
|
Panu Matilainen |
5430e2 |
|
|
Panu Matilainen |
5430e2 |
diff --git a/lib/rpmchroot.c b/lib/rpmchroot.c
|
|
Panu Matilainen |
5430e2 |
index e91be71..81bb5e5 100644
|
|
Panu Matilainen |
5430e2 |
--- a/lib/rpmchroot.c
|
|
Panu Matilainen |
5430e2 |
+++ b/lib/rpmchroot.c
|
|
Panu Matilainen |
5430e2 |
@@ -40,6 +40,7 @@ int rpmChrootSet(const char *rootDir)
|
|
Panu Matilainen |
5430e2 |
rootState.rootDir = rstrdup(rootDir);
|
|
Panu Matilainen |
5430e2 |
rootState.cwd = open(".", O_RDONLY);
|
|
Panu Matilainen |
5430e2 |
if (rootState.cwd < 0) {
|
|
Panu Matilainen |
5430e2 |
+ rpmlog(RPMLOG_ERR, _("Unable to open current directory: %m\n"));
|
|
Panu Matilainen |
5430e2 |
rc = -1;
|
|
Panu Matilainen |
5430e2 |
}
|
|
Panu Matilainen |
5430e2 |
}
|
|
Panu Matilainen |
5430e2 |
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
|
|
Panu Matilainen |
5430e2 |
index ed52608..3801873 100644
|
|
Panu Matilainen |
5430e2 |
--- a/lib/rpmscript.c
|
|
Panu Matilainen |
5430e2 |
+++ b/lib/rpmscript.c
|
|
Panu Matilainen |
5430e2 |
@@ -55,6 +55,7 @@ static rpmRC runLuaScript(int selinux, ARGV_const_t prefixes,
|
|
Panu Matilainen |
5430e2 |
rpmluaPop(lua);
|
|
Panu Matilainen |
5430e2 |
|
|
Panu Matilainen |
5430e2 |
/* Lua scripts can change our cwd and umask, save and restore */
|
|
Panu Matilainen |
5430e2 |
+ /* XXX TODO: use cwd from chroot state to save unnecessary open here */
|
|
Panu Matilainen |
5430e2 |
cwd = open(".", O_RDONLY);
|
|
Panu Matilainen |
5430e2 |
if (cwd != -1) {
|
|
Panu Matilainen |
5430e2 |
int xx;
|
|
Panu Matilainen |
5430e2 |
diff --git a/lib/transaction.c b/lib/transaction.c
|
|
Panu Matilainen |
5430e2 |
index 06e54af..628e4ea 100644
|
|
Panu Matilainen |
5430e2 |
--- a/lib/transaction.c
|
|
Panu Matilainen |
5430e2 |
+++ b/lib/transaction.c
|
|
Panu Matilainen |
5430e2 |
@@ -1260,7 +1260,12 @@ static int rpmtsSetup(rpmts ts, rpmprobFilterFlags ignoreSet)
|
|
Panu Matilainen |
5430e2 |
rpmtsSELabelInit(ts, selinux_file_context_path());
|
|
Panu Matilainen |
5430e2 |
}
|
|
Panu Matilainen |
5430e2 |
|
|
Panu Matilainen |
5430e2 |
- /* XXX Make sure the database is open RDWR for package install/erase. */
|
|
Panu Matilainen |
5430e2 |
+ /*
|
|
Panu Matilainen |
5430e2 |
+ * Make sure the database is open RDWR for package install/erase.
|
|
Panu Matilainen |
5430e2 |
+ * Note that we initialize chroot state here even if it's just "/" as
|
|
Panu Matilainen |
5430e2 |
+ * this ensures we can successfully perform open(".") which is
|
|
Panu Matilainen |
5430e2 |
+ * required to reliably restore cwd after Lua scripts.
|
|
Panu Matilainen |
5430e2 |
+ */
|
|
Panu Matilainen |
5430e2 |
if (rpmtsOpenDB(ts, dbmode) || rpmChrootSet(rpmtsRootDir(ts)))
|
|
Panu Matilainen |
5430e2 |
return -1;
|
|
Panu Matilainen |
5430e2 |
|