From ad24ed10a97f5a0ce01d8ab508f5c4d61b15b8a1 Mon Sep 17 00:00:00 2001 From: Pawel Smolenski Date: Thu, 21 Nov 2024 14:37:08 +0100 Subject: [PATCH] Integration tests for 'file cp --mode' and 'file chmod --mode' --- testing/integrate.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/testing/integrate.sh b/testing/integrate.sh index 8e7678e0..1308fdde 100755 --- a/testing/integrate.sh +++ b/testing/integrate.sh @@ -626,6 +626,7 @@ EXPECTED_NEW_IMMUTABLE="i" CUR=$(printf "%d\n" "${ORIG_MODE}") NEW=$((CUR + 1)) EXPECTED_NEW_MODE=$(printf "0%o" "${NEW}") +EXPECTED_NEW_MODE_NO_LEAD_ZERO=$(printf "%o" "${NEW}") run_a_test false 0 file chown --uid=${EXPECTED_NEW_UID} ${LOGS}/test-file run_a_test false 0 file chgrp --gid=${EXPECTED_NEW_GID} ${LOGS}/test-file @@ -634,6 +635,10 @@ run_a_test false 0 file immutable --state=true ${LOGS}/test-file check_perms_mode ${LOGS}/test-file +# Should treat mode with and without leading zero the same +run_a_test false 0 file chmod --mode="${EXPECTED_NEW_MODE_NO_LEAD_ZERO}" ${LOGS}/test-file +check_perms_mode ${LOGS}/test-file + # Now do it with username/group args NOBODY_UID=$(id nobody | awk '{print $1}' | sed -e 's:uid=\([0-9][0-9]*\).*:\1:') NOBODY_GID=$(id nobody | awk '{print $2}' | sed -e 's:gid=\([0-9][0-9]*\).*:\1:') @@ -665,6 +670,10 @@ EXPECTED_NEW_GID=$((ORIG_GID + 1)) run_a_test false 0 file cp --overwrite --uid=${EXPECTED_NEW_UID} --gid=${EXPECTED_NEW_GID} --mode="${EXPECTED_NEW_MODE}" ${LOGS}/hosts ${LOGS}/cp-hosts check_perms_mode ${LOGS}/cp-hosts +# Should treat mode with and without leading zero the same +run_a_test false 0 file cp --overwrite --uid=${EXPECTED_NEW_UID} --gid=${EXPECTED_NEW_GID} --mode="${EXPECTED_NEW_MODE_NO_LEAD_ZERO}" ${LOGS}/hosts ${LOGS}/cp-hosts +check_perms_mode ${LOGS}/cp-hosts + # Now do it with username/group EXPECTED_NEW_UID=${NOBODY_UID} EXPECTED_NEW_GID=${NOBODY_GID}