Переглянути джерело

dpkg-maintscript-helper: Handle symlinks and pathnames ending in slash

For symlinks, error out as the argument is obviously bogus. For
pathnames just strip the trailing slash, as this is a common way to
name directories.

Closes: #771752
Guillem Jover 11 роки тому
батько
коміт
4266c68bc4
2 змінених файлів з 5 додано та 1 видалено
  1. 2 0
      debian/changelog
  2. 3 1
      scripts/dpkg-maintscript-helper.sh

+ 2 - 0
debian/changelog

@@ -92,6 +92,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     - Clarify dpkg-genchanges changes description open error.
     - Add missing preposition in Dpkg::Source::Patch error message.
     - Improve available state sorting order strings in dselect panel.
+  * Change dpkg-maintscript-helper to handle symlinks and pathnames ending in
+    slash. For the former error out, for the latter strip it. Closes: #771752
 
   [ Raphaël Hertzog ]
   * Drop myself from Uploaders.

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

@@ -254,6 +254,8 @@ symlink_to_dir() {
 	[ -n "$SYMLINK" ] || error "symlink parameter is missing"
 	[ "${SYMLINK#/}" = "$SYMLINK" ] && \
 		error "symlink pathname is not an absolute path"
+	[ "${SYMLINK%/}" = "$SYMLINK" ] && \
+		error "symlink pathname ends with a slash"
 	[ -n "$SYMLINK_TARGET" ] || error "original symlink target is missing"
 	[ -n "$1" ] || error "maintainer script parameters are missing"
 
@@ -305,7 +307,7 @@ symlink_to_dir() {
 ## Functions to replace a directory with a symlink
 ##
 dir_to_symlink() {
-	local PATHNAME="$1"
+	local PATHNAME="${1%/}"
 	local SYMLINK_TARGET="$2"
 	local LASTVERSION="$3"
 	local PACKAGE="$4"