Blame tests/test-basic-user-only.sh

Packit Service 2a3f3d
#!/bin/bash
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# SPDX-License-Identifier: LGPL-2.0+
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is free software; you can redistribute it and/or
Packit Service 2a3f3d
# modify it under the terms of the GNU Lesser General Public
Packit Service 2a3f3d
# License as published by the Free Software Foundation; either
Packit Service 2a3f3d
# version 2 of the License, or (at your option) any later version.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is distributed in the hope that it will be useful,
Packit Service 2a3f3d
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2a3f3d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 2a3f3d
# Lesser General Public License for more details.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# You should have received a copy of the GNU Lesser General Public
Packit Service 2a3f3d
# License along with this library; if not, write to the
Packit Service 2a3f3d
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service 2a3f3d
# Boston, MA 02111-1307, USA.
Packit Service 2a3f3d
Packit Service 2a3f3d
set -euo pipefail
Packit Service 2a3f3d
Packit Service 2a3f3d
. $(dirname $0)/libtest.sh
Packit Service 2a3f3d
Packit Service 2a3f3d
mode="bare-user-only"
Packit Service 2a3f3d
setup_test_repository "$mode"
Packit Service 2a3f3d
extra_basic_tests=5
Packit Service 2a3f3d
. $(dirname $0)/basic-test.sh
Packit Service 2a3f3d
Packit Service 2a3f3d
$CMD_PREFIX ostree --version > version.yaml
Packit Service 2a3f3d
python3 -c 'import yaml; yaml.safe_load(open("version.yaml"))'
Packit Service 2a3f3d
echo "ok yaml version"
Packit Service 2a3f3d
Packit Service 2a3f3d
# Reset things so we don't inherit a lot of state from earlier tests
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
rm repo files -rf
Packit Service 2a3f3d
ostree_repo_init repo init --mode=bare-user-only
Packit Service 2a3f3d
Packit Service 2a3f3d
# Init an archive repo where we'll store content that can't go into bare-user
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
rm repo-input -rf
Packit Service 2a3f3d
ostree_repo_init repo-input init --mode=archive
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
cat > statoverride.txt <
Packit Service 2a3f3d
2048 /some-setuid
Packit Service 2a3f3d
EOF
Packit Service 2a3f3d
mkdir -p files/
Packit Service 2a3f3d
echo "a setuid file" > files/some-setuid
Packit Service 2a3f3d
chmod 0644 files/some-setuid
Packit Service 2a3f3d
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=files
Packit Service 2a3f3d
if $CMD_PREFIX ostree pull-local --repo=repo repo-input 2>err.txt; then
Packit Service 2a3f3d
    assert_not_reached "copying suid file into bare-user worked?"
Packit Service 2a3f3d
fi
Packit Service 2a3f3d
assert_file_has_content err.txt "Content object.*invalid mode.*with bits 040.*"
Packit Service 2a3f3d
echo "ok failed to commit suid"
Packit Service 2a3f3d
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
rm repo-input -rf
Packit Service 2a3f3d
ostree_repo_init repo-input init --mode=archive
Packit Service 2a3f3d
rm files -rf && mkdir files
Packit Service 2a3f3d
echo "a group writable file" > files/some-group-writable
Packit Service 2a3f3d
chmod 0664 files/some-group-writable
Packit Service 2a3f3d
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-group-writable --tree=dir=files
Packit Service 2a3f3d
$CMD_PREFIX ostree pull-local --repo=repo repo-input
Packit Service 2a3f3d
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-group-writable groupwritable-co
Packit Service 2a3f3d
assert_file_has_mode groupwritable-co/some-group-writable 664
Packit Service 2a3f3d
echo "ok supported group writable"
Packit Service 2a3f3d
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
rm repo-input -rf
Packit Service 2a3f3d
ostree_repo_init repo-input init --mode=archive
Packit Service 2a3f3d
rm files -rf && mkdir files
Packit Service 2a3f3d
mkdir files/worldwritable-dir
Packit Service 2a3f3d
chmod a+w files/worldwritable-dir
Packit Service 2a3f3d
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-dir-world-writable --tree=dir=files
Packit Service 2a3f3d
$CMD_PREFIX ostree pull-local --repo=repo repo-input
Packit Service 2a3f3d
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
Packit Service 2a3f3d
assert_file_has_mode dir-co/worldwritable-dir 775
Packit Service 2a3f3d
echo "ok didn't make world-writable dir"
Packit Service 2a3f3d
Packit Service 2a3f3d
if ! skip_one_without_user_xattrs; then
Packit Service 2a3f3d
    cd ${test_tmpdir}
Packit Service 2a3f3d
    rm repo-input -rf
Packit Service 2a3f3d
    rm repo -rf
Packit Service 2a3f3d
    ostree_repo_init repo init --mode=bare-user-only
Packit Service 2a3f3d
    ostree_repo_init repo-input init --mode=bare-user
Packit Service 2a3f3d
    rm files -rf && mkdir files
Packit Service 2a3f3d
    echo afile > files/afile
Packit Service 2a3f3d
    ln -s afile files/afile-link
Packit Service 2a3f3d
    $CMD_PREFIX ostree --repo=repo-input commit --canonical-permissions -b testtree --tree=dir=files
Packit Service 2a3f3d
    afile_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile)
Packit Service 2a3f3d
    afile_link_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile-link)
Packit Service 2a3f3d
    $CMD_PREFIX ostree pull-local --repo=repo repo-input
Packit Service 2a3f3d
    assert_files_hardlinked repo/${afile_relobjpath} repo-input/${afile_relobjpath}
Packit Service 2a3f3d
    if files_are_hardlinked repo/${afile_link_relobjpath} repo-input/${afile_link_relobjpath}; then
Packit Service 2a3f3d
        assert_not_reached "symlinks hardlinked across bare-user?"
Packit Service 2a3f3d
    fi
Packit Service 2a3f3d
    $OSTREE fsck -q
Packit Service 2a3f3d
    echo "ok hardlink pull from bare-user"
Packit Service 2a3f3d
fi