[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Feb 2 14:11:02 MST 2012


The branch, master has been updated
       via  fad9727 s3: Test for faulty xattr_tdb listxattr
       via  da0a7b2 s3-xattr_tdb: Fix listxattr
       via  b1a544f s3-vfstest: Add removexattr
       via  dbe9ff2 s3-vfstest: Add setxattr
       via  0a000f1 s3-vfstest: Add listxattr
       via  7d72424 s3-vfstest: Add getxattr
       via  c251667 s3: Move stream_depot test to script/tests
       via  bbde298 s3: Use ARRAY_SIZE in bsd_attr_list
       via  03300f2 s3: Simplify streams_depot a bit
      from  3bea5a1 s3-vfstest: Fix an uninitialized read in close

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fad9727f256588993b15c15cf3c24fe18b885da9
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 20:32:07 2012 +0100

    s3: Test for faulty xattr_tdb listxattr
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Thu Feb  2 22:10:49 CET 2012 on sn-devel-104

commit da0a7b2fcc967d4d0f6cab3f1a93c875da9e5498
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 18:11:32 2012 +0100

    s3-xattr_tdb: Fix listxattr
    
    We have to tell the caller how many bytes we actually want

commit b1a544fc80d22050415ec5749ce5c5936772ecd8
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 19:41:56 2012 +0100

    s3-vfstest: Add removexattr

commit dbe9ff29996287e6b91b69cd56d61e0a83f551a7
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 19:36:00 2012 +0100

    s3-vfstest: Add setxattr

commit 0a000f1ca7282f865e5e92ce508a67573fda6c76
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 17:45:09 2012 +0100

    s3-vfstest: Add listxattr

commit 7d72424f01f772147ceab3a1ed756dcdb8d240e8
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 16:36:18 2012 +0100

    s3-vfstest: Add getxattr

commit c251667b4f799544b4d965492a9ce5f61ebefb61
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 18:30:40 2012 +0100

    s3: Move stream_depot test to script/tests

commit bbde29824179fc78ee923ccd24e4039b96eb866d
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 2 17:49:22 2012 +0100

    s3: Use ARRAY_SIZE in bsd_attr_list

commit 03300f233c429caa9ec43cebebc603f4c7a513cb
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 1 20:40:06 2012 +0100

    s3: Simplify streams_depot a bit
    
    b0c0b949 is a bit involved. Passing down booleans is almost never
    very clear

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/system.c                               |    2 +-
 source3/modules/vfs_streams_depot.c                |   19 +--
 source3/modules/vfs_xattr_tdb.c                    |    2 +-
 source3/{ => script}/tests/stream-depot/run.sh     |    2 +-
 source3/{ => script}/tests/stream-depot/smb.conf   |    0
 .../{ => script}/tests/stream-depot/vfstest.cmd    |    0
 source3/script/tests/xattr-tdb-1/run.sh            |    7 +
 .../tests/xattr-tdb-1}/smb.conf                    |    2 +-
 source3/script/tests/xattr-tdb-1/vfstest.cmd       |    5 +
 source3/torture/cmd_vfs.c                          |  133 ++++++++++++++++++++
 10 files changed, 154 insertions(+), 18 deletions(-)
 rename source3/{ => script}/tests/stream-depot/run.sh (76%)
 copy source3/{ => script}/tests/stream-depot/smb.conf (100%)
 rename source3/{ => script}/tests/stream-depot/vfstest.cmd (100%)
 create mode 100755 source3/script/tests/xattr-tdb-1/run.sh
 rename source3/{tests/stream-depot => script/tests/xattr-tdb-1}/smb.conf (70%)
 create mode 100644 source3/script/tests/xattr-tdb-1/vfstest.cmd


Changeset truncated at 500 lines:

diff --git a/source3/lib/system.c b/source3/lib/system.c
index 821dd8d..a308014 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1797,7 +1797,7 @@ static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size
 	int i, t, len;
 	char *buf;
 	/* Iterate through extattr(2) namespaces */
