Просмотр исходного кода

dpkg-maintscript-helper: Fix symlink_to_dir to assure absolute pathnames

We must ensure that the original symlink and symlink targets are
absolute pathnames. For the latter it is easier to make sure the
filesystem symlink target matches the argument passed, as we can
canonicalize the argument.
Guillem Jover лет назад: 12
Родитель
Сommit
914e739cf4
3 измененных файлов с 8 добавлено и 2 удалено
  1. 2 0
      debian/changelog
  2. 2 2
      man/dpkg-maintscript-helper.1
  3. 4 0
      scripts/dpkg-maintscript-helper.sh

+ 2 - 0
debian/changelog

@@ -12,6 +12,8 @@ dpkg (1.17.13) UNRELEASED; urgency=low
     - Remove duplicate “of the” in dpkg-maintscript-helper(1).
   * Fix dpkg-maintscript-helper dir_to_symlink to handle relative symlink
     targets. Thanks to Helmut Grohne <helmut@subdivi.de>.
+  * Fix dpkg-maintscript-helper symlink_to_dir to assure absolute pathnames
+    arguments.
 
   [ Updated programs translations ]
   * Czech (Miroslav Kure).

+ 2 - 2
man/dpkg-maintscript-helper.1

@@ -169,9 +169,9 @@ scripts:
     dpkg\-maintscript\-helper symlink_to_dir \\
         \fIpathname\fP \fIold-target\fP \fIprior-version\fP \fIpackage\fP \-\- "$@"
 .P
-\fIpathname\fP is the name of the old symlink (the path will be a
+\fIpathname\fP is the absolute name of the old symlink (the path will be a
 directory at the end of the installation) and \fIold-target\fP the
-target of the former symlink at \fIpathname\fP.
+absolute target name of the former symlink at \fIpathname\fP.
 .P
 Current implementation: the \fBpreinst\fP checks if the symlink exists
 and points to \fIold-target\fP, if not then it's left in place, otherwise

+ 4 - 0
scripts/dpkg-maintscript-helper.sh

@@ -252,7 +252,11 @@ symlink_to_dir() {
 		error "environment variable DPKG_MAINTSCRIPT_NAME is required"
 	[ -n "$PACKAGE" ] || error "cannot identify the package"
 	[ -n "$SYMLINK" ] || error "symlink parameter is missing"
+	[ "${SYMLINK#/}" = "$SYMLINK" ] && \
+		error "symlink pathname is not an absolute path"
 	[ -n "$SYMLINK_TARGET" ] || error "original symlink target is missing"
+	[ "${SYMLINK_TARGET#/}" = "$SYMLINK_TARGET" ] && \
+		error "original symlink target is not an absolute path"
 	[ -n "$1" ] || error "maintainer script parameters are missing"
 
 	debug "Executing $0 symlink_to_dir in $DPKG_MAINTSCRIPT_NAME" \