The branch, master has been updated via 41edcf8 vfs_catia: testcase - add missing pieces via 3966473 vfs_catia: testcase - implement vfstest additions via e10c815 vfs_catia: write a testcase - add a translate command to vfstest via b40c4b0 vfstest: fix the "-c" multiple-command option from 389197e scripting: No longer install samba_upgradeprovision
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 41edcf849a592d0d358621fdffbab82befa76e02 Author: Guenter Kukkukk <ku...@samba.org> Date: Tue Mar 12 01:44:59 2013 +0100 vfs_catia: testcase - add missing pieces Signed-off-by: Guenter Kukkukk <ku...@samba.org> Reviewed-by: Richard Sharpe <realrichardsha...@samba.org> Autobuild-User(master): Richard Sharpe <sha...@samba.org> Autobuild-Date(master): Tue Mar 12 07:36:13 CET 2013 on sn-devel-104 commit 396647340f233e30277d6d6081465b7b6d855181 Author: Guenter Kukkukk <ku...@samba.org> Date: Mon Mar 11 05:34:27 2013 +0100 vfs_catia: testcase - implement vfstest additions Signed-off-by: Guenter Kukkukk <ku...@samba.org> Reviewed-by: Richard Sharpe <realrichardsha...@gmail.com> commit e10c81553b1691ae1b7c260719d724beed61bb48 Author: Guenter Kukkukk <ku...@samba.org> Date: Sun Mar 10 05:43:24 2013 +0100 vfs_catia: write a testcase - add a translate command to vfstest first approach Signed-off-by: Guenter Kukkukk <ku...@samba.org> Reviewed-by: Richard Sharpe <realrichardsha...@gmail.com> commit b40c4b069a600af86c1f20ee09cbf5052c1552bf Author: Guenter Kukkukk <ku...@samba.org> Date: Tue Mar 12 04:51:03 2013 +0100 vfstest: fix the "-c" multiple-command option Signed-off-by: Guenter Kukkukk <ku...@samba.org> Reviewed-by: Richard Sharpe <realrichardsha...@gmail.com> ----------------------------------------------------------------------- Summary of changes: source3/script/tests/vfstest-catia/run.sh | 102 +++++++++++++++++++++++ source3/script/tests/vfstest-catia/vfstest.cmd | 2 + source3/script/tests/vfstest-catia/vfstest1.cmd | 2 + source3/selftest/tests.py | 1 + source3/torture/cmd_vfs.c | 75 +++++++++++++++++ source3/torture/vfstest.c | 7 ++- 6 files changed, 188 insertions(+), 1 deletions(-) create mode 100755 source3/script/tests/vfstest-catia/run.sh create mode 100644 source3/script/tests/vfstest-catia/vfstest.cmd create mode 100644 source3/script/tests/vfstest-catia/vfstest1.cmd Changeset truncated at 500 lines: diff --git a/source3/script/tests/vfstest-catia/run.sh b/source3/script/tests/vfstest-catia/run.sh new file mode 100755 index 0000000..c345f11 --- /dev/null +++ b/source3/script/tests/vfstest-catia/run.sh @@ -0,0 +1,102 @@ +#!/bin/sh +if [ $# -lt 2 ]; then +cat <<EOF +Usage: run.sh VFSTEST PREFIX +EOF +exit 1; +fi + +TESTBASE=`dirname $0` +VFSTEST=$1 +PREFIX=$2 +shift 2 +ADDARGS="$*" + +VFSTEST_PREFIX=vfstest +VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX) + +# We could pass in the --option=... via tests.py as ADDARGS +# Atm i've choosen to specify them here: + +MYARGS1="--option=vfsobjects=catia" +MYARGS2="--option=catia:mappings=0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6,0x20:0xb1" + +# vars for the translation test: +# a) here for unix-to-windows test +UNIX_FILE="a\\a:a*a?a<a>a|a" +# translated window file name +WIN_FILE="aÿa÷a¤a¿a«a»a¦a" + +# b) here for windows-to-unix test +WIN_DIR="dir_aÿa÷a¤a¿a«a»a¦a" +# translated unix directory name +UNIX_DIR="dir_a\a:a*a?a<a>a|a" + +incdir=`dirname $0`/../../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +cd $VFSTEST_TMPDIR || exit 1 + +# create unix file in tmpdir +touch $UNIX_FILE || exit 1 + +# test "translate" unix-to-windows +test_vfstest() +{ + cmd='$VFSTEST -f $TESTBASE/vfstest.cmd $MYARGS1 $MYARGS2 $ADDARGS ' + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep $WIN_FILE >/dev/null 2>&1 + + if [ $? = 0 ] ; then + echo "ALL IS WORKING" + true + else + false + fi +} + +# test the mkdir call with special windows chars +# and then check the created unix directory name +test_vfstest_dir() +{ + cmd='$VFSTEST -f $TESTBASE/vfstest1.cmd $MYARGS1 $MYARGS2 $ADDARGS ' + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + NUM=`find $UNIX_DIR | wc -l` + if [ $NUM -ne 1 ] ; then + echo "Cannot find $UNIX_DIR" + false + else + true + fi +} + +testit "vfstest_catia" test_vfstest || failed=`expr $failed + 1` + +if [ $failed = 0 ] ; then + testit "vfstest1_catia" test_vfstest_dir || failed=`expr $failed + 1` +fi + +# Cleanup: remove tempdir +rm -R $VFSTEST_TMPDIR + +exit $failed diff --git a/source3/script/tests/vfstest-catia/vfstest.cmd b/source3/script/tests/vfstest-catia/vfstest.cmd new file mode 100644 index 0000000..5acecbc --- /dev/null +++ b/source3/script/tests/vfstest-catia/vfstest.cmd @@ -0,0 +1,2 @@ +connect +translate_name a\a:a*a?a<a>a|a diff --git a/source3/script/tests/vfstest-catia/vfstest1.cmd b/source3/script/tests/vfstest-catia/vfstest1.cmd new file mode 100644 index 0000000..ef56159 --- /dev/null +++ b/source3/script/tests/vfstest-catia/vfstest1.cmd @@ -0,0 +1,2 @@ +connect +mkdir dir_aÿa÷a¤a¿a«a»a¦a diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 740bd4a..30253ca 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -138,6 +138,7 @@ tests = ["--ping", "--separator", plantestsuite("samba.vfstest.stream_depot", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/stream-depot/run.sh"), binpath("vfstest"), "$PREFIX", configuration]) plantestsuite("samba.vfstest.xattr-tdb-1", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/xattr-tdb-1/run.sh"), binpath("vfstest"), "$PREFIX", configuration]) plantestsuite("samba.vfstest.acl", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/vfstest-acl/run.sh"), binpath("vfstest"), "$PREFIX", configuration]) +plantestsuite("samba.vfstest.catia", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/vfstest-catia/run.sh"), binpath("vfstest"), "$PREFIX", configuration]) for options in ["--option=clientusespnego=no", " --option=clientntlmv2auth=no --option=clientlanmanauth=yes --max-protocol=LANMAN2", ""]: env = "s3dc" diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 15f0c5a..72bc2ca 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -1704,6 +1704,80 @@ static NTSTATUS cmd_sys_acl_delete_def_file(struct vfs_state *vfs, TALLOC_CTX *m return NT_STATUS_OK; } +/* Afaik translate name was first introduced with vfs_catia, to be able + to translate unix file/dir-names, containing invalid windows characters, + to valid windows names. + The used translation direction is always unix --> windows +*/ +static NTSTATUS cmd_translate_name(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + int ret; + struct dirent *dent = NULL; + SMB_STRUCT_STAT st; + bool found = false; + char *translated = NULL; + NTSTATUS status; + + if (argc != 2) { + DEBUG(0, ("Usage: translate_name unix_filename\n")); + return NT_STATUS_UNSUCCESSFUL; + } + + vfs->currentdir = SMB_VFS_OPENDIR(vfs->conn, ".", NULL, 0); + if (vfs->currentdir == NULL) { + DEBUG(0, ("cmd_translate_name: opendir error=%d (%s)\n", + errno, strerror(errno))); + return NT_STATUS_UNSUCCESSFUL; + } + + while (true) { + dent = SMB_VFS_READDIR(vfs->conn, vfs->currentdir, &st); + if (dent == NULL) { + break; + } + if (strcmp (dent->d_name, argv[1]) == 0) { + found = true; + break; + } + }; + + if (!found) { + DEBUG(0, ("cmd_translate_name: file '%s' not found.\n", + argv[1])); + status = NT_STATUS_UNSUCCESSFUL; + goto cleanup; + } + status = SMB_VFS_TRANSLATE_NAME(vfs->conn, dent->d_name, + vfs_translate_to_windows, + talloc_tos(), &translated); + if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { + DEBUG(0, ("cmd_translate_name: file '%s' cannot be " + "translated\n", argv[1])); + TALLOC_FREE(translated); + goto cleanup; + } + /* translation success. But that could also mean + that translating "aaa" to "aaa" was successful :-( + */ + DEBUG(0, ("cmd_translate_name: file '%s' --> '%s'\n", + argv[1], translated)); + + TALLOC_FREE(translated); + +cleanup: + ret = SMB_VFS_CLOSEDIR(vfs->conn, vfs->currentdir); + if (ret == -1) { + DEBUG(0, ("cmd_translate_name: closedir failure: %s\n", + strerror(errno))); + return NT_STATUS_UNSUCCESSFUL; + } + + vfs->currentdir = NULL; + return status;; +} + + struct cmd_set vfs_commands[] = { { "VFS Commands" }, @@ -1773,5 +1847,6 @@ struct cmd_set vfs_commands[] = { { "test_chain", cmd_test_chain, "test chain code", "test_chain" }, + { "translate_name", cmd_translate_name, "VFS translate_name()", "translate_name unix_filename" }, { NULL } }; diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c index 54365e0..2cec687 100644 --- a/source3/torture/vfstest.c +++ b/source3/torture/vfstest.c @@ -108,7 +108,12 @@ static char *next_command(TALLOC_CTX *ctx, char **cmdstr) if (p) *p = '\0'; command = talloc_strdup(ctx, *cmdstr); - *cmdstr = p; + + /* Pass back the remaining cmdstring + (a trailing delimiter ";" does also work), + or NULL at last cmdstring. + */ + *cmdstr = p ? p + 1 : p; return command; } -- Samba Shared Repository