2017-03-07 07:11:40 +08:00
#!/usr/bin/env bats
load helpers
2018-09-09 22:44:05 +08:00
@test "copy-flags-order-verification" {
2020-04-16 21:48:43 +08:00
run_buildah 125 copy container1 -q /tmp/container1
2018-09-09 22:44:05 +08:00
check_options_flag_err "-q"
2020-04-16 21:48:43 +08:00
run_buildah 125 copy container1 --chown /tmp/container1 --quiet
2018-09-09 22:44:05 +08:00
check_options_flag_err "--chown"
2020-04-16 21:48:43 +08:00
run_buildah 125 copy container1 /tmp/container1 --quiet
2018-09-09 22:44:05 +08:00
check_options_flag_err "--quiet"
}
2017-03-25 03:42:18 +08:00
@test "copy-local-multiple" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-randomfile
createrandom ${TEST_SCRATCH_DIR}/third-randomfile
2017-03-25 03:42:18 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
run_buildah mount $cid
root=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
# copy ${TEST_SCRATCH_DIR}/randomfile to a file of the same name in the container's working directory
2022-08-22 14:46:39 +08:00
run_buildah copy --retry 4 --retry-delay 4s $cid ${TEST_SCRATCH_DIR}/randomfile
2022-04-26 23:09:11 +08:00
# copy ${TEST_SCRATCH_DIR}/other-randomfile and ${TEST_SCRATCH_DIR}/third-randomfile to a new directory named ${TEST_SCRATCH_DIR}/randomfile in the container
run_buildah copy $cid ${TEST_SCRATCH_DIR}/other-randomfile ${TEST_SCRATCH_DIR}/third-randomfile ${TEST_SCRATCH_DIR}/randomfile
# try to copy ${TEST_SCRATCH_DIR}/other-randomfile and ${TEST_SCRATCH_DIR}/third-randomfile to a /randomfile, which already exists and is a file
run_buildah 125 copy $cid ${TEST_SCRATCH_DIR}/other-randomfile ${TEST_SCRATCH_DIR}/third-randomfile /randomfile
# copy ${TEST_SCRATCH_DIR}/other-randomfile and ${TEST_SCRATCH_DIR}/third-randomfile to previously-created directory named ${TEST_SCRATCH_DIR}/randomfile in the container
run_buildah copy $cid ${TEST_SCRATCH_DIR}/other-randomfile ${TEST_SCRATCH_DIR}/third-randomfile ${TEST_SCRATCH_DIR}/randomfile
2019-12-12 04:03:37 +08:00
run_buildah rm $cid
2017-03-25 03:42:18 +08:00
2019-12-09 21:45:52 +08:00
_prefetch alpine
2022-04-26 21:47:03 +08:00
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
2019-12-12 03:11:08 +08:00
cid=$output
run_buildah mount $cid
root=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/randomfile
run_buildah copy $cid ${TEST_SCRATCH_DIR}/other-randomfile ${TEST_SCRATCH_DIR}/third-randomfile ${TEST_SCRATCH_DIR}/randomfile /etc
2019-12-12 04:03:37 +08:00
run_buildah rm $cid
2017-07-17 22:42:58 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
2019-12-12 03:11:08 +08:00
cid=$output
run_buildah mount $cid
root=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid "${TEST_SCRATCH_DIR}/*randomfile" /etc
(cd ${TEST_SCRATCH_DIR}; for i in *randomfile; do cmp $i ${root}/etc/$i; done)
2017-03-25 03:42:18 +08:00
}
2017-03-07 07:11:40 +08:00
@test "copy-local-plain" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-randomfile
createrandom ${TEST_SCRATCH_DIR}/third-randomfile
2017-03-07 07:11:40 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
run_buildah mount $cid
root=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/randomfile
run_buildah copy $cid ${TEST_SCRATCH_DIR}/other-randomfile
2019-12-12 04:03:37 +08:00
run_buildah unmount $cid
2022-04-26 21:47:03 +08:00
run_buildah commit $WITH_POLICY_JSON $cid containers-storage:new-image
2019-12-12 04:03:37 +08:00
run_buildah rm $cid
2017-03-07 07:11:40 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON new-image
2019-12-12 03:11:08 +08:00
newcid=$output
run_buildah mount $newcid
newroot=$output
2017-03-25 00:49:22 +08:00
test -s $newroot/randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $newroot/randomfile
2017-03-25 00:49:22 +08:00
test -s $newroot/other-randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/other-randomfile $newroot/other-randomfile
2017-03-07 07:11:40 +08:00
}
2017-03-28 15:02:41 +08:00
@test "copy-local-subdirectory" {
2022-04-26 23:09:11 +08:00
mkdir -p ${TEST_SCRATCH_DIR}/subdir
createrandom ${TEST_SCRATCH_DIR}/subdir/randomfile
createrandom ${TEST_SCRATCH_DIR}/subdir/other-randomfile
2017-03-28 15:02:41 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir /container-subdir $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/subdir
2019-12-12 03:11:08 +08:00
run_buildah mount $cid
root=$output
2017-03-28 15:02:41 +08:00
test -s $root/container-subdir/randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/subdir/randomfile $root/container-subdir/randomfile
2017-03-28 15:02:41 +08:00
test -s $root/container-subdir/other-randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/subdir/other-randomfile $root/container-subdir/other-randomfile
run_buildah copy $cid ${TEST_SCRATCH_DIR}/subdir /other-subdir
2017-03-28 15:02:41 +08:00
test -s $root/other-subdir/randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/subdir/randomfile $root/other-subdir/randomfile
2017-03-28 15:02:41 +08:00
test -s $root/other-subdir/other-randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/subdir/other-randomfile $root/other-subdir/other-randomfile
2017-03-28 15:02:41 +08:00
}
2017-03-28 03:35:09 +08:00
@test "copy-local-force-directory" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2017-03-28 03:35:09 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/randomfile /randomfile
2019-12-12 03:11:08 +08:00
run_buildah mount $cid
root=$output
2017-03-28 03:35:09 +08:00
test -s $root/randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $root/randomfile
2019-12-12 04:03:37 +08:00
run_buildah rm $cid
2017-03-28 03:35:09 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/randomfile /randomsubdir/
2019-12-12 03:11:08 +08:00
run_buildah mount $cid
root=$output
2017-03-28 03:35:09 +08:00
test -s $root/randomsubdir/randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $root/randomsubdir/randomfile
2017-03-28 03:35:09 +08:00
}
2017-03-28 15:01:59 +08:00
@test "copy-url-mtime" {
2019-10-30 00:26:14 +08:00
# Create a file with random content and a non-now timestamp (so we can
# can trust that buildah correctly set mtime on copy)
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
touch -t 201910310123.45 ${TEST_SCRATCH_DIR}/randomfile
2017-03-28 15:01:59 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
starthttpd ${TEST_SCRATCH_DIR}
2019-12-12 04:03:37 +08:00
run_buildah copy $cid http://0.0.0.0:${HTTP_SERVER_PORT}/randomfile /urlfile
2017-03-28 15:01:59 +08:00
stophttpd
2019-12-12 03:11:08 +08:00
run_buildah mount $cid
root=$output
2017-03-28 15:01:59 +08:00
test -s $root/urlfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $root/urlfile
2019-10-30 00:26:14 +08:00
# Compare timestamps. Display them in human-readable form, so if there's
# a mismatch it will be shown in the test log.
2022-04-26 23:09:11 +08:00
mtime_randomfile=$(stat --format %y ${TEST_SCRATCH_DIR}/randomfile)
2019-10-30 00:26:14 +08:00
mtime_urlfile=$(stat --format %y $root/urlfile)
2019-12-12 07:21:51 +08:00
expect_output --from="$mtime_randomfile" "$mtime_urlfile" "mtime[randomfile] == mtime[urlfile]"
2017-03-28 15:01:59 +08:00
}
2017-11-30 22:34:02 +08:00
@test "copy --chown" {
2022-04-26 23:09:11 +08:00
mkdir -p ${TEST_SCRATCH_DIR}/subdir
mkdir -p ${TEST_SCRATCH_DIR}/other-subdir
createrandom ${TEST_SCRATCH_DIR}/subdir/randomfile
createrandom ${TEST_SCRATCH_DIR}/subdir/other-randomfile
createrandom ${TEST_SCRATCH_DIR}/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-subdir/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-subdir/other-randomfile
2017-11-30 22:34:02 +08:00
2019-12-09 21:45:52 +08:00
_prefetch alpine
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON alpine
2019-12-12 03:11:08 +08:00
cid=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy --chown 1:1 $cid ${TEST_SCRATCH_DIR}/randomfile
run_buildah copy --chown root:1 $cid ${TEST_SCRATCH_DIR}/randomfile /randomfile2
run_buildah copy --chown nobody $cid ${TEST_SCRATCH_DIR}/randomfile /randomfile3
run_buildah copy --chown nobody:root $cid ${TEST_SCRATCH_DIR}/subdir /subdir
2019-12-12 04:03:37 +08:00
run_buildah run $cid stat -c "%u:%g" /randomfile
2019-12-12 07:21:51 +08:00
expect_output "1:1" "stat ug /randomfile"
2019-12-12 04:03:37 +08:00
run_buildah run $cid stat -c "%U:%g" /randomfile2
2019-12-12 07:21:51 +08:00
expect_output "root:1" "stat Ug /randomfile2"
2019-12-12 04:03:37 +08:00
run_buildah run $cid stat -c "%U" /randomfile3
2019-12-12 07:21:51 +08:00
expect_output "nobody" "stat U /randomfile3"
for i in randomfile other-randomfile ; do
run_buildah run $cid stat -c "%U:%G" /subdir/$i
expect_output "nobody:root" "stat UG /subdir/$i"
done
2020-09-30 03:01:27 +08:00
# subdir will have been implicitly created, and the --chown should have had an effect
run_buildah run $cid stat -c "%U:%G" /subdir
expect_output "nobody:root" "stat UG /subdir"
2022-04-26 23:09:11 +08:00
run_buildah copy --chown root:root $cid ${TEST_SCRATCH_DIR}/other-subdir /subdir
2019-12-12 07:21:51 +08:00
for i in randomfile other-randomfile ; do
run_buildah run $cid stat -c "%U:%G" /subdir/$i
expect_output "root:root" "stat UG /subdir/$i (after chown)"
done
2020-09-30 03:01:27 +08:00
# subdir itself will have not been copied (the destination directory was created implicitly), so its permissions should not have changed
2019-12-12 04:03:37 +08:00
run_buildah run $cid stat -c "%U:%G" /subdir
2019-12-12 07:21:51 +08:00
expect_output "nobody:root" "stat UG /subdir"
2017-11-30 22:34:02 +08:00
}
2018-09-12 21:28:38 +08:00
2021-02-24 07:14:04 +08:00
@test "copy --chmod" {
2022-04-26 23:09:11 +08:00
mkdir -p ${TEST_SCRATCH_DIR}/subdir
mkdir -p ${TEST_SCRATCH_DIR}/other-subdir
createrandom ${TEST_SCRATCH_DIR}/subdir/randomfile
createrandom ${TEST_SCRATCH_DIR}/subdir/other-randomfile
createrandom ${TEST_SCRATCH_DIR}/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-subdir/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-subdir/other-randomfile
2021-02-24 07:14:04 +08:00
_prefetch alpine
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON alpine
2021-02-24 07:14:04 +08:00
cid=$output
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy --chmod 777 $cid ${TEST_SCRATCH_DIR}/randomfile
run_buildah copy --chmod 700 $cid ${TEST_SCRATCH_DIR}/randomfile /randomfile2
run_buildah copy --chmod 755 $cid ${TEST_SCRATCH_DIR}/randomfile /randomfile3
run_buildah copy --chmod 660 $cid ${TEST_SCRATCH_DIR}/subdir /subdir
2021-02-24 07:14:04 +08:00
run_buildah run $cid ls -l /randomfile
expect_output --substring rwxrwxrwx
run_buildah run $cid ls -l /randomfile2
expect_output --substring rwx------
run_buildah run $cid ls -l /randomfile3
expect_output --substring rwxr-xr-x
for i in randomfile other-randomfile ; do
run_buildah run $cid ls -l /subdir/$i
expect_output --substring rw-rw----
done
run_buildah run $cid ls -l /subdir
expect_output --substring rw-rw----
2022-04-26 23:09:11 +08:00
run_buildah copy --chmod 600 $cid ${TEST_SCRATCH_DIR}/other-subdir /subdir
2021-02-24 07:14:04 +08:00
for i in randomfile other-randomfile ; do
run_buildah run $cid ls -l /subdir/$i
expect_output --substring rw-------
done
}
2018-09-12 21:28:38 +08:00
@test "copy-symlink" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
ln -s ${TEST_SCRATCH_DIR}/randomfile ${TEST_SCRATCH_DIR}/link-randomfile
2018-09-12 21:28:38 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2019-12-12 03:11:08 +08:00
cid=$output
run_buildah mount $cid
root=$output
2019-12-12 04:03:37 +08:00
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/link-randomfile
2019-12-12 04:03:37 +08:00
run_buildah unmount $cid
2022-04-26 21:47:03 +08:00
run_buildah commit $WITH_POLICY_JSON $cid containers-storage:new-image
2019-12-12 04:03:37 +08:00
run_buildah rm $cid
2018-09-12 21:28:38 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON new-image
2019-12-12 03:11:08 +08:00
newcid=$output
run_buildah mount $newcid
newroot=$output
2018-09-12 21:28:38 +08:00
test -s $newroot/link-randomfile
test -f $newroot/link-randomfile
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $newroot/link-randomfile
2018-09-12 21:28:38 +08:00
}
2020-01-25 22:43:01 +08:00
2021-03-12 16:20:33 +08:00
@test "ignore-socket" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2021-04-20 03:26:36 +08:00
# This seems to be the least-worst way to create a socket: run and kill nc
2022-04-26 23:09:11 +08:00
nc -lkU ${TEST_SCRATCH_DIR}/test.socket &
2021-04-20 03:26:36 +08:00
nc_pid=$!
# This should succeed fairly quickly. We test with a timeout in case of
# failure (likely reason: 'nc' not installed.)
retries=50
2022-04-26 23:09:11 +08:00
while ! test -e ${TEST_SCRATCH_DIR}/test.socket; do
2021-04-20 03:26:36 +08:00
sleep 0.1
retries=$((retries - 1))
if [[ $retries -eq 0 ]]; then
2022-04-26 23:09:11 +08:00
die "Timed out waiting for ${TEST_SCRATCH_DIR}/test.socket (is nc installed?)"
2021-04-20 03:26:36 +08:00
fi
done
kill $nc_pid
2021-03-12 16:20:33 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2021-03-12 16:20:33 +08:00
cid=$output
run_buildah mount $cid
root=$output
run_buildah config --workingdir / $cid
run_buildah unmount $cid
2022-04-26 21:47:03 +08:00
run_buildah commit $WITH_POLICY_JSON $cid containers-storage:new-image
2021-03-12 16:20:33 +08:00
run_buildah rm $cid
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON new-image
2021-03-12 16:20:33 +08:00
newcid=$output
run_buildah mount $newcid
newroot=$output
test \! -e $newroot/test.socket
}
2020-08-16 17:37:22 +08:00
@test "copy-symlink-archive-suffix" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile.tar.gz
ln -s ${TEST_SCRATCH_DIR}/randomfile.tar.gz ${TEST_SCRATCH_DIR}/link-randomfile.tar.gz
2020-08-16 17:37:22 +08:00
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2020-08-16 17:37:22 +08:00
cid=$output
run_buildah mount $cid
root=$output
run_buildah config --workingdir / $cid
2022-04-26 23:09:11 +08:00
run_buildah copy $cid ${TEST_SCRATCH_DIR}/link-randomfile.tar.gz
2020-08-16 17:37:22 +08:00
run_buildah unmount $cid
2022-04-26 21:47:03 +08:00
run_buildah commit $WITH_POLICY_JSON $cid containers-storage:new-image
2020-08-16 17:37:22 +08:00
run_buildah rm $cid
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON new-image
2020-08-16 17:37:22 +08:00
newcid=$output
run_buildah mount $newcid
newroot=$output
test -s $newroot/link-randomfile.tar.gz
test -f $newroot/link-randomfile.tar.gz
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile.tar.gz $newroot/link-randomfile.tar.gz
2020-08-16 17:37:22 +08:00
}
2020-01-25 22:43:01 +08:00
@test "copy-detect-missing-data" {
2019-12-09 21:45:52 +08:00
_prefetch busybox
2022-04-26 23:09:11 +08:00
: > ${TEST_SCRATCH_DIR}/Dockerfile
echo FROM busybox AS builder >> ${TEST_SCRATCH_DIR}/Dockerfile
echo FROM scratch >> ${TEST_SCRATCH_DIR}/Dockerfile
echo COPY --from=builder /bin/-no-such-file-error- /usr/bin >> ${TEST_SCRATCH_DIR}/Dockerfile
run_buildah 125 build-using-dockerfile $WITH_POLICY_JSON ${TEST_SCRATCH_DIR}
2020-01-25 22:43:01 +08:00
expect_output --substring "no such file or directory"
}
2020-11-19 21:14:58 +08:00
2021-08-24 22:41:16 +08:00
@test "copy --ignorefile" {
2022-04-26 23:09:11 +08:00
mytest=${TEST_SCRATCH_DIR}/mytest
2020-11-19 21:14:58 +08:00
mkdir -p ${mytest}
touch ${mytest}/mystuff
touch ${mytest}/source.go
mkdir -p ${mytest}/notmystuff
touch ${mytest}/notmystuff/notmystuff
cat > ${mytest}/.ignore << _EOF
*.go
.ignore
notmystuff
_EOF
expect="
stuff
stuff/mystuff"
2022-04-26 21:47:03 +08:00
run_buildah from $WITH_POLICY_JSON scratch
2020-11-19 21:14:58 +08:00
cid=$output
run_buildah 125 copy --ignorefile ${mytest}/.ignore $cid ${mytest} /stuff
2022-09-18 18:36:08 +08:00
expect_output -- "Error: --ignorefile option requires that you specify a context dir using --contextdir" "container file list"
2020-11-19 21:14:58 +08:00
run_buildah copy --contextdir=${mytest} --ignorefile ${mytest}/.ignore $cid ${mytest} /stuff
run_buildah mount $cid
mnt=$output
run find $mnt -printf "%P\n"
filelist=$(LC_ALL=C sort <<<"$output")
run_buildah umount $cid
expect_output --from="$filelist" "$expect" "container file list"
}
2021-03-02 01:19:01 +08:00
2024-09-12 21:08:12 +08:00
@test "copy --exclude" {
mytest=${TEST_SCRATCH_DIR}/mytest
mkdir -p ${mytest}
touch ${mytest}/mystuff
touch ${mytest}/source.go
mkdir -p ${mytest}/notmystuff
touch ${mytest}/notmystuff/notmystuff
expect="
stuff
stuff/mystuff"
run_buildah from $WITH_POLICY_JSON scratch
cid=$output
run_buildah copy --exclude=**/*.go --exclude=.ignore --exclude=**/notmystuff $cid ${mytest} /stuff
run_buildah mount $cid
mnt=$output
run find $mnt -printf "%P\n"
filelist=$(LC_ALL=C sort <<<"$output")
run_buildah umount $cid
expect_output --from="$filelist" "$expect" "container file list"
}
2025-02-17 21:29:46 +08:00
@test "copy --parents" {
mytest=${TEST_SCRATCH_DIR}/mytest
mkdir -p ${mytest}
mkdir -p ${mytest}/x
mkdir -p ${mytest}/y
touch ${mytest}/x/a.txt
touch ${mytest}/y/a.txt
touch ${mytest}/y/b.txt
expect_all="
parents
parents/x
parents/x/a.txt
parents/y
parents/y/a.txt
parents/y/b.txt"
expect_a_txt="
parents
parents/x
parents/x/a.txt
parents/y
parents/y/a.txt"
expect_b_txt="
parents
parents/y
parents/y/b.txt"
expect_only_y_dir="
parents
parents/y
parents/y/a.txt
parents/y/b.txt"
# paths | expected
tests="
${mytest}/./*/a.txt | ${expect_a_txt}
${mytest}/./y/* | ${expect_only_y_dir}
${mytest}/./*/b.txt | ${expect_b_txt}
${mytest}/./* | ${expect_all}
"
local -A paths
local -A expected
while read paths expected; do
run_buildah from $WITH_POLICY_JSON scratch
cid=$output
run_buildah copy --parents $cid ${paths} /parents/
run_buildah mount $cid
mnt=$output
run find $mnt -printf "%P\n"
filelist=$(LC_ALL=C sort <<<"$output")
run_buildah umount $cid
expect_output --from="$filelist" "$expect" "container file list"
done < <(parse_table "$tests")
}
2021-03-02 01:19:01 +08:00
@test "copy-quiet" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2021-03-02 01:19:01 +08:00
_prefetch alpine
2022-04-26 21:47:03 +08:00
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
2021-03-02 01:19:01 +08:00
cid=$output
run_buildah mount $cid
root=$output
2022-04-26 23:09:11 +08:00
run_buildah copy --quiet $cid ${TEST_SCRATCH_DIR}/randomfile /
2021-03-02 01:19:01 +08:00
expect_output ""
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile $root/randomfile
2021-03-02 01:19:01 +08:00
run_buildah umount $cid
run_buildah rm $cid
}
2021-04-07 05:48:25 +08:00
@test "copy-from-container" {
_prefetch busybox
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON busybox
2021-04-07 05:48:25 +08:00
from=$output
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON busybox
2021-04-07 05:48:25 +08:00
cid=$output
2022-04-26 23:09:11 +08:00
run_buildah copy --quiet $from ${TEST_SCRATCH_DIR}/randomfile /tmp/random
2021-04-07 05:48:25 +08:00
expect_output ""
2022-04-26 21:47:03 +08:00
run_buildah copy --quiet $WITH_POLICY_JSON --from $from $cid /tmp/random /tmp/random # absolute path
2021-04-07 05:48:25 +08:00
expect_output ""
2022-04-26 21:47:03 +08:00
run_buildah copy --quiet $WITH_POLICY_JSON --from $from $cid tmp/random /tmp/random2 # relative path
2021-04-07 05:48:25 +08:00
expect_output ""
run_buildah mount $cid
croot=$output
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile ${croot}/tmp/random
cmp ${TEST_SCRATCH_DIR}/randomfile ${croot}/tmp/random2
2021-04-07 05:48:25 +08:00
}
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
@test "copy-container-root" {
_prefetch busybox
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON busybox
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
from=$output
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON busybox
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
cid=$output
2022-04-26 23:09:11 +08:00
run_buildah copy --quiet $from ${TEST_SCRATCH_DIR}/randomfile /tmp/random
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
expect_output ""
2022-04-26 21:47:03 +08:00
run_buildah copy --quiet $WITH_POLICY_JSON --from $from $cid / /tmp/
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
expect_output "" || \
expect_output --substring "copier: file disappeared while reading"
run_buildah mount $cid
croot=$output
2022-04-26 23:09:11 +08:00
cmp ${TEST_SCRATCH_DIR}/randomfile ${croot}/tmp/tmp/random
Fix copy race while walking paths
During a copy operation which descends through a directory tree,
It's possible for a referenced file to become inaccessible (by unlink
or permission change or whatever). During the walk of paths to copy,
an `Lstat()` is run on each item, and any error passed into the handler
function to deal with. Subsequently, if there is no error, the file
is examined for inclusion/exclusion by the handler.
Unfortunately, this introduces a TOCTOU race condition for files which
become inaccessible even if they would otherwise be excluded. For
example a file or directory under /proc or /sys (which frequently and
unpredictably change). This was the original cause encountered during
podman integration testing.
It's impractical to actually fix this race at the file-level, without
introducing negative effects to any source-container operations. It's
also questionably useful to offer a command-line option to offload the
choice to the user. Instead, follow the behavior of the `tar` command
for this situation: Issue a warning to the user, and ignore the
problematic item (don't copy it).
Also add a test resembling the podman test which originally caught this
race. While not reliable, it does introduce a non-zero chance of
hitting the race condition - and handling the new warning properly.
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-05-07 22:37:52 +08:00
}
2021-06-18 03:41:19 +08:00
@test "add-from-image" {
2021-04-07 05:48:25 +08:00
_prefetch busybox
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON busybox
2021-04-07 05:48:25 +08:00
cid=$output
2022-04-26 21:47:03 +08:00
run_buildah add $WITH_POLICY_JSON --quiet --from ubuntu $cid /etc/passwd /tmp/passwd # should pull the image, absolute path
2021-04-07 05:48:25 +08:00
expect_output ""
2022-04-26 21:47:03 +08:00
run_buildah add --quiet $WITH_POLICY_JSON --from ubuntu $cid etc/passwd /tmp/passwd2 # relative path
2021-04-07 05:48:25 +08:00
expect_output ""
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON ubuntu
2021-04-07 05:48:25 +08:00
ubuntu=$output
run_buildah mount $cid
croot=$output
run_buildah mount $ubuntu
ubuntu=$output
cmp $ubuntu/etc/passwd ${croot}/tmp/passwd
cmp $ubuntu/etc/passwd ${croot}/tmp/passwd2
}
2021-06-18 03:41:19 +08:00
@test "copy with .dockerignore" {
_prefetch alpine busybox
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON alpine
2021-06-18 03:41:19 +08:00
from=$output
2022-04-26 21:56:21 +08:00
run_buildah copy --contextdir=$BUDFILES/dockerignore $from $BUDFILES/dockerignore ./
2021-06-18 03:41:19 +08:00
run_buildah 1 run $from ls -l test1.txt
run_buildah run $from ls -l test2.txt
run_buildah 1 run $from ls -l sub1.txt
run_buildah 1 run $from ls -l sub2.txt
2021-08-24 22:41:16 +08:00
run_buildah 1 run $from ls -l subdir/
2021-06-18 03:41:19 +08:00
}
2021-06-19 02:56:09 +08:00
@test "copy-preserving-extended-attributes" {
2022-04-26 23:09:11 +08:00
createrandom ${TEST_SCRATCH_DIR}/randomfile
2022-03-10 23:22:37 +08:00
# if we need to change which image we use, any image that can provide a working setattr/setcap/getfattr will do
2025-01-08 01:56:14 +08:00
image="quay.io/libpod/ubuntu"
2022-03-10 23:22:37 +08:00
if ! which setfattr > /dev/null 2> /dev/null; then
2022-04-26 23:09:11 +08:00
skip "setfattr not available, unable to check if it'll work in filesystem at ${TEST_SCRATCH_DIR}"
2022-03-10 23:22:37 +08:00
fi
2022-04-26 23:09:11 +08:00
run setfattr -n user.yeah -v butno ${TEST_SCRATCH_DIR}/root
2022-03-10 23:22:37 +08:00
if [ "$status" -ne 0 ] ; then
if [[ "$output" =~ "not supported" ]] ; then
2022-04-26 23:09:11 +08:00
skip "setfattr not supported in filesystem at ${TEST_SCRATCH_DIR}"
2022-03-10 23:22:37 +08:00
fi
skip "$output"
fi
2021-06-19 02:56:09 +08:00
_prefetch $image
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON $image
2021-06-19 02:56:09 +08:00
first="$output"
2025-01-08 01:56:14 +08:00
run_buildah run $first apt-get -y update
run_buildah run $first apt-get -y install attr libcap2-bin
2022-04-26 23:09:11 +08:00
run_buildah copy $first ${TEST_SCRATCH_DIR}/randomfile /
2021-06-19 02:56:09 +08:00
# set security.capability
2022-03-10 23:22:37 +08:00
run_buildah run $first setcap cap_setuid=ep /randomfile
2021-06-19 02:56:09 +08:00
# set user.something
2022-03-10 23:22:37 +08:00
run_buildah run $first setfattr -n user.yeah -v butno /randomfile
2021-06-19 02:56:09 +08:00
# copy the file to a second container
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON $image
2021-06-19 02:56:09 +08:00
second="$output"
2025-01-08 01:56:14 +08:00
run_buildah run $second apt-get -y update
run_buildah run $second apt-get -y install attr
2021-06-19 02:56:09 +08:00
run_buildah copy --from $first $second /randomfile /
# compare what the extended attributes look like. if we're on a system with SELinux, there's a label in here, too
2022-03-10 23:22:37 +08:00
run_buildah run $first sh -c "getfattr -d -m . --absolute-names /randomfile | grep -v ^security.selinux | sort"
2021-06-19 02:56:09 +08:00
expected="$output"
2022-03-10 23:22:37 +08:00
run_buildah run $second sh -c "getfattr -d -m . --absolute-names /randomfile | grep -v ^security.selinux | sort"
2021-06-19 02:56:09 +08:00
expect_output "$expected"
}
2022-03-01 23:42:56 +08:00
@test "copy-relative-context-dir" {
image=busybox
_prefetch $image
2022-04-26 23:09:11 +08:00
mkdir -p ${TEST_SCRATCH_DIR}/context
createrandom ${TEST_SCRATCH_DIR}/context/excluded_test_file
createrandom ${TEST_SCRATCH_DIR}/context/test_file
echo excluded_test_file | tee ${TEST_SCRATCH_DIR}/context/.containerignore | tee ${TEST_SCRATCH_DIR}/context/.dockerignore
2022-04-26 21:47:03 +08:00
run_buildah from --quiet $WITH_POLICY_JSON $image
2022-03-01 23:42:56 +08:00
ctr="$output"
2022-04-26 23:09:11 +08:00
cd ${TEST_SCRATCH_DIR}/context
2022-03-01 23:42:56 +08:00
run_buildah copy --contextdir . $ctr / /opt/
run_buildah run $ctr ls -1 /opt/
expect_line_count 1
2022-04-25 22:37:28 +08:00
assert "$output" = "test_file" "only contents of copied directory"
2022-03-01 23:42:56 +08:00
}
2023-09-16 04:15:24 +08:00
@test "copy-file-relative-context-dir" {
image=busybox
_prefetch $image
mkdir -p ${TEST_SCRATCH_DIR}/context
createrandom ${TEST_SCRATCH_DIR}/context/test_file
run_buildah from --quiet $WITH_POLICY_JSON $image
ctr="$output"
run_buildah copy --contextdir ${TEST_SCRATCH_DIR}/context $ctr test_file /opt/
run_buildah run $ctr ls -1 /opt/
expect_line_count 1
assert "$output" = "test_file" "only the one file"
}
@test "copy-file-absolute-context-dir" {
image=busybox
_prefetch $image
mkdir -p ${TEST_SCRATCH_DIR}/context/subdir
createrandom ${TEST_SCRATCH_DIR}/context/subdir/test_file
run_buildah from --quiet $WITH_POLICY_JSON $image
ctr="$output"
run_buildah copy --contextdir ${TEST_SCRATCH_DIR}/context $ctr /subdir/test_file /opt/
run_buildah run $ctr ls -1 /opt/
expect_line_count 1
assert "$output" = "test_file" "only the one file"
}
@test "copy-file-relative-no-context-dir" {
image=busybox
_prefetch $image
mkdir -p ${TEST_SCRATCH_DIR}/context
createrandom ${TEST_SCRATCH_DIR}/context/test_file
run_buildah from --quiet $WITH_POLICY_JSON $image
ctr="$output"
# we're not in that directory currently
run_buildah 125 copy $ctr test_file /opt/
# now we are
cd ${TEST_SCRATCH_DIR}/context
run_buildah copy $ctr test_file /opt/
run_buildah run $ctr ls -1 /opt/
expect_line_count 1
assert "$output" = "test_file" "only the one file"
}
2024-06-17 21:49:39 +08:00
@test "copy-from-ownership" {
# Build both a container and an image that have contents owned by a
# non-default user.
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-1
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-2
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-3
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-4
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-5
truncate -s 256 ${TEST_SCRATCH_DIR}/random-file-6
run_buildah from scratch
sourcectr="$output"
run_buildah copy --chown 123:123 $sourcectr ${TEST_SCRATCH_DIR}/random-file-1
run_buildah copy --chown 123:123 $sourcectr ${TEST_SCRATCH_DIR}/random-file-2
run_buildah copy --chown 456:456 $sourcectr ${TEST_SCRATCH_DIR}/random-file-4
run_buildah copy --chown 456:456 $sourcectr ${TEST_SCRATCH_DIR}/random-file-5
sourceimg=testimage
run_buildah commit $sourcectr $sourceimg
_prefetch busybox
run_buildah from --pull=never $WITH_POLICY_JSON busybox
ctr="$output"
run_buildah copy $ctr ${TEST_SCRATCH_DIR}/random-file-3
run_buildah copy --from=$sourceimg $ctr /random-file-1 # should be preserved as 123:123
run_buildah copy --from=$sourceimg --chown=456:456 $ctr /random-file-2
run_buildah copy --from=$sourcectr $ctr /random-file-4 # should be preserved as 456:456
run_buildah copy --from=$sourcectr --chown=123:123 $ctr /random-file-5
run_buildah copy $ctr ${TEST_SCRATCH_DIR}/random-file-3
run_buildah copy --chown=789:789 $ctr ${TEST_SCRATCH_DIR}/random-file-6
run_buildah run $ctr stat -c %u:%g /random-file-1
assert 123:123
run_buildah run $ctr stat -c %u:%g /random-file-2
assert 456:456
run_buildah run $ctr stat -c %u:%g /random-file-3
assert 0:0
run_buildah run $ctr stat -c %u:%g /random-file-4
assert 456:456
run_buildah run $ctr stat -c %u:%g /random-file-5
assert 123:123
run_buildah run $ctr stat -c %u:%g /random-file-6
assert 789:789
}
2025-06-14 02:26:23 +08:00
@test "copy-link-flag" {
createrandom ${TEST_SCRATCH_DIR}/randomfile
createrandom ${TEST_SCRATCH_DIR}/other-randomfile
run_buildah from $WITH_POLICY_JSON scratch
cid=$output
run_buildah mount $cid
root=$output
run_buildah config --workingdir=/ $cid
run_buildah copy --link $cid ${TEST_SCRATCH_DIR}/randomfile
run_buildah copy --link $cid ${TEST_SCRATCH_DIR}/randomfile ${TEST_SCRATCH_DIR}/other-randomfile /subdir/
run_buildah unmount $cid
run_buildah commit $WITH_POLICY_JSON $cid copy-link-image
run_buildah inspect --type=image copy-link-image
layers=$(echo "$output" | jq -r '.OCIv1.rootfs.diff_ids | length')
assert "$layers" -eq 3 "Expected 3 layers from 2 --link operations and base, but found $layers"
run_buildah from $WITH_POLICY_JSON copy-link-image
newcid=$output
run_buildah mount $newcid
newroot=$output
test -s $newroot/randomfile
cmp ${TEST_SCRATCH_DIR}/randomfile $newroot/randomfile
test -s $newroot/subdir/randomfile
cmp ${TEST_SCRATCH_DIR}/randomfile $newroot/subdir/randomfile
test -s $newroot/subdir/other-randomfile
cmp ${TEST_SCRATCH_DIR}/other-randomfile $newroot/subdir/other-randomfile
}
@test "copy-link-directory" {
mkdir -p ${TEST_SCRATCH_DIR}/sourcedir
createrandom ${TEST_SCRATCH_DIR}/sourcedir/file1
createrandom ${TEST_SCRATCH_DIR}/sourcedir/file2
run_buildah from $WITH_POLICY_JSON scratch
cid=$output
run_buildah config --workingdir=/ $cid
run_buildah copy --link $cid ${TEST_SCRATCH_DIR}/sourcedir /destdir
run_buildah commit $WITH_POLICY_JSON $cid copy-link-dir-image
run_buildah from $WITH_POLICY_JSON copy-link-dir-image
newcid=$output
run_buildah mount $newcid
newroot=$output
test -d $newroot/destdir
test -s $newroot/destdir/file1
cmp ${TEST_SCRATCH_DIR}/sourcedir/file1 $newroot/destdir/file1
test -s $newroot/destdir/file2
cmp ${TEST_SCRATCH_DIR}/sourcedir/file2 $newroot/destdir/file2
}
@test "copy-link-with-chown" {
createrandom ${TEST_SCRATCH_DIR}/randomfile
_prefetch busybox
run_buildah from --quiet $WITH_POLICY_JSON busybox
cid=$output
run_buildah copy --link --chown bin:bin $cid ${TEST_SCRATCH_DIR}/randomfile /tmp/random
run_buildah commit $WITH_POLICY_JSON $cid copy-link-chown-image
run_buildah from $WITH_POLICY_JSON copy-link-chown-image
newcid=$output
run_buildah run $newcid ls -l /tmp/random
expect_output --substring "bin.*bin"
}
@test "copy-link-with-chmod" {
createrandom ${TEST_SCRATCH_DIR}/randomfile
_prefetch busybox
run_buildah from --quiet $WITH_POLICY_JSON busybox
cid=$output
run_buildah copy --link --chmod 777 $cid ${TEST_SCRATCH_DIR}/randomfile /tmp/random
run_buildah commit $WITH_POLICY_JSON $cid copy-link-chmod-image
run_buildah from $WITH_POLICY_JSON copy-link-chmod-image
newcid=$output
run_buildah run $newcid ls -l /tmp/random
expect_output --substring "rwxrwxrwx"
}