Sfoglia il codice sorgente

dpkg-maintscript-helper: Anchor pathnames in sed and grep regexes

Make conffile checks a bit more robust, by anchoring them at the
beginning of the string. This requires both «dpkg-query -W -f» and
md5sum(1) to prepended a space but nothing else to pathnames.

Signed-off-by: Guillem Jover <guillem@debian.org>
Carsten Hey 10 anni fa
parent
commit
678e4a0def
2 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 2 0
      debian/changelog
  2. 3 3
      scripts/dpkg-maintscript-helper.sh

+ 2 - 0
debian/changelog

@@ -31,6 +31,8 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     Thanks to Carsten Hey <carsten@debian.org>.
   * Quote shell variables in dpkg-maintscript-helper.
     Thanks to Carsten Hey <carsten@debian.org>.
+  * Anchor pathnames in sed and grep regexes in dpkg-maintscript-helper.
+    Thanks to Carsten Hey <carsten@debian.org>.
   * Portability:
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
       code, to make life easier for non-dpkg-based systems.

+ 3 - 3
scripts/dpkg-maintscript-helper.sh

@@ -90,7 +90,7 @@ prepare_rm_conffile() {
 
 	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
 	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
-		sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
+		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" != "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-backup"
 	else
@@ -193,7 +193,7 @@ prepare_mv_conffile() {
 
 	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
 	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
-		sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
+		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" = "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-remove"
 	fi
@@ -391,7 +391,7 @@ prepare_dir_to_symlink()
 
 	# If there are conffiles we should not perform the switch.
 	if dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
-	   grep -q "$PATHNAME/."; then
+	   grep -q "^ $PATHNAME/."; then
 		error "directory '$PATHNAME' contains conffiles," \
 		      "cannot switch to symlink"
 	fi