Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-143906

tar: --one-top-level with absolute path fails

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • rhel-10.2
    • CentOS Stream 10, rhel-10.2
    • tar
    • None
    • Yes
    • Moderate
    • ZStream
    • rhel-base-utils-core
    • None
    • None
    • x86_64
    • None

      What were you trying to do that didn't work?

      Extract a tarball using --one-top-level

      What is the impact of this issue to you?

      I have had to refactor build scripts to run `mkdir -p <target dir>; tar -C <target dir> x ...` instead of tar --one-top-level <target dir>

      Please provide the package NVR for which the bug is seen:

      tar-1.35-10.el10.x86_64

      How reproducible is this bug?:

      Easily AFAIK

      Steps to reproduce

      #!/bin/bash
      set -x
      WORKDIR=$(mktemp -d)
      trap "rm -rf $WORKDIR /tmp/tar-one-top-level-test" EXIT
      cd "$WORKDIR" # Create minimal test archive
      mkdir -p pkg/usr/lib && echo "test" > pkg/usr/lib/tartest.txt
      tar czf test.tar.gz -C pkg . && rm -rf pkg
      echo "tar version: $(rpm -q tar 2>/dev/null || tar --version)"
      tar zxf test.tar.gz --one-top-level=/tmp/tar-one-top-level-test 2>&1 

      Expected results

      archive is extracted at /tmp/tar-one-top-level-test

      Actual results

      Cannot mkdir/Cannot open: Invalid cross-device link

      ++ mktemp -d
      + WORKDIR=/tmp/tmp.kbE3w6y1Cn
      + trap 'rm -rf /tmp/tmp.kbE3w6y1Cn /tmp/tar-one-top-level-test' EXIT
      + cd /tmp/tmp.kbE3w6y1Cn
      + mkdir -p pkg/usr/lib
      + echo test
      + tar czf test.tar.gz -C pkg .
      + rm -rf pkg
      ++ rpm -q tar
      + echo 'tar version: tar-1.35-10.el10.x86_64'
      tar version: tar-1.35-10.el10.x86_64
      + tar zxf test.tar.gz --one-top-level=/tmp/tar-one-top-level-test
      tar: /tmp/tar-one-top-level-test: Cannot mkdir: Invalid cross-device link
      tar: /tmp/tar-one-top-level-test/usr: Cannot mkdir: Invalid cross-device link
      tar: /tmp/tar-one-top-level-test/usr/lib: Cannot mkdir: Invalid cross-device link
      tar: /tmp/tar-one-top-level-test/usr/lib/tartest.txt: Cannot open: Invalid cross-device link
      tar: Exiting with failure status due to previous errors
      + rm -rf /tmp/tmp.kbE3w6y1Cn /tmp/tar-one-top-level-test
       

              rhn-support-pcahyna Pavel Cahyna
              rh-ee-ckruse Christian Kruse
              Pavel Cahyna Pavel Cahyna
              Radka Brychtova Radka Brychtova
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated: