Do not clean "/" in pkgAcquire::Clean/pkgArchiveCleaner
authorMichael Vogt <mvo@debian.org>
Tue, 8 Jul 2014 09:27:01 +0000 (11:27 +0200)
committerMichael Vogt <mvo@debian.org>
Tue, 8 Jul 2014 09:27:01 +0000 (11:27 +0200)
Having "/" here is most likely a user configuration error and
may cause removal of import symlinks like /vmlinuz

Closes: #753531

apt-pkg/acquire.cc
apt-pkg/clean.cc

index a187a00..057bc24 100644 (file)
@@ -486,6 +486,9 @@ bool pkgAcquire::Clean(string Dir)
    if (DirectoryExists(Dir) == false)
       return true;
 
+   if(Dir == "/")
+      return _error->Error(_("Clean of %s is not supported"), Dir.c_str());
+
    DIR *D = opendir(Dir.c_str());   
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
index 0ee3b76..37128e9 100644 (file)
 bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
 {
    bool CleanInstalled = _config->FindB("APT::Clean-Installed",true);
-      
+
+   if(Dir == "/")
+      return _error->Error(_("Clean of %s is not supported"), Dir.c_str());
+
    DIR *D = opendir(Dir.c_str());
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());