]> git.saurik.com Git - apt.git/commitdiff
ignore non-regular files in GetListOfFilesInDir (Closes: #594694)
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 13 Jan 2011 22:22:17 +0000 (23:22 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 13 Jan 2011 22:22:17 +0000 (23:22 +0100)
apt-pkg/contrib/fileutl.cc
debian/changelog
test/libapt/run-tests

index db6057ea3ff6a975cf8a2555d38e499dcdc40406..52f517ee07784ca2578e445b3041a8679a48ef1e 100644 (file)
@@ -336,6 +336,20 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
       if (Ent->d_name[0] == '.')
         continue;
 
+      // Make sure it is a file and not something else
+      string const File = flCombine(Dir,Ent->d_name);
+#ifdef _DIRENT_HAVE_D_TYPE
+      if (Ent->d_type != DT_REG)
+#endif
+      {
+        if (RealFileExists(File.c_str()) == false)
+        {
+           if (SilentIgnore.Match(Ent->d_name) == false)
+              _error->Notice(_("Ignoring '%s' in directory '%s' as it is not a regular file"), Ent->d_name, Dir.c_str());
+           continue;
+        }
+      }
+
       // check for accepted extension:
       // no extension given -> periods are bad as hell!
       // extensions given -> "" extension allows no extension
@@ -349,7 +363,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
               if (Debug == true)
                  std::clog << "Bad file: " << Ent->d_name << " → no extension" << std::endl;
               if (SilentIgnore.Match(Ent->d_name) == false)
-                 _error->Notice("Ignoring file '%s' in directory '%s' as it has no filename extension", Ent->d_name, Dir.c_str());
+                 _error->Notice(_("Ignoring file '%s' in directory '%s' as it has no filename extension"), Ent->d_name, Dir.c_str());
               continue;
            }
         }
@@ -358,7 +372,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
            if (Debug == true)
               std::clog << "Bad file: " << Ent->d_name << " → bad extension »" << flExtension(Ent->d_name) << "«" << std::endl;
            if (SilentIgnore.Match(Ent->d_name) == false)
-              _error->Notice("Ignoring file '%s' in directory '%s' as it has an invalid filename extension", Ent->d_name, Dir.c_str());
+              _error->Notice(_("Ignoring file '%s' in directory '%s' as it has an invalid filename extension"), Ent->d_name, Dir.c_str());
            continue;
         }
       }
@@ -391,16 +405,6 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
         continue;
       }
 
-      // Make sure it is a file and not something else
-      string const File = flCombine(Dir,Ent->d_name);
-      struct stat St;
-      if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
-      {
-        if (Debug == true)
-           std::clog << "Bad file: " << Ent->d_name << " → stat says not a good file" << std::endl;
-        continue;
-      }
-
       if (Debug == true)
         std::clog << "Accept file: " << Ent->d_name << " in " << Dir << std::endl;
       List.push_back(File);
index febd259c0b16913fc41097ba176b3680a1d45fc2..ca5d4f235ca224ae0804b03c4cb9d23818f2183c 100644 (file)
@@ -20,6 +20,7 @@ apt (0.8.11+wheezy) unstable; urgency=low
   * apt-pkg/contrib/fileutl.cc:
     - add a RealFileExists method and check that your configuration files
       are real files to avoid endless loops if not (Closes: #604401)
+    - ignore non-regular files in GetListOfFilesInDir (Closes: #594694)
   * apt-pkg/contrib/weakptr.h:
     - include stddefs.h to fix compile error (undefined NULL) with gcc-4.6
   * methods/https.cc:
@@ -35,7 +36,7 @@ apt (0.8.11+wheezy) unstable; urgency=low
   * apt-pkg/cacheiterator.h:
     - do not segfault if cache is not build (Closes: #254770)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 13 Jan 2011 17:10:36 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 13 Jan 2011 23:19:03 +0100
 
 apt (0.8.10) unstable; urgency=low
 
index f5fc0344642b00b2159d953ce00503431d6817a3..a66de386d1cce88ef8d1eee2f35b2013ee76192f 100755 (executable)
@@ -39,6 +39,11 @@ do
                        "${tmppath}/invälid.conf" \
                        "${tmppath}/invalíd" \
                        "${tmppath}/01invalíd"
+               mkdir "${tmppath}/invaliddir" \
+                       "${tmppath}/directory.conf" \
+                       "${tmppath}/directory.list" \
+                       "${tmppath}/directory.wron" \
+                       "${tmppath}/directory.list.disabled"
                ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
                ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
        elif [ $name = "getLanguages${EXT}" ]; then