Sophie

Sophie

distrib > Mandriva > 2007.1 > i586 > by-pkgid > 2e20fbe220a1d0f48a15d5008a7dd680 > files > 18

rpm-4.4.6-22.1mdv2007.1.src.rpm

--- rpm-4.4.6/lib/transaction.c.pix	2007-01-08 12:38:41.000000000 +0100
+++ rpm-4.4.6/lib/transaction.c	2007-01-08 13:20:01.000000000 +0100
@@ -2049,8 +2049,18 @@
 	const char * rootDir = rpmtsRootDir(ts);
 	xx = chdir("/");
 	/*@-superuser -noeffect @*/
-	if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
+	if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') {
 	    xx = chroot(rootDir);
+	    if (xx != 0) {
+	      int err = errno;
+	      struct stat st;
+	      if (Stat(rootDir, &st) >= 0 && S_ISDIR(st.st_mode))
+		rpmlog(RPMLOG_CRIT, _("only superuser is allowed to use --root\n"));
+	      else 
+		rpmlog(RPMLOG_CRIT, _("chroot failed, %s: %s\n"), rootDir, strerror(err));
+	      abort();
+	    }
+	}
 	/*@=superuser =noeffect @*/
 	(void) rpmtsSetChrootDone(ts, 1);
     }