selftest: tests for vfs_fruite file-id behavior
authorUri Simchoni <uri@samba.org>
Thu, 23 Mar 2017 19:32:04 +0000 (21:32 +0200)
committerRalph Boehme <slow@samba.org>
Sun, 26 Mar 2017 21:31:08 +0000 (23:31 +0200)
The test is in its own suite because it validates
our hackish workaround rather than some reference
implementation behavior.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sun Mar 26 23:31:08 CEST 2017 on sn-devel-144

source3/selftest/tests.py
source4/torture/vfs/fruit.c
source4/torture/vfs/vfs.c

index 54f5b7baa030b313270b4c0be2475d861c5b08e6..336ec9236479747cc9c18edc6a8d4edf4befe6fb 100755 (executable)
@@ -340,7 +340,7 @@ nbt = ["nbt.dgram" ]
 
 libsmbclient = ["libsmbclient"]
 
-vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk"]
+vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id"]
 
 tests= base + raw + smb2 + rpc + unix + local + rap + nbt + libsmbclient + idmap + vfs
 
@@ -428,6 +428,8 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_stream_depot --option=torture:share2=vfs_wo_fruit_stream_depot -U$USERNAME%$PASSWORD', 'streams_depot')
     elif t == "vfs.fruit_netatalk":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share')
+    elif t == "vfs.fruit_file_id":
+        plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD')
     elif t == "rpc.schannel_anon_setpw":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$%', description="anonymous password set")
         plansmbtorture4testsuite(t, "nt4_dc_schannel", '//$SERVER_IP/tmp -U$%', description="anonymous password set (schannel enforced server-side)")
index d74a153c1a2ffb7b1482a84f62e4ad43a293387a..857e7380cf260794b7da47a8d3e937e69658f57a 100644 (file)
@@ -3914,6 +3914,63 @@ done:
        return ret;
 }
 
+static bool test_zero_file_id(struct torture_context *tctx,
+                             struct smb2_tree *tree)
+{
+       const char *fname = "filtest_file_id";
+       struct smb2_create create = {0};
+       NTSTATUS status;
+       bool ret = true;
+       uint8_t zero_file_id[8] = {0};
+
+       torture_comment(tctx, "Testing zero file id\n");
+
+       ret = torture_setup_file(tctx, tree, fname, false);
+       torture_assert_goto(tctx, ret == true, ret, done, "torture_setup_file");
+
+       ZERO_STRUCT(create);
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+       create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.fname = fname;
+       create.in.query_on_disk_id = true;
+
+       status = smb2_create(tree, tctx, &create);
+       torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret,
+                                          done,
+                                          "test file could not be opened");
+       torture_assert_mem_not_equal_goto(tctx, create.out.on_disk_id,
+                                         zero_file_id, 8, ret, done,
+                                         "unexpected zero file id");
+
+       smb2_util_close(tree, create.out.file.handle);
+
+       ret = enable_aapl(tctx, tree);
+       torture_assert(tctx, ret == true, "enable_aapl failed");
+
+       ZERO_STRUCT(create);
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+       create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.fname = fname;
+       create.in.query_on_disk_id = true;
+
+       status = smb2_create(tree, tctx, &create);
+       torture_assert_ntstatus_equal_goto(
+           tctx, status, NT_STATUS_OK, ret, done,
+           "test file could not be opened with AAPL");
+       torture_assert_mem_equal_goto(tctx, create.out.on_disk_id, zero_file_id,
+                                     8, ret, done, "non-zero file id");
+
+       smb2_util_close(tree, create.out.file.handle);
+
+done:
+       smb2_util_unlink(tree, fname);
+       return ret;
+}
+
 /*
  * Note: This test depends on "vfs objects = catia fruit streams_xattr".  For
  * some tests torture must be run on the host it tests and takes an additional
@@ -3968,3 +4025,18 @@ struct torture_suite *torture_vfs_fruit_netatalk(void)
 
        return suite;
 }
+
+struct torture_suite *torture_vfs_fruit_file_id(void)
+{
+       struct torture_suite *suite =
+           torture_suite_create(talloc_autofree_context(), "fruit_file_id");
+
+       suite->description =
+           talloc_strdup(suite, "vfs_fruit tests for on-disk file ID that "
+                                "require fruit:zero_file_id=yes");
+
+       torture_suite_add_1smb2_test(suite, "zero file id if AAPL negotiated",
+                                    test_zero_file_id);
+
+       return suite;
+}
index a4f81256b09926ea176b68e0079753961c2016d6..710e93bf2efbecdba976bd363daeb3ca190ea6b8 100644 (file)
@@ -111,6 +111,7 @@ NTSTATUS torture_vfs_init(void)
        torture_suite_add_suite(suite, torture_vfs_fruit());
        torture_suite_add_suite(suite, torture_vfs_fruit_netatalk());
        torture_suite_add_suite(suite, torture_acl_xattr());
+       torture_suite_add_suite(suite, torture_vfs_fruit_file_id());
 
        torture_register_suite(suite);