From: Panu Matilainen Date: Tue, 19 Apr 2011 10:21:36 +0000 (+0300) Subject: Give at least some indication of error from fchdir() failures X-Git-Tag: tznext/4.11.0.1.tizen20130304~1194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ea4fcd87f9f313099f983380e9ece93149a0271;p=tools%2Flibrpm-tizen.git 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. --- diff --git a/lib/rpmscript.c b/lib/rpmscript.c index 5568821..905d1cf 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); }