Преглед изворни кода

dpkg: Ignore trailing filter subpattern slashes on reinclusion comparison

The code was not matching directories on subpatterns due to trailing
slashes, which was causing unpack failures as the containing
subdirectories were not being unpacked and as such, they were
subsequently missing from the file system.

While unpacking a «/usr/share/locale/de/LC_MESSAGES/foo.mo» file,
for example, something like the following options would trigger
this problem:

  --path-exclude=/usr/share/locale/*
  --path-include=/usr/share/locale/de/*

Closes: #688416
Guillem Jover пре 13 година
родитељ
комит
e9ea356ab8
2 измењених фајлова са 8 додато и 0 уклоњено
  1. 4 0
      debian/changelog
  2. 4 0
      src/filters.c

+ 4 - 0
debian/changelog

@@ -27,6 +27,10 @@ dpkg (1.16.9) UNRELEASED; urgency=low
     versions, which can be an issue with partial upgrades.
   * Fix filter subpattern debug output format string to print an actual
     value instead of just blanks.
+  * Ignore trailing filter subpattern slashes on reinclusion comparison.
+    This makes sure to reinclude directories previously excluded so that
+    contained files marked for inclusion do not fail to unpack due to a
+    missing directory. Closes: #688416
 
   [ Updated programs translations ]
   * Czech (Miroslav Kure).

+ 4 - 0
src/filters.c

@@ -114,6 +114,10 @@ filter_should_skip(struct tar_entry *ti)
 			else
 				path_len = strlen(f->pattern);
 
+			/* Ignore any trailing slash for the comparison. */
+			while (path_len && f->pattern[path_len - 1] == '/')
+				path_len--;
+
 			debug(dbg_eachfiledetail,
 			      "filter subpattern '%.*s'", path_len, f->pattern);