* tests/mv/meta-to-xpart.sh: Add new test. * tests/local.mk: Reference new test. --- tests/local.mk | 1 + tests/mv/meta-to-xpart.sh | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 tests/mv/meta-to-xpart.sh
diff --git a/tests/local.mk b/tests/local.mk index 955de4e22..f84dd4f41 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -135,6 +135,7 @@ all_root_tests = \ tests/mkdir/smack-root.sh \ tests/mv/hardlink-case.sh \ tests/mv/sticky-to-xpart.sh \ + tests/mv/meta-to-xpart.sh \ tests/mv/mv-special-2.sh \ tests/rm/fail-2eperm.sh \ tests/rm/no-give-up.sh \ diff --git a/tests/mv/meta-to-xpart.sh b/tests/mv/meta-to-xpart.sh new file mode 100755 index 000000000..c9d3b7aa7 --- /dev/null +++ b/tests/mv/meta-to-xpart.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# A cross-partition move of a file should maintain user and permissions + +# Copyright (C) 2025 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ mv +require_root_ + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/tests/other-fs-tmpdir" + +touch non-root-owned || framework_failure_ +chown "$NON_ROOT_USERNAME" non-root-owned || + skip_ "can't chown to $NON_ROOT_USERNAME" +# Also check setuid bit, since it's security sensitive +# and also dependent on correct order of meta data update. +chmod u+s non-root-owned || + skip_ "can't set setuid bit" + +mv non-root-owned "$other_partition_tmpdir" || fail=1 + +test -u "$other_partition_tmpdir"/non-root-owned || fail=1 +test $(stat -c %U "$other_partition_tmpdir"/non-root-owned) = \ + "$NON_ROOT_USERNAME" || fail=1 + +Exit $fail -- 2.51.1
