summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-08-22 22:30:20 +0200
committerMichael Vogt <mvo@debian.org>2013-08-22 22:30:20 +0200
commit2510eea4a0922b7b6da8099deb70ca87851633ce (patch)
tree4a5c22eb4e0d3747e3da267c42c100606ad863aa
parent0644bed3baac08bbfb495dcfe60c3bbb6f8fbd02 (diff)
do chdir("/") after chroot()
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/tagfile.cc2
-rw-r--r--cmdline/apt-mark.cc4
3 files changed, 4 insertions, 4 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index e32e553a4..4f9b84e00 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -392,7 +392,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
dup2(nullfd, STDIN_FILENO);
dup2(external[1], STDOUT_FILENO);
dup2(nullfd, STDERR_FILENO);
- if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0)
+ if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0)
_error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str());
execvp(Args[0], (char**) &Args[0]);
_error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!");
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 868adf3d2..b91e868e2 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -237,7 +237,7 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset)
// ---------------------------------------------------------------------
/* */
pkgTagSection::pkgTagSection()
- : Section(0), TagCount(0), Stop(0), d(NULL)
+ : Section(0), TagCount(0), d(NULL), Stop(0)
{
memset(&Indexes, 0, sizeof(Indexes));
memset(&AlphaIndexes, 0, sizeof(AlphaIndexes));
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index eb3410be1..ebb1f9892 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -209,7 +209,7 @@ bool DoHold(CommandLine &CmdL)
dup2(nullfd, STDIN_FILENO);
dup2(nullfd, STDOUT_FILENO);
dup2(nullfd, STDERR_FILENO);
- if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0)
+ if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0)
_error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --assert-multi-arch", chrootDir.c_str());
execvp(Args[0], (char**) &Args[0]);
_error->WarningE("dpkgGo", "Can't detect if dpkg supports multi-arch!");
@@ -279,7 +279,7 @@ bool DoHold(CommandLine &CmdL)
{
close(external[1]);
std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory");
- if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0)
+ if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0)
_error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --set-selections", chrootDir.c_str());
int const nullfd = open("/dev/null", O_RDONLY);
dup2(external[0], STDIN_FILENO);