X-Git-Url: http://gitweb.michael.orlitzky.com/?p=apply-default-acl.git;a=blobdiff_plain;f=run-tests.sh;h=d6e72bf6f46639cda021f0a65c6a887ad7b9a681;hp=da398138f6b7a67db70168dafb0fb5b59137412e;hb=44e1b8dbbc5f4c41a142467acc7da6a277a09d40;hpb=d56c49481c2ab666a34a1902b7e39f82819db4a3 diff --git a/run-tests.sh b/run-tests.sh index da39813..d6e72bf 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -13,13 +13,16 @@ EXIT_FAILURE=1 # present, we exit with a different (non-EXIT_FAILURE). EXIT_MISSING_USERS=2 -# Define the users that we'll use in the tests below. We store the -# names as variables to avoid repeating them everywhere. +# Define the users and groups that we'll use in the tests below. We +# store the names as variables to avoid repeating them everywhere. +# Since GROUPS is already part of everyone's environment, we need +# a different name. # # WARNING: These must be in alphabetical order; otherwise the getfacl # output will not match. # USERS=( bin daemon ) +TESTGROUPS=( bin daemon ) # Check to see if the above users exist. If not, bail. for idx in $( seq 0 $((${#USERS[@]} - 1)) ); do @@ -874,24 +877,109 @@ TARGET="${TESTDIR}" mkdir "${TARGET}/foo" mkdir "${TARGET}/bar" setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" -"${BIN}" --recursive "${TARGET}/foo" +"${BIN}" "${TARGET}/foo" EXPECTED=$( getfacl --omit-header "${TARGET}/foo" ) pushd "${TARGET}/bar" > /dev/null -"${BIN}" --recursive "." +"${BIN}" "." ACTUAL=$( getfacl --omit-header "." ) popd > /dev/null compare +# Ensure that "." works as an argument (recursive). +((TESTNUM++)) +TARGET="${TESTDIR}" +mkdir -p "${TARGET}/foo/baz" +mkdir -p "${TARGET}/bar/baz" +setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" +"${BIN}" --recursive "${TARGET}/foo" +EXPECTED=$( getfacl --omit-header "${TARGET}/foo/baz" ) +pushd "${TARGET}/bar" > /dev/null +"${BIN}" --recursive "." +ACTUAL=$( getfacl --omit-header "./baz" ) +popd > /dev/null +compare + +# Ensure that "./" works as an argument. +((TESTNUM++)) +TARGET="${TESTDIR}" +mkdir "${TARGET}/foo" +mkdir "${TARGET}/bar" +setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" +"${BIN}" "${TARGET}/foo" +EXPECTED=$( getfacl --omit-header "${TARGET}/foo" ) +pushd "${TARGET}/bar" > /dev/null +"${BIN}" "./" +ACTUAL=$( getfacl --omit-header "./" ) +popd > /dev/null +compare + # Ensure that ".." works as an argument. ((TESTNUM++)) TARGET="${TESTDIR}" mkdir "${TARGET}/foo" mkdir -p "${TARGET}/bar/baz" setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" -"${BIN}" --recursive "${TARGET}/foo" +"${BIN}" "${TARGET}/foo" EXPECTED=$( getfacl --omit-header "${TARGET}/foo" ) pushd "${TARGET}/bar/baz" > /dev/null -"${BIN}" --recursive ".." +"${BIN}" ".." ACTUAL=$( getfacl --omit-header ".." ) popd > /dev/null compare + +# Ensure that ".." works as an argument (recursive). +((TESTNUM++)) +TARGET="${TESTDIR}" +mkdir -p "${TARGET}/foo/baz" +mkdir -p "${TARGET}/bar/baz" +setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" +"${BIN}" --recursive "${TARGET}/foo" +EXPECTED=$( getfacl --omit-header "${TARGET}/foo/baz" ) +pushd "${TARGET}/bar/baz" > /dev/null +"${BIN}" --recursive ".." +ACTUAL=$( getfacl --omit-header "." ) +popd > /dev/null +compare + +# Ensure that "../" works as an argument. +((TESTNUM++)) +TARGET="${TESTDIR}" +mkdir "${TARGET}/foo" +mkdir -p "${TARGET}/bar/baz" +setfacl --default --modify user:${USERS[0]}:rw "${TARGET}" +"${BIN}" "${TARGET}/foo" +EXPECTED=$( getfacl --omit-header "${TARGET}/foo" ) +pushd "${TARGET}/bar/baz" > /dev/null +"${BIN}" "../" +ACTUAL=$( getfacl --omit-header "../" ) +popd > /dev/null +compare + + +# Ensure that multiple named-user and named-group entries all get +# applied individually rather than the last one taking precedence. +# This is a regression test against a bug that made it into a release +# and was reported by Michał Bartoszkiewicz. +((TESTNUM++)) +TARGET="${TESTDIR}" +TARGET="${TESTDIR}"/foo +touch "${TARGET}" +setfacl -d -m user:${USERS[0]}:rw- "${TESTDIR}" +setfacl -d -m group:${TESTGROUPS[0]}:rw- "${TESTDIR}" +setfacl -d -m user:${USERS[1]}:--- "${TESTDIR}" +setfacl -d -m group:${TESTGROUPS[1]}:--- "${TESTDIR}" +"${BIN}" "${TARGET}" +EXPECTED=$(cat <