This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=5f454c08c5e3190dce3256019b4adef93dc62f99

commit 5f454c08c5e3190dce3256019b4adef93dc62f99
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Jun 26 06:37:10 2020 +0200

    dpkg-realpath: Do not expect pathname to be prefixed with root directory
    
    This made its usage cumbersome as then the root directory needs to be
    specified twice. It also diverges from the other commands as they do
    not expect the root directory to be prefixed, which would make this a
    rather unexpected interface.
---
 scripts/dpkg-maintscript-helper.sh | 2 +-
 scripts/dpkg-realpath.sh           | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/scripts/dpkg-maintscript-helper.sh 
b/scripts/dpkg-maintscript-helper.sh
index 7e640661d..1c7e17eed 100755
--- a/scripts/dpkg-maintscript-helper.sh
+++ b/scripts/dpkg-maintscript-helper.sh
@@ -410,7 +410,7 @@ dir_to_symlink() {
             -f "$DPKG_ROOT$PATHNAME/.dpkg-staging-dir" \) -o \
          \( -h "$DPKG_ROOT$PATHNAME" -a \
             \( "$(readlink "$DPKG_ROOT$PATHNAME")" = "$SYMLINK_TARGET" -o \
-               "$(dpkg-realpath "$DPKG_ROOT$PATHNAME")" = "$SYMLINK_TARGET" \) 
\) ] &&
+               "$(dpkg-realpath "$PATHNAME")" = "$SYMLINK_TARGET" \) \) ] &&
        dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then
       abort_dir_to_symlink "$PATHNAME"
     fi
diff --git a/scripts/dpkg-realpath.sh b/scripts/dpkg-realpath.sh
index 30a8d290b..feba0eae4 100755
--- a/scripts/dpkg-realpath.sh
+++ b/scripts/dpkg-realpath.sh
@@ -55,11 +55,6 @@ canonicalize() {
   local result="$root"
   local dst
 
-  if [ "${src#"$root"}" = "$src" ]; then
-    error "link not within root"
-  fi
-  # Remove prefixed root dir.
-  src=${src#"$root"}
   # Remove prefixed slashes.
   while [ "$src" != "${src#/}" ]; do
      src=${src#/}
@@ -155,6 +150,9 @@ while [ $# -ne 0 ]; do
 done
 
 [ -n "$pathname" ] || badusage "missing pathname"
+if [ "${pathname#"$DPKG_ROOT"}" != "$pathname" ]; then
+  error "link includes root prefix"
+fi
 
 canonicalize "$pathname"
 

-- 
Dpkg.Org's dpkg

Reply via email to