Procházet zdrojové kódy

Do not clean "/" in pkgAcquire::Clean/pkgArchiveCleaner

Having "/" here is most likely a user configuration error and
may cause removal of import symlinks like /vmlinuz

Closes: #753531
Michael Vogt před 12 roky
rodič
revize
10ecfe4f8a
2 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 3 0
      apt-pkg/acquire.cc
  2. 4 1
      apt-pkg/clean.cc

+ 3 - 0
apt-pkg/acquire.cc

@@ -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());

+ 4 - 1
apt-pkg/clean.cc

@@ -34,7 +34,10 @@
 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());