summaryrefslogtreecommitdiff
path: root/lib/rpmscript.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-04-19 13:21:36 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-04-19 13:21:36 +0300
commit7ea4fcd87f9f313099f983380e9ece93149a0271 (patch)
tree11289057ad8070f99f19ca9dea17d5327d43d85d /lib/rpmscript.c
parentb2abe4957871bb07e3895c5331d667d843494737 (diff)
downloadlibrpm-tizen-7ea4fcd87f9f313099f983380e9ece93149a0271.tar.gz
librpm-tizen-7ea4fcd87f9f313099f983380e9ece93149a0271.tar.bz2
librpm-tizen-7ea4fcd87f9f313099f983380e9ece93149a0271.zip
Give at least some indication of error from fchdir() failures
- Failure to return to current dir is likely to be lethal, at least log an error and return a different code for it.
Diffstat (limited to 'lib/rpmscript.c')
-rw-r--r--lib/rpmscript.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
index 55688214b..905d1cf2e 100644
--- a/lib/rpmscript.c
+++ b/lib/rpmscript.c
@@ -58,15 +58,17 @@ static rpmRC runLuaScript(int selinux, ARGV_const_t prefixes,
/* XXX TODO: use cwd from chroot state to save unnecessary open here */
cwd = open(".", O_RDONLY);
if (cwd != -1) {
- int xx;
mode_t oldmask = umask(0);
umask(oldmask);
if (chdir("/") == 0 && rpmluaRunScript(lua, script, sname) == 0) {
rc = RPMRC_OK;
}
- /* XXX no way to return error from restore meaningfully atm */
- xx = fchdir(cwd);
+ /* This failing would be fatal, return something different for it... */
+ if (fchdir(cwd)) {
+ rpmlog(RPMLOG_ERR, _("Unable to restore current directory: %m"));
+ rc = RPMRC_NOTFOUND;
+ }
close(cwd);
umask(oldmask);
}