s4: torture: Ensure a failed file create doesn't create the file.
authorJeremy Allison <jra@samba.org>
Wed, 28 Mar 2018 17:54:30 +0000 (10:54 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 29 Mar 2018 18:31:34 +0000 (20:31 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13358

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
source4/torture/basic/delete.c

index 54815b95512d3a2275d5f6dc427809a0099028a1..bc23b5fd1d0fc4622aaba50062eff90895d79afb 100644 (file)
@@ -476,10 +476,18 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st
 static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
+       NTSTATUS status;
 
        del_clean_area(cli1, cli2);
 
        /* This should fail - we need to set DELETE_ACCESS. */
+
+       /*
+        * A file or directory create with DELETE_ON_CLOSE but
+        * without DELETE_ACCESS should fail with
+        * NT_STATUS_INVALID_PARAMETER.
+        */
+
        fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
                                      SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA,
                                      FILE_ATTRIBUTE_NORMAL, 
@@ -491,6 +499,25 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st
                                   talloc_asprintf(tctx, "open of %s succeeded should have failed!", 
                       fname));
 
+       /* Must fail with NT_STATUS_INVALID_PARAMETER. */
+       status = smbcli_nt_error(cli1->tree);
+       torture_assert_ntstatus_equal(tctx,
+                       status,
+                       NT_STATUS_INVALID_PARAMETER,
+                       talloc_asprintf(tctx, "create of %s should return "
+                               "NT_STATUS_INVALID_PARAMETER, got %s",
+                       fname,
+                       smbcli_errstr(cli1->tree)));
+
+       /* This should fail - the file should not have been created. */
+       status = smbcli_getatr(cli1->tree, fname, NULL, NULL, NULL);
+       torture_assert_ntstatus_equal(tctx,
+                       status,
+                       NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                       talloc_asprintf(tctx, "getattr of %s succeeded should "
+                               "not have been created !",
+                       fname));
+
        return true;
 }