-	for(t = 0; t < (sizeof(extattr)/sizeof(extattr[0])); t++) {
+	for(t = 0; t < ARRAY_SIZE(extattr); t++) {
 		switch(type) {
 #if defined(HAVE_EXTATTR_LIST_FILE)
 			case 0:
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index a188274..f268492 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -67,15 +67,10 @@ static uint32_t hash_fn(DATA_BLOB key)
  * an option to put in a special ACL entry for a non-existing group.
  */
 
-static bool file_is_valid(vfs_handle_struct *handle, const char *path,
-			  bool check_valid)
+static bool file_is_valid(vfs_handle_struct *handle, const char *path)
 {
 	char buf;
 
-	if (!check_valid) {
-		return true;
-	}
-
 	DEBUG(10, ("file_is_valid (%s) called\n", path));
 
 	if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
@@ -92,16 +87,11 @@ static bool file_is_valid(vfs_handle_struct *handle, const char *path,
 	return true;
 }
 
-static bool mark_file_valid(vfs_handle_struct *handle, const char *path,
-			    bool check_valid)
+static bool mark_file_valid(vfs_handle_struct *handle, const char *path)
 {
 	char buf = '1';
 	int ret;
 
-	if (!check_valid) {
-		return true;
-	}
-
 	DEBUG(10, ("marking file %s as valid\n", path));
 
 	ret = SMB_VFS_SETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
@@ -214,7 +204,8 @@ static char *stream_dir(vfs_handle_struct *handle,
 			goto fail;
 		}
 
-		if (file_is_valid(handle, smb_fname->base_name, check_valid)) {
+		if (!check_valid ||
+		    file_is_valid(handle, smb_fname->base_name)) {
 			return result;
 		}
 
@@ -294,7 +285,7 @@ static char *stream_dir(vfs_handle_struct *handle,
 		goto fail;
 	}
 
-	if (!mark_file_valid(handle, smb_fname->base_name, check_valid)) {
+	if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
 		goto fail;
 	}
 
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index f00caa4..1f3f20e 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -426,7 +426,7 @@ static ssize_t xattr_tdb_listattr(struct db_context *db_ctx,
 	if (len > size) {
 		TALLOC_FREE(attribs);
 		errno = ERANGE;
-		return -1;
+		return len;
 	}
 
 	len = 0;
diff --git a/source3/tests/stream-depot/run.sh b/source3/script/tests/stream-depot/run.sh
similarity index 76%
rename from source3/tests/stream-depot/run.sh
rename to source3/script/tests/stream-depot/run.sh
index f459aa3..f1e75fb 100755
--- a/source3/tests/stream-depot/run.sh
+++ b/source3/script/tests/stream-depot/run.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 rm -r .streams
-../../bin/vfstest -s smb.conf -f vfstest.cmd
+../../../bin/vfstest -s smb.conf -f vfstest.cmd
 NUM=`find .streams | wc -l`
 if [ $NUM -ne 3 ] ; then
     echo "streams_depot left ${NUM} in .streams, expected 3"
diff --git a/source3/tests/stream-depot/smb.conf b/source3/script/tests/stream-depot/smb.conf
similarity index 100%
copy from source3/tests/stream-depot/smb.conf
copy to source3/script/tests/stream-depot/smb.conf
diff --git a/source3/tests/stream-depot/vfstest.cmd b/source3/script/tests/stream-depot/vfstest.cmd
similarity index 100%
rename from source3/tests/stream-depot/vfstest.cmd
rename to source3/script/tests/stream-depot/vfstest.cmd
diff --git a/source3/script/tests/xattr-tdb-1/run.sh b/source3/script/tests/xattr-tdb-1/run.sh
new file mode 100755
index 0000000..2a1b6af
--- /dev/null
+++ b/source3/script/tests/xattr-tdb-1/run.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+if ../../../bin/vfstest -s smb.conf -f vfstest.cmd |
+    grep "NT_STATUS_ACCESS_DENIED" > /dev/null 2>&1
+then
+    exit 1
+fi
+exit 0
diff --git a/source3/tests/stream-depot/smb.conf b/source3/script/tests/xattr-tdb-1/smb.conf
similarity index 70%
rename from source3/tests/stream-depot/smb.conf
rename to source3/script/tests/xattr-tdb-1/smb.conf
index 426d23c..259b630 100644
--- a/source3/tests/stream-depot/smb.conf
+++ b/source3/script/tests/xattr-tdb-1/smb.conf
@@ -2,4 +2,4 @@
 # "path" is ignored by vfstest, it's always set to $(pwd)
 path = /tmp
 writable = yes
-vfs objects =  streams_depot xattr_tdb
+vfs objects = xattr_tdb
diff --git a/source3/script/tests/xattr-tdb-1/vfstest.cmd b/source3/script/tests/xattr-tdb-1/vfstest.cmd
new file mode 100644
index 0000000..585147d
--- /dev/null
+++ b/source3/script/tests/xattr-tdb-1/vfstest.cmd
@@ -0,0 +1,5 @@
+connect
+open x RC 0700
+setxattr x y z
+listxattr x
+unlink x
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 667cc16..8447bec 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -1147,6 +1147,131 @@ static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
 	return NT_STATUS_OK;
 }
 
+static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+			     int argc, const char **argv)
+{
+	uint8_t *buf;
+	ssize_t ret;
+
+	if (argc != 3) {
+		printf("Usage: getxattr <path> <xattr>\n");
+		return NT_STATUS_OK;
+	}
+
+	buf = NULL;
+
+	ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+			       talloc_get_size(buf));
+	if (ret == -1) {
+		int err = errno;
+		printf("getxattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	buf = talloc_array(mem_ctx, uint8_t, ret);
+	if (buf == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+			       talloc_get_size(buf));
+	if (ret == -1) {
+		int err = errno;
+		printf("getxattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	dump_data_file(buf, talloc_get_size(buf), false, stdout);
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS cmd_listxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+			      int argc, const char **argv)
+{
+	char *buf, *p;
+	ssize_t ret;
+
+	if (argc != 2) {
+		printf("Usage: listxattr <path>\n");
+		return NT_STATUS_OK;
+	}
+
+	buf = NULL;
+
+	ret = SMB_VFS_LISTXATTR(vfs->conn, argv[1], buf, talloc_get_size(buf));
+	if (ret == -1) {
+		int err = errno;
+		printf("listxattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	buf = talloc_array(mem_ctx, char, ret);
+	if (buf == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	ret = SMB_VFS_LISTXATTR(vfs->conn, argv[1], buf, talloc_get_size(buf));
+	if (ret == -1) {
+		int err = errno;
+		printf("listxattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	if (ret == 0) {
+		return NT_STATUS_OK;
+	}
+	if (buf[ret-1] != '\0') {
+		printf("listxattr returned non 0-terminated strings\n");
+		return NT_STATUS_INTERNAL_ERROR;
+	}
+
+	p = buf;
+	while (p < buf+ret) {
+		printf("%s\n", p);
+		p = strchr(p, 0);
+		p += 1;
+	}
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS cmd_setxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+			     int argc, const char **argv)
+{
+	ssize_t ret;
+	int flags = 0;
+
+	if ((argc < 4) || (argc > 5)) {
+		printf("Usage: setxattr <path> <xattr> <value> [flags]\n");
+		return NT_STATUS_OK;
+	}
+
+	if (argc == 5) {
+		flags = atoi(argv[4]);
+	}
+
+	ret = SMB_VFS_SETXATTR(vfs->conn, argv[1], argv[2],
+			       argv[3], strlen(argv[3]), flags);
+	if (ret == -1) {
+		int err = errno;
+		printf("setxattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS cmd_removexattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+				int argc, const char **argv)
+{
+	ssize_t ret;
+
+	if (argc != 3) {
+		printf("Usage: removexattr <path> <xattr>\n");
+		return NT_STATUS_OK;
+	}
+
+	ret = SMB_VFS_REMOVEXATTR(vfs->conn, argv[1], argv[2]);
+	if (ret == -1) {
+		int err = errno;
+		printf("removexattr returned (%s)\n", strerror(err));
+		return map_nt_error_from_unix(err);
+	}
+	return NT_STATUS_OK;
+}
+
 struct cmd_set vfs_commands[] = {
 
 	{ "VFS Commands" },
@@ -1187,5 +1312,13 @@ struct cmd_set vfs_commands[] = {
 	{ "link",   cmd_link,   "VFS link()",    "link <oldpath> <newpath>" },
 	{ "mknod",   cmd_mknod,   "VFS mknod()",    "mknod <path> <mode> <dev>" },
 	{ "realpath",   cmd_realpath,   "VFS realpath()",    "realpath <path>" },
+	{ "getxattr", cmd_getxattr, "VFS getxattr()",
+	  "getxattr <path> <name>" },
+	{ "listxattr", cmd_listxattr, "VFS listxattr()",
+	  "listxattr <path>" },
+	{ "setxattr", cmd_setxattr, "VFS setxattr()",
+	  "setxattr <path> <name> <value> [<flags>]" },
+	{ "removexattr", cmd_removexattr, "VFS removexattr()",
+	  "removexattr <path> <name>\n" },
 	{ NULL }
 };


-- 
Samba Shared Repository


More information about the samba-cvs mailing list