From 465841e8501762b36899b6f31b47968efbe74538 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 18 Dec 2008 10:01:01 +0200 Subject: [PATCH] Check chroot() result in psm too (Pixel) - bail out early if it fails instead of blindly continuing and potentially messing in real root (chroot can fail for priviledged user too) --- lib/psm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/psm.c b/lib/psm.c index 4d18c30..22bf74f 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -1256,6 +1256,7 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) /* Change root directory if requested and not already done. */ rc = rpmpsmNext(psm, PSM_CHROOT_IN); + if (rc) break; if (psm->goal == PSM_PKGINSTALL) { psm->scriptTag = RPMTAG_PREIN; @@ -1555,7 +1556,10 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) { xx = chdir("/"); if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') - rc = chroot(rootDir); + if (chroot(rootDir) == -1) { + rpmlog(RPMLOG_ERR, _("Unable to change root directory: %m\n")); + return -1; + } psm->chrootDone = 1; (void) rpmtsSetChrootDone(ts, 1); } -- 2.7.4