|
|
dd59ef |
diff -urNp coreutils-8.22-orig/tests/cp/cp-a-selinux.sh coreutils-8.22/tests/cp/cp-a-selinux.sh
|
|
|
dd59ef |
--- coreutils-8.22-orig/tests/cp/cp-a-selinux.sh 2013-12-04 15:48:30.000000000 +0100
|
|
|
dd59ef |
+++ coreutils-8.22/tests/cp/cp-a-selinux.sh 2015-08-17 13:59:27.837012142 +0200
|
|
|
dd59ef |
@@ -4,7 +4,7 @@
|
|
|
dd59ef |
# Check also locally if --preserve=context, -a and --preserve=all
|
|
|
dd59ef |
# does work
|
|
|
dd59ef |
|
|
|
dd59ef |
-# Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
|
|
dd59ef |
+# Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
|
|
dd59ef |
|
|
|
dd59ef |
# This program is free software: you can redistribute it and/or modify
|
|
|
dd59ef |
# it under the terms of the GNU General Public License as published by
|
|
|
dd59ef |
@@ -37,16 +37,36 @@ cp -a c d 2>err || framework_failure_
|
|
|
dd59ef |
cp --preserve=context c e || framework_failure_
|
|
|
dd59ef |
cp --preserve=all c f || framework_failure_
|
|
|
dd59ef |
ls -Z d | grep $ctx || fail=1
|
|
|
dd59ef |
-test -s err && fail=1 #there must be no stderr output for -a
|
|
|
dd59ef |
+# there must be no stderr output for -a
|
|
|
dd59ef |
+compare /dev/null err || fail=1
|
|
|
dd59ef |
ls -Z e | grep $ctx || fail=1
|
|
|
dd59ef |
ls -Z f | grep $ctx || fail=1
|
|
|
dd59ef |
+rm -f f
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+# Check handling of existing dirs which requires specific handling
|
|
|
dd59ef |
+# due to recursion, and was handled incorrectly in coreutils-8.22
|
|
|
dd59ef |
+# Note standard permissions are updated for existing directories
|
|
|
dd59ef |
+# in the destination, so SELinux contexts should be updated too.
|
|
|
dd59ef |
+chmod o+rw restore/existing_dir
|
|
|
dd59ef |
+mkdir -p backup/existing_dir/ || framework_failure_
|
|
|
dd59ef |
+ls -Zd backup/existing_dir > ed_ctx || fail=1
|
|
|
dd59ef |
+grep $ctx ed_ctx && framework_failure_
|
|
|
dd59ef |
+touch backup/existing_dir/file || framework_failure_
|
|
|
dd59ef |
+chcon $ctx backup/existing_dir/file || framework_failure_
|
|
|
dd59ef |
+# Set the dir context to ensure it is reset
|
|
|
dd59ef |
+mkdir -p --context="$ctx" restore/existing_dir || framework_failure_
|
|
|
dd59ef |
+# Copy and ensure existing directories updated
|
|
|
dd59ef |
+cp -a backup/. restore/
|
|
|
dd59ef |
+ls -Zd restore/existing_dir > ed_ctx || fail=1
|
|
|
dd59ef |
+grep $ctx ed_ctx &&
|
|
|
dd59ef |
+ { ls -lZd restore/existing_dir; fail=1; }
|
|
|
dd59ef |
|
|
|
dd59ef |
# Check restorecon (-Z) functionality for file and directory
|
|
|
dd59ef |
get_selinux_type() { ls -Zd "$1" | sed -n 's/.*:\(.*_t\):.*/\1/p'; }
|
|
|
dd59ef |
# Also make a dir with our known context
|
|
|
dd59ef |
mkdir c_d || framework_failure_
|
|
|
dd59ef |
chcon $ctx c_d || framework_failure_
|
|
|
dd59ef |
-# Get the type of this known context for file and dir
|
|
|
dd59ef |
+# Get the type of this known context for file and dir for tracing
|
|
|
dd59ef |
old_type_f=$(get_selinux_type c)
|
|
|
dd59ef |
old_type_d=$(get_selinux_type c_d)
|
|
|
dd59ef |
# Setup copies for manipulation with restorecon
|
|
|
dd59ef |
@@ -62,7 +82,7 @@ if restorecon Z1 Z1_d 2>/dev/null; then
|
|
|
dd59ef |
cpZ_type_f=$(get_selinux_type Z2)
|
|
|
dd59ef |
test "$cpZ_type_f" = "$new_type_f" || fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
- # Ensuze -Z overrides -a and that dirs are handled too
|
|
|
dd59ef |
+ # Ensure -Z overrides -a and that dirs are handled too
|
|
|
dd59ef |
cp -aZ c Z3 || fail=1
|
|
|
dd59ef |
cp -aZ c_d Z3_d || fail=1
|
|
|
dd59ef |
cpaZ_type_f=$(get_selinux_type Z3)
|
|
|
dd59ef |
@@ -93,27 +113,30 @@ test $skip = 1 \
|
|
|
dd59ef |
|
|
|
dd59ef |
cd mnt || framework_failure_
|
|
|
dd59ef |
|
|
|
dd59ef |
-echo > f || framework_failure_
|
|
|
dd59ef |
-
|
|
|
dd59ef |
+# Create files with hopefully different contexts
|
|
|
dd59ef |
+echo > ../f || framework_failure_
|
|
|
dd59ef |
echo > g || framework_failure_
|
|
|
dd59ef |
+test "$(stat -c%C ../f)" = "$(stat -c%C g)" &&
|
|
|
dd59ef |
+ skip_ "files on separate file systems have the same security context"
|
|
|
dd59ef |
+
|
|
|
dd59ef |
# /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp
|
|
|
dd59ef |
# succeed (giving no diagnostics), yet leaving the destination file empty.
|
|
|
dd59ef |
-cp -a f g 2>err || fail=1
|
|
|
dd59ef |
+cp -a ../f g 2>err || fail=1
|
|
|
dd59ef |
test -s g || fail=1 # The destination file must not be empty.
|
|
|
dd59ef |
-test -s err && fail=1 # There must be no stderr output.
|
|
|
dd59ef |
+compare /dev/null err || fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
# =====================================================
|
|
|
dd59ef |
# Here, we expect cp to succeed and not warn with "Operation not supported"
|
|
|
dd59ef |
rm -f g
|
|
|
dd59ef |
echo > g
|
|
|
dd59ef |
-cp --preserve=all f g 2>err || fail=1
|
|
|
dd59ef |
+cp --preserve=all ../f g 2>err || fail=1
|
|
|
dd59ef |
test -s g || fail=1
|
|
|
dd59ef |
grep "Operation not supported" err && fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
# =====================================================
|
|
|
dd59ef |
# The same as above except destination does not exist
|
|
|
dd59ef |
rm -f g
|
|
|
dd59ef |
-cp --preserve=all f g 2>err || fail=1
|
|
|
dd59ef |
+cp --preserve=all ../f g 2>err || fail=1
|
|
|
dd59ef |
test -s g || fail=1
|
|
|
dd59ef |
grep "Operation not supported" err && fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
@@ -133,9 +156,9 @@ echo > g
|
|
|
dd59ef |
# =====================================================
|
|
|
dd59ef |
# Here, we expect cp to fail, because it cannot set the SELinux
|
|
|
dd59ef |
# security context through NFS or a mount with fixed context.
|
|
|
dd59ef |
-cp --preserve=context f g 2> out && fail=1
|
|
|
dd59ef |
+cp --preserve=context ../f g 2> out && fail=1
|
|
|
dd59ef |
# Here, we *do* expect the destination to be empty.
|
|
|
dd59ef |
-test -s g && fail=1
|
|
|
dd59ef |
+compare /dev/null g || fail=1
|
|
|
dd59ef |
sed "s/ .g'.*//" out > k
|
|
|
dd59ef |
mv k out
|
|
|
dd59ef |
compare exp out || fail=1
|
|
|
dd59ef |
@@ -143,9 +166,9 @@ compare exp out || fail=1
|
|
|
dd59ef |
rm -f g
|
|
|
dd59ef |
echo > g
|
|
|
dd59ef |
# Check if -a option doesn't silence --preserve=context option diagnostics
|
|
|
dd59ef |
-cp -a --preserve=context f g 2> out2 && fail=1
|
|
|
dd59ef |
+cp -a --preserve=context ../f g 2> out2 && fail=1
|
|
|
dd59ef |
# Here, we *do* expect the destination to be empty.
|
|
|
dd59ef |
-test -s g && fail=1
|
|
|
dd59ef |
+compare /dev/null g || fail=1
|
|
|
dd59ef |
sed "s/ .g'.*//" out2 > k
|
|
|
dd59ef |
mv k out2
|
|
|
dd59ef |
compare exp out2 || fail=1
|
|
|
dd59ef |
@@ -154,31 +177,33 @@ for no_g_cmd in '' 'rm -f g'; do
|
|
|
dd59ef |
# restorecon equivalent. Note even though the context
|
|
|
dd59ef |
# returned from matchpathcon() will not match $ctx
|
|
|
dd59ef |
# the resulting ENOTSUP warning will be suppressed.
|
|
|
dd59ef |
+
|
|
|
dd59ef |
# With absolute path
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
- cp -Z f $(realpath g) || fail=1
|
|
|
dd59ef |
+ cp -Z ../f $(realpath g) || fail=1
|
|
|
dd59ef |
# With relative path
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
- cp -Z f g || fail=1
|
|
|
dd59ef |
+ cp -Z ../f g || fail=1
|
|
|
dd59ef |
# -Z overrides -a
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
- cp -Z -a f g || fail=1
|
|
|
dd59ef |
+ cp -Z -a ../f g || fail=1
|
|
|
dd59ef |
# -Z doesn't take an arg
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
- cp -Z "$ctx" f g && fail=1
|
|
|
dd59ef |
+ returns_ 1 cp -Z "$ctx" ../f g || fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
# Explicit context
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
# Explicitly defaulting to the global $ctx should work
|
|
|
dd59ef |
- cp --context="$ctx" f g || fail=1
|
|
|
dd59ef |
+ cp --context="$ctx" ../f g || fail=1
|
|
|
dd59ef |
# --context overrides -a
|
|
|
dd59ef |
$no_g_cmd
|
|
|
dd59ef |
- cp -a --context="$ctx" f g || fail=1
|
|
|
dd59ef |
+ cp -a --context="$ctx" ../f g || fail=1
|
|
|
dd59ef |
done
|
|
|
dd59ef |
|
|
|
dd59ef |
-# Mutually exlusive options
|
|
|
dd59ef |
-cp -Z --preserve=context f g && fail=1
|
|
|
dd59ef |
-cp --preserve=context -Z f g && fail=1
|
|
|
dd59ef |
-cp --preserve=context --context="$ctx" f g && fail=1
|
|
|
dd59ef |
+# Mutually exclusive options
|
|
|
dd59ef |
+returns_ 1 cp -Z --preserve=context ../f g || fail=1
|
|
|
dd59ef |
+returns_ 1 cp --preserve=context -Z ../f g || fail=1
|
|
|
dd59ef |
+returns_ 1 cp --preserve=context --context="$ctx" ../f g || fail=1
|
|
|
dd59ef |
|
|
|
dd59ef |
Exit $fail
|
|
|
dd59ef |
+
|
|
|
dd59ef |
diff -urNp coreutils-8.22-orig/tests/du/2g.sh coreutils-8.22/tests/du/2g.sh
|
|
|
dd59ef |
--- coreutils-8.22-orig/tests/du/2g.sh 2013-12-04 15:48:30.000000000 +0100
|
|
|
dd59ef |
+++ coreutils-8.22/tests/du/2g.sh 2015-08-17 13:59:37.349088611 +0200
|
|
|
dd59ef |
@@ -3,7 +3,7 @@
|
|
|
dd59ef |
# Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks
|
|
|
dd59ef |
# one of du's computations would overflow.
|
|
|
dd59ef |
|
|
|
dd59ef |
-# Copyright (C) 2005-2013 Free Software Foundation, Inc.
|
|
|
dd59ef |
+# Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
|
|
dd59ef |
|
|
|
dd59ef |
# This program is free software: you can redistribute it and/or modify
|
|
|
dd59ef |
# it under the terms of the GNU General Public License as published by
|
|
|
dd59ef |
@@ -24,13 +24,9 @@ print_ver_ du
|
|
|
dd59ef |
# Creating a 2GB file counts as 'very expensive'.
|
|
|
dd59ef |
very_expensive_
|
|
|
dd59ef |
|
|
|
dd59ef |
-
|
|
|
dd59ef |
# Get number of free kilobytes on current partition, so we can
|
|
|
dd59ef |
# skip this test if there is insufficient free space.
|
|
|
dd59ef |
-
|
|
|
dd59ef |
-# This technique relies on the fact that the 'Available' kilobyte
|
|
|
dd59ef |
-# count is the number just before the one with a trailing '%'.
|
|
|
dd59ef |
-free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //')
|
|
|
dd59ef |
+free_kb=$(df -k --output=avail . | tail -n1)
|
|
|
dd59ef |
case "$free_kb" in
|
|
|
dd59ef |
[0-9]*) ;;
|
|
|
dd59ef |
*) skip_ "invalid size from df: $free_kb";;
|
|
|
dd59ef |
@@ -45,16 +41,22 @@ test $min_kb -lt $free_kb ||
|
|
|
dd59ef |
}
|
|
|
dd59ef |
|
|
|
dd59ef |
big=big
|
|
|
dd59ef |
-rm -f $big
|
|
|
dd59ef |
-test -t 1 || printf 'creating a 2GB file...\n'
|
|
|
dd59ef |
-for i in $(seq 100); do
|
|
|
dd59ef |
- # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
|
|
|
dd59ef |
- printf %21474836s x >> $big || fail=1
|
|
|
dd59ef |
- # On the final iteration, append the remaining 48 bytes.
|
|
|
dd59ef |
- test $i = 100 && { printf %48s x >> $big || fail=1; }
|
|
|
dd59ef |
- test -t 1 && printf 'creating a 2GB file: %d%% complete\r' $i
|
|
|
dd59ef |
-done
|
|
|
dd59ef |
-echo
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+if ! fallocate -l2G $big; then
|
|
|
dd59ef |
+ rm -f $big
|
|
|
dd59ef |
+ {
|
|
|
dd59ef |
+ is_local_dir_ . || skip 'Not writing 2GB data to remote'
|
|
|
dd59ef |
+ for i in $(seq 100); do
|
|
|
dd59ef |
+ # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
|
|
|
dd59ef |
+ printf %21474836s x || fail=1
|
|
|
dd59ef |
+ done
|
|
|
dd59ef |
+ # After the final iteration, append the remaining 48 bytes.
|
|
|
dd59ef |
+ printf %48s x || fail=1
|
|
|
dd59ef |
+ } > $big || fail=1
|
|
|
dd59ef |
+fi
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+# The allocation may be done asynchronously (BTRFS for example)
|
|
|
dd59ef |
+sync $big || framework_failure_
|
|
|
dd59ef |
|
|
|
dd59ef |
du -k $big > out1 || fail=1
|
|
|
dd59ef |
rm -f $big
|
|
|
dd59ef |
diff -urNp coreutils-8.22-orig/tests/init.sh coreutils-8.22/tests/init.sh
|
|
|
dd59ef |
--- coreutils-8.22-orig/tests/init.sh 2013-12-04 15:48:30.000000000 +0100
|
|
|
dd59ef |
+++ coreutils-8.22/tests/init.sh 2015-08-17 13:59:19.900948318 +0200
|
|
|
dd59ef |
@@ -93,6 +93,27 @@ skip_ () { warn_ "$ME_: skipped test: $@
|
|
|
dd59ef |
fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
|
|
|
dd59ef |
framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; }
|
|
|
dd59ef |
|
|
|
dd59ef |
+# This is used to simplify checking of the return value
|
|
|
dd59ef |
+# which is useful when ensuring a command fails as desired.
|
|
|
dd59ef |
+# I.e., just doing `command ... &&fail=1` will not catch
|
|
|
dd59ef |
+# a segfault in command for example. With this helper you
|
|
|
dd59ef |
+# instead check an explicit exit code like
|
|
|
dd59ef |
+# returns_ 1 command ... || fail
|
|
|
dd59ef |
+returns_ () {
|
|
|
dd59ef |
+ # Disable tracing so it doesn't interfere with stderr of the wrapped command
|
|
|
dd59ef |
+ { set +x; } 2>/dev/null
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+ local exp_exit="$1"
|
|
|
dd59ef |
+ shift
|
|
|
dd59ef |
+ "$@"
|
|
|
dd59ef |
+ test $? -eq $exp_exit && ret_=0 || ret_=1
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+ if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then
|
|
|
dd59ef |
+ set -x
|
|
|
dd59ef |
+ fi
|
|
|
dd59ef |
+ { return $ret_; } 2>/dev/null
|
|
|
dd59ef |
+}
|
|
|
dd59ef |
+
|
|
|
dd59ef |
# Sanitize this shell to POSIX mode, if possible.
|
|
|
dd59ef |
DUALCASE=1; export DUALCASE
|
|
|
dd59ef |
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
|
|
dd59ef |
diff -urNp coreutils-8.22-orig/tests/local.mk coreutils-8.22/tests/local.mk
|
|
|
dd59ef |
--- coreutils-8.22-orig/tests/local.mk 2015-08-17 12:44:49.343344148 +0200
|
|
|
dd59ef |
+++ coreutils-8.22/tests/local.mk 2015-08-17 13:59:12.124885835 +0200
|
|
|
dd59ef |
@@ -121,7 +121,6 @@ all_root_tests = \
|
|
|
dd59ef |
tests/install/install-C-root.sh \
|
|
|
dd59ef |
tests/ls/capability.sh \
|
|
|
dd59ef |
tests/ls/nameless-uid.sh \
|
|
|
dd59ef |
- tests/misc/chcon.sh \
|
|
|
dd59ef |
tests/misc/chroot-credentials.sh \
|
|
|
dd59ef |
tests/misc/selinux.sh \
|
|
|
dd59ef |
tests/misc/truncate-owned-by-other.sh \
|