Blame tests/test-basic-user.sh

rpm-build 0fba15
#!/bin/bash
rpm-build 0fba15
#
rpm-build 0fba15
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
rpm-build 0fba15
#
rpm-build 0fba15
# SPDX-License-Identifier: LGPL-2.0+
rpm-build 0fba15
#
rpm-build 0fba15
# This library is free software; you can redistribute it and/or
rpm-build 0fba15
# modify it under the terms of the GNU Lesser General Public
rpm-build 0fba15
# License as published by the Free Software Foundation; either
rpm-build 0fba15
# version 2 of the License, or (at your option) any later version.
rpm-build 0fba15
#
rpm-build 0fba15
# This library is distributed in the hope that it will be useful,
rpm-build 0fba15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0fba15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0fba15
# Lesser General Public License for more details.
rpm-build 0fba15
#
rpm-build 0fba15
# You should have received a copy of the GNU Lesser General Public
rpm-build 0fba15
# License along with this library; if not, write to the
rpm-build 0fba15
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
rpm-build 0fba15
# Boston, MA 02111-1307, USA.
rpm-build 0fba15
rpm-build 0fba15
set -euo pipefail
rpm-build 0fba15
rpm-build 0fba15
. $(dirname $0)/libtest.sh
rpm-build 0fba15
rpm-build 0fba15
skip_without_user_xattrs
rpm-build 0fba15
rpm-build 0fba15
mode="bare-user"
rpm-build 0fba15
setup_test_repository "$mode"
rpm-build 0fba15
rpm-build 0fba15
extra_basic_tests=6
rpm-build 0fba15
. $(dirname $0)/basic-test.sh
rpm-build 0fba15
rpm-build 0fba15
# Reset things so we don't inherit a lot of state from earlier tests
rpm-build 0fba15
rm repo files -rf
rpm-build 0fba15
setup_test_repository "bare-user"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
objpath_nonexec=$(ostree_file_path_to_object_path repo test2 baz/cow)
rpm-build 0fba15
assert_file_has_mode ${objpath_nonexec} 644
rpm-build 0fba15
objpath_ro=$(ostree_file_path_to_object_path repo test2 baz/cowro)
rpm-build 0fba15
assert_file_has_mode ${objpath_ro} 600
rpm-build 0fba15
objpath_exec=$(ostree_file_path_to_object_path repo test2 baz/deeper/ohyeahx)
rpm-build 0fba15
assert_file_has_mode ${objpath_exec} 755
rpm-build 0fba15
echo "ok bare-user committed modes"
rpm-build 0fba15
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout -U -H test2 test2-checkout
rpm-build 0fba15
cd test2-checkout
rpm-build 0fba15
assert_file_has_mode baz/cow 644
rpm-build 0fba15
assert_file_has_mode baz/cowro 600
rpm-build 0fba15
assert_file_has_mode baz/deeper/ohyeahx 755
rpm-build 0fba15
echo "ok bare-user checkout modes"
rpm-build 0fba15
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout -U -H test2 test2-checkout
rpm-build 0fba15
touch test2-checkout/unwritable
rpm-build 0fba15
chmod 0400 test2-checkout/unwritable
rpm-build 0fba15
$OSTREE commit -b test2-unwritable --tree=dir=test2-checkout
rpm-build 0fba15
chmod 0600 test2-checkout/unwritable
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout -U -H test2-unwritable test2-checkout
rpm-build 0fba15
cd test2-checkout
rpm-build 0fba15
assert_file_has_mode unwritable 400
rpm-build 0fba15
echo "ok bare-user unwritable"
rpm-build 0fba15
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout -U -H test2 test2-checkout
rpm-build 0fba15
cat > statoverride.txt <
rpm-build 0fba15
=0 /unreadable
rpm-build 0fba15
EOF
rpm-build 0fba15
touch test2-checkout/unreadable
rpm-build 0fba15
$OSTREE commit -b test2-unreadable --statoverride=statoverride.txt --tree=dir=test2-checkout
rpm-build 0fba15
$OSTREE fsck
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout -U -H test2-unreadable test2-checkout
rpm-build 0fba15
assert_file_has_mode test2-checkout/unreadable 400
rpm-build 0fba15
echo "ok bare-user handled unreadable file"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
mkdir -p components/{dbus,systemd}/usr/{bin,lib}
rpm-build 0fba15
echo dbus binary > components/dbus/usr/bin/dbus-daemon
rpm-build 0fba15
chmod a+x components/dbus/usr/bin/dbus-daemon
rpm-build 0fba15
echo dbus lib > components/dbus/usr/lib/libdbus.so.1
rpm-build 0fba15
echo dbus helper > components/dbus/usr/lib/dbus-daemon-helper
rpm-build 0fba15
chmod a+x components/dbus/usr/lib/dbus-daemon-helper
rpm-build 0fba15
echo systemd binary > components/systemd/usr/bin/systemd
rpm-build 0fba15
chmod a+x components/systemd/usr/bin/systemd
rpm-build 0fba15
echo systemd lib > components/systemd/usr/lib/libsystemd.so.1
rpm-build 0fba15
rpm-build 0fba15
# Make the gid on dbus 81 like fedora
rpm-build 0fba15
$OSTREE commit -b component-dbus --owner-uid 0 --owner-gid 81 --tree=dir=components/dbus
rpm-build 0fba15
$OSTREE commit -b component-systemd --owner-uid 0 --owner-gid 0 --tree=dir=components/systemd
rpm-build 0fba15
rm rootfs -rf
rpm-build 0fba15
for component in dbus systemd; do
rpm-build 0fba15
    $OSTREE checkout -U -H component-${component} --union rootfs
