From ef98e1c218b8cf6bbbc33d19ec8cb62ba078238e Mon Sep 17 00:00:00 2001 From: OpenAI Date: Fri, 19 Jun 2026 15:22:14 +0000 Subject: [PATCH] tests: run ncpfs host metadata checks privileged --- tests/nwfs/nwfs_ncpfs_dirquota_smoke.sh.in | 16 ++++++--- tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in | 38 ++++++++++++++-------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/tests/nwfs/nwfs_ncpfs_dirquota_smoke.sh.in b/tests/nwfs/nwfs_ncpfs_dirquota_smoke.sh.in index 6ede94a..78d3ff0 100644 --- a/tests/nwfs/nwfs_ncpfs_dirquota_smoke.sh.in +++ b/tests/nwfs/nwfs_ncpfs_dirquota_smoke.sh.in @@ -126,14 +126,22 @@ cleanup() { } trap cleanup EXIT HUP INT TERM -run_rm_rf() { +run_host_privileged() { if [ -n "${MARS_NWE_TEST_SUDO:-}" ]; then - ${MARS_NWE_TEST_SUDO} ${MARS_NWE_TEST_SUDO_FLAGS:-} rm -rf -- "$@" + ${MARS_NWE_TEST_SUDO} ${MARS_NWE_TEST_SUDO_FLAGS:-} "$@" else - rm -rf -- "$@" + "$@" fi } +run_rm_rf() { + run_host_privileged rm -rf -- "$@" +} + +host_dump() { + run_host_privileged "$DUMP" "$@" +} + purge_testdir_recycle() { for path in "$HOST_VOLUME_ROOT"/.recycle/*/"$TESTDIR" "$HOST_VOLUME_ROOT"/.salvage/*/"$TESTDIR"; do [ -e "$path" ] || continue @@ -174,7 +182,7 @@ verify_dump_limit() { echo "skipping host netware.metadata directory quota check for limit=$expected" >&2 return 0 fi - "$DUMP" "$HOST_VOLUME_ROOT/$TESTDIR" | tee "$DUMP_OUT" + host_dump "$HOST_VOLUME_ROOT/$TESTDIR" | tee "$DUMP_OUT" if [ "$expected" = 0 ]; then if grep -Eq 'dirQuotaLimit=.* active$' "$DUMP_OUT"; then echo "expected directory quota to be cleared on $HOST_VOLUME_ROOT/$TESTDIR" >&2 diff --git a/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in b/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in index 1357dd3..d1e0c5e 100755 --- a/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in +++ b/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in @@ -164,11 +164,23 @@ cleanup() { } trap cleanup EXIT HUP INT TERM +run_host_privileged() { + if [ -n "${MARS_NWE_TEST_SUDO:-}" ]; then + ${MARS_NWE_TEST_SUDO} ${MARS_NWE_TEST_SUDO_FLAGS:-} "$@" + else + "$@" + fi +} + +host_dump() { + run_host_privileged "$DUMP" "$@" +} + dump_host_acl() { path=$1 - stat -c ' unix.mode=%a owner=%U group=%G' "$path" + run_host_privileged stat -c ' unix.mode=%a owner=%U group=%G' "$path" if command -v getfacl >/dev/null 2>&1; then - getfacl -cp "$path" 2>/dev/null | sed 's/^/ acl./' || true + run_host_privileged getfacl -cp "$path" 2>/dev/null | sed 's/^/ acl./' || true fi } @@ -234,7 +246,7 @@ verify_host_acl_other() { exit 1 fi - getfacl -cp "$path" >"$ACL_DUMP" 2>/dev/null || { + run_host_privileged getfacl -cp "$path" >"$ACL_DUMP" 2>/dev/null || { echo "getfacl failed for $path" >&2 exit 1 } @@ -300,14 +312,14 @@ host_reset_testdir() { esac echo "resetting test directory host-side at $HOST_TEST_PATH" >&2 - rm -rf -- "$HOST_TEST_PATH" - mkdir -p -- "$HOST_TEST_PATH" + run_rm_rf "$HOST_TEST_PATH" + run_host_privileged mkdir -p -- "$HOST_TEST_PATH" } verify_dump_trustee_count() { path=$1 expected=$2 - "$DUMP" "$path" | tee "$RIGHTS_DUMP" + host_dump "$path" | tee "$RIGHTS_DUMP" if ! grep -q "trusteeCount=$expected active" "$RIGHTS_DUMP"; then echo "expected trusteeCount=$expected active in netware.metadata on $path" >&2 exit 1 @@ -319,7 +331,7 @@ verify_dosinfo_dump_attr() { path=$1 attr=$2 expected=$(printf '%016x' "$((attr))") - "$DUMP" "$path" | tee "$DOSINFO_DUMP" + host_dump "$path" | tee "$DOSINFO_DUMP" if ! grep -q "fileAttributes=0x$expected" "$DOSINFO_DUMP"; then echo "expected fileAttributes=0x$expected in netware.metadata on $path" >&2 exit 1 @@ -338,7 +350,7 @@ verify_dosinfo_dump_irm() { return 0 ;; esac - "$DUMP" "$path" | tee "$DOSINFO_DUMP" + host_dump "$path" | tee "$DOSINFO_DUMP" if ! grep -q "inheritedRightsMask=0x$expected active" "$DOSINFO_DUMP"; then echo "expected inheritedRightsMask=0x$expected active in netware.metadata on $path" >&2 exit 1 @@ -668,7 +680,7 @@ run_userquota_write_enforcement_test() { # The metadata fallback records the restriction for NCP readback, but it # cannot make the local filesystem reject writes. Only a real quota-backed # volume can enforce the following over-quota write. - "$DUMP" "$SYSROOT" >"$USERQUOTA_DUMP" 2>/dev/null || : + host_dump "$SYSROOT" >"$USERQUOTA_DUMP" 2>/dev/null || : if grep -q "netware.userquota.0:.*validate=0" "$USERQUOTA_DUMP" && \ grep -q "restriction=$USER_QUOTA_WRITE_LIMIT_4K" "$USERQUOTA_DUMP"; then echo "user quota write test uses metadata fallback on $VOLUME; skipping enforcement write" >&2 @@ -841,7 +853,7 @@ fi sync printf '\n# before trustee mutation\n' -"$DUMP" "$HOST_TEST_PATH" "$HOST_TEST_PATH/NCPMETA.TXT" +host_dump "$HOST_TEST_PATH" "$HOST_TEST_PATH/NCPMETA.TXT" if [ -n "$RIGHTS_MATRIX" ]; then if command -v nwgrant >/dev/null 2>&1 && command -v nwrevoke >/dev/null 2>&1 && \ @@ -937,7 +949,7 @@ if [ -n "$DIR_QUOTA_4K" ]; then "$DIRQUOTA_HELPER" -l "$DIR_QUOTA_4K" "$NCP_TEST_PATH" sync printf '\n# after directory quota set\n' - "$DUMP" "$HOST_TEST_PATH" | tee "$DIRQUOTA_DUMP" + host_dump "$HOST_TEST_PATH" | tee "$DIRQUOTA_DUMP" if ! grep -q "dirQuotaLimit=$DIR_QUOTA_4K active" "$DIRQUOTA_DUMP"; then echo "directory quota mutation did not reach netware.metadata on $HOST_TEST_PATH" >&2 echo "expected: dirQuotaLimit=$DIR_QUOTA_4K active" >&2 @@ -964,7 +976,7 @@ if [ -n "$USER_QUOTA_4K" ]; then fi sync printf '\n# after user quota set\n' - "$DUMP" "$SYSROOT" | tee "$USERQUOTA_DUMP" + host_dump "$SYSROOT" | tee "$USERQUOTA_DUMP" case "$USER_QUOTA_EXPECT" in metadata) if ! grep -q "netware.userquota.0:.*validate=0" "$USERQUOTA_DUMP" || \ @@ -1001,7 +1013,7 @@ if [ -n "$USER_QUOTA_4K" ]; then fi sync printf '\n# after user quota remove\n' - "$DUMP" "$SYSROOT" | tee "$USERQUOTA_DUMP" + host_dump "$SYSROOT" | tee "$USERQUOTA_DUMP" if [ "$USER_QUOTA_EXPECT" = metadata ]; then if ! grep -q "netware.userquota.0:.*validate=0" "$USERQUOTA_DUMP" || \ ! userquota_dump_is_unrestricted "$USERQUOTA_DUMP"; then