mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 08:25:38 +00:00
704d91fc7c
symlink(2) is a very dumb syscall, and allows you to put any damn value you please inside a symlink. In addition, spaces are valid path characters which causes issues with keyword parsing. So use Vis() and Unvis() to safely store an encoded version of the path. This also adds a cli test for this behaviour. Signed-off-by: Aleksa Sarai <asarai@suse.de>
24 lines
581 B
Bash
24 lines
581 B
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
name=$(basename $0)
|
|
root=$1
|
|
gomtree=$(readlink -f ${root}/gomtree)
|
|
t=$(mktemp -d /tmp/go-mtree.XXXXXX)
|
|
|
|
echo "[${name}] Running in ${t}"
|
|
# This test is for basic running check of manifest, and check against tar and file system
|
|
#
|
|
|
|
pushd ${root}
|
|
|
|
# Create a symlink with spaces in the entries.
|
|
mkdir ${t}/root
|
|
ln -s "this is a dummy symlink" ${t}/root/link
|
|
|
|
# Create manifest and check it against the same symlink.
|
|
${gomtree} -K link,sha256digest -c -p ${t}/root > ${t}/root.mtree
|
|
${gomtree} -K link,sha256digest -f ${t}/root.mtree -p ${t}/root
|
|
|
|
popd
|
|
rm -rf ${t}
|