rpm-build 0fba15
done
rpm-build 0fba15
echo 'some rootfs data' > rootfs/usr/lib/cache.txt
rpm-build 0fba15
$OSTREE commit -b rootfs --link-checkout-speedup --tree=dir=rootfs
rpm-build 0fba15
$OSTREE ls rootfs /usr/bin/systemd >ls.txt
rpm-build 0fba15
assert_file_has_content ls.txt '^-007.. 0 0 .*/usr/bin/systemd'
rpm-build 0fba15
$OSTREE ls rootfs /usr/lib/dbus-daemon-helper >ls.txt
rpm-build 0fba15
assert_file_has_content ls.txt '^-007.. 0 81 .*/usr/lib/dbus-daemon-helper'
rpm-build 0fba15
echo "ok bare-user link-checkout-speedup maintains uids"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
$OSTREE checkout -H -U test2 test2-checkout
rpm-build 0fba15
# With --link-checkout-speedup, specifying --owner-uid should "win" by default.
rpm-build 0fba15
myuid=$(id -u)
rpm-build 0fba15
mygid=$(id -g)
rpm-build 0fba15
newuid=$((${myuid} + 1))
rpm-build 0fba15
newgid=$((${mygid} + 1))
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --owner-uid ${newuid} --owner-gid ${newgid} \
rpm-build 0fba15
        --link-checkout-speedup -b test2-linkcheckout-test --tree=dir=test2-checkout
rpm-build 0fba15
$OSTREE ls test2-linkcheckout-test /baz/cow > ls.txt
rpm-build 0fba15
assert_file_has_content ls.txt "^-006.. ${newuid} ${newgid} .*/baz/cow"
rpm-build 0fba15
rpm-build 0fba15
# But --devino-canonical should override that
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --owner-uid ${newuid} --owner-gid ${newgid} \
rpm-build 0fba15
        -I -b test2-devino-test --table-output --tree=dir=test2-checkout > out.txt
rpm-build 0fba15
$OSTREE ls test2-devino-test /baz/cow > ls.txt
rpm-build 0fba15
assert_file_has_content ls.txt "^-006.. ${myuid} ${mygid} .*/baz/cow"
rpm-build 0fba15
assert_file_has_content out.txt "Content Cache Hits: [1-9][0-9]*"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE refs --delete test2-{linkcheckout,devino}-test
rpm-build 0fba15
echo "ok commit with -I"