diff --git a/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in b/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in index 46370c0..db5e96f 100755 --- a/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in +++ b/tests/nwfs/nwfs_ncpfs_metadata_smoke.sh.in @@ -1,13 +1,14 @@ #!/bin/sh # Manual NCPFS smoke test. Requires a running mars-nwe server and ncpfs tools. -# It performs the mutation through NCP, then verifies the host SYS tree via +# It performs mutations through NCP, then verifies the host SYS tree via # netware.metadata/netware.userquota. Not registered in ctest intentionally. set -eu if [ "$#" -lt 4 ]; then - echo "usage: $0 SERVER USER PASSWORD HOST_SYSROOT [MOUNTPOINT] [TESTDIR]" >&2 - echo "example: $0 localhost supervisor secret /var/local/mars_nwe/SYS /mnt/nw-sys SYSTEM/NWFSTEST" >&2 + echo "usage: $0 SERVER USER PASSWORD HOST_SYSROOT [MOUNTPOINT] [TESTDIR] [VOLUME]" >&2 + echo "example: $0 localhost supervisor secret /var/local/mars_nwe/SYS /mnt/nw-sys SYSTEM/NWFSTEST SYS" >&2 echo "TESTDIR defaults to NWFSTEST. If the volume root is not creatable through NCP, pass an existing writable directory below SYS." >&2 + echo "Set NWFS_NCPFS_TRUSTEE_OBJECT and NWFS_NCPFS_TRUSTEE_TYPE to override the default GUEST user trustee mutation." >&2 exit 2 fi @@ -17,9 +18,15 @@ PASSWORD=$3 SYSROOT=$4 MOUNTPOINT=${5:-} TESTDIR=${6:-${NWFS_NCPFS_TESTDIR:-NWFSTEST}} +VOLUME=${7:-${NWFS_NCPFS_VOLUME:-SYS}} +TRUSTEE_OBJECT=${NWFS_NCPFS_TRUSTEE_OBJECT:-GUEST} +TRUSTEE_TYPE=${NWFS_NCPFS_TRUSTEE_TYPE:-1} +TRUSTEE_RIGHTS=${NWFS_NCPFS_TRUSTEE_RIGHTS:-RF} DUMP="@CMAKE_CURRENT_BINARY_DIR@/nwfs_xattr_dump" MKDIR_ERR=$(mktemp "${TMPDIR:-/tmp}/nwfs_ncpfs_mkdir.XXXXXX") WRITE_ERR=$(mktemp "${TMPDIR:-/tmp}/nwfs_ncpfs_write.XXXXXX") +GRANT_ERR=$(mktemp "${TMPDIR:-/tmp}/nwfs_ncpfs_grant.XXXXXX") +REVOKE_ERR=$(mktemp "${TMPDIR:-/tmp}/nwfs_ncpfs_revoke.XXXXXX") case "$TESTDIR" in /*|*..*) @@ -28,6 +35,13 @@ case "$TESTDIR" in ;; esac +case "$VOLUME" in + *:*|*/*|*..*|"") + echo "VOLUME must be a bare NetWare volume name: $VOLUME" >&2 + exit 2 + ;; +esac + if [ -z "$MOUNTPOINT" ]; then MOUNTPOINT=$(mktemp -d "${TMPDIR:-/tmp}/mars-ncpfs.XXXXXX") CLEAN_MOUNT=1 @@ -45,7 +59,7 @@ cleanup() { umount "$MOUNTPOINT" || true fi fi - rm -f "$MKDIR_ERR" "$WRITE_ERR" + rm -f "$MKDIR_ERR" "$WRITE_ERR" "$GRANT_ERR" "$REVOKE_ERR" [ "$CLEAN_MOUNT" = 1 ] && rmdir "$MOUNTPOINT" 2>/dev/null || true } trap cleanup EXIT HUP INT TERM @@ -59,32 +73,59 @@ fi NCP_TEST_PATH=$MOUNTPOINT/$TESTDIR HOST_TEST_PATH=$SYSROOT/$TESTDIR -if ! mkdir -p "$NCP_TEST_PATH" 2>"$MKDIR_ERR"; then - echo "cannot create SYS:$TESTDIR through NCPFS at $MOUNTPOINT" >&2 - cat "$MKDIR_ERR" >&2 || true - echo "The server was reached, but the NCP create was denied. Try passing a pre-existing writable test directory, e.g.:" >&2 - echo " $0 $SERVER $USER '***' $SYSROOT $MOUNTPOINT SYSTEM/NWFSTEST" >&2 - echo "or create/grant a directory first with DOS tools, then rerun with that relative SYS path." >&2 - exit 1 +NW_TEST_PATH=$VOLUME:$TESTDIR + +if [ -d "$NCP_TEST_PATH" ]; then + echo "using existing test directory $NCP_TEST_PATH" >&2 +else + if ! mkdir -p "$NCP_TEST_PATH" 2>"$MKDIR_ERR"; then + echo "cannot create $NW_TEST_PATH through NCPFS at $MOUNTPOINT" >&2 + cat "$MKDIR_ERR" >&2 || true + echo "The server was reached, but the NCP create was denied. Try passing a pre-existing writable test directory, e.g.:" >&2 + echo " $0 $SERVER $USER '***' $SYSROOT $MOUNTPOINT SYSTEM/NWFSTEST $VOLUME" >&2 + echo "or create/grant a directory first with DOS tools, then rerun with that relative SYS path." >&2 + exit 1 + fi fi : >"$MKDIR_ERR" if ! printf 'ncpfs metadata test\n' > "$NCP_TEST_PATH/NCPMETA.TXT" 2>"$WRITE_ERR"; then - echo "cannot write SYS:$TESTDIR/NCPMETA.TXT through NCPFS" >&2 + echo "cannot write $NW_TEST_PATH/NCPMETA.TXT through NCPFS" >&2 cat "$WRITE_ERR" >&2 || true exit 1 fi : >"$WRITE_ERR" -# Use ncpfs/nwfs tools if available. These commands are intentionally optional -# because tool names differ between distros/builds; the host-side dump below is -# the authoritative verification step for the NSS/OES xattrs. +sync +printf '\n# before trustee mutation\n' +"$DUMP" "$HOST_TEST_PATH" "$HOST_TEST_PATH/NCPMETA.TXT" + if command -v nwgrant >/dev/null 2>&1; then - nwgrant -S "$SERVER" -U "$USER" -P "$PASSWORD" -r '[RF]' "$TESTDIR" || true -fi -if command -v nwrevoke >/dev/null 2>&1; then - nwrevoke -S "$SERVER" -U "$USER" -P "$PASSWORD" -r '[W]' "$TESTDIR" || true + echo "granting [$TRUSTEE_RIGHTS] to $TRUSTEE_OBJECT type $TRUSTEE_TYPE on $NW_TEST_PATH" >&2 + if ! nwgrant -S "$SERVER" -U "$USER" -P "$PASSWORD" \ + -o "$TRUSTEE_OBJECT" -t "$TRUSTEE_TYPE" -r "[$TRUSTEE_RIGHTS]" "$NW_TEST_PATH" 2>"$GRANT_ERR"; then + echo "nwgrant failed" >&2 + cat "$GRANT_ERR" >&2 || true + exit 1 + fi + sync + printf '\n# after nwgrant\n' + "$DUMP" "$HOST_TEST_PATH" +else + echo "nwgrant not found; skipping trustee-add mutation" >&2 fi -sync -"$DUMP" "$HOST_TEST_PATH" "$HOST_TEST_PATH/NCPMETA.TXT" +if command -v nwrevoke >/dev/null 2>&1; then + echo "revoking $TRUSTEE_OBJECT type $TRUSTEE_TYPE on $NW_TEST_PATH" >&2 + if ! nwrevoke -S "$SERVER" -U "$USER" -P "$PASSWORD" \ + -o "$TRUSTEE_OBJECT" -t "$TRUSTEE_TYPE" "$NW_TEST_PATH" 2>"$REVOKE_ERR"; then + echo "nwrevoke failed" >&2 + cat "$REVOKE_ERR" >&2 || true + exit 1 + fi + sync + printf '\n# after nwrevoke\n' + "$DUMP" "$HOST_TEST_PATH" +else + echo "nwrevoke not found; skipping trustee-remove mutation" >&2 +fi