s3: torture: Add a MSDFS-ATTRIBUTE test.
authorJeremy Allison <jra@samba.org>
Mon, 1 Jun 2020 19:08:17 +0000 (12:08 -0700)
committerKarolin Seeger <kseeger@samba.org>
Fri, 26 Jun 2020 07:52:26 +0000 (07:52 +0000)
Framework to drive comes next.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 84134812e3447317125ae08b2a98848a2e4bbd65)

source3/torture/torture.c

index f07a0adf11545557db019f3e102762b039930d17..56258d3d2ad50ea0d75281190256407444f84046 100644 (file)
@@ -11405,6 +11405,81 @@ static bool run_large_readx(int dummy)
        return correct;
 }
 
+static NTSTATUS msdfs_attribute_list_fn(const char *mnt,
+                                 struct file_info *finfo,
+                                 const char *mask,
+                                 void *private_data)
+{
+       uint16_t *p_mode = (uint16_t *)private_data;
+
+       if (strequal(finfo->name, test_filename)) {
+               *p_mode = finfo->mode;
+       }
+
+       return NT_STATUS_OK;
+}
+
+static bool run_msdfs_attribute(int dummy)
+{
+       static struct cli_state *cli;
+       bool correct = false;
+       uint16_t mode = 0;
+       NTSTATUS status;
+
+       printf("Starting MSDFS-ATTRIBUTE test\n");
+
+       if (test_filename == NULL || test_filename[0] == '\0') {
+               printf("MSDFS-ATTRIBUTE test "
+                       "needs -f filename-of-msdfs-link\n");
+               return false;
+       }
+
+       /*
+        * NB. We use torture_open_connection_flags() not
+        * torture_open_connection() as the latter forces
+        * SMB1.
+        */
+       if (!torture_open_connection_flags(&cli, 0, 0)) {
+               return false;
+       }
+
+       smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+       status = cli_list(cli,
+                       "*",
+                       FILE_ATTRIBUTE_DIRECTORY,
+                       msdfs_attribute_list_fn,
+                       &mode);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_list failed with %s\n",
+                       nt_errstr(status));
+               goto out;
+       }
+       if ((mode & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
+               printf("file %s should have "
+                       "FILE_ATTRIBUTE_REPARSE_POINT set. attr = 0x%x\n",
+                       test_filename,
+                       (unsigned int)mode);
+               goto out;
+       }
+
+       if ((mode & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+               printf("file %s should have "
+                       "FILE_ATTRIBUTE_DIRECTORY set. attr = 0x%x\n",
+                       test_filename,
+                       (unsigned int)mode);
+               goto out;
+       }
+
+       correct = true;
+
+  out:
+
+       torture_close_connection(cli);
+       return correct;
+}
+
 static bool run_cli_echo(int dummy)
 {
        struct cli_state *cli;
@@ -14539,6 +14614,10 @@ static struct {
                .name  = "LARGE_READX",
                .fn    = run_large_readx,
        },
+       {
+               .name  = "MSDFS-ATTRIBUTE",
+               .fn    = run_msdfs_attribute,
+       },
        {
                .name  = "NTTRANS-CREATE",
                .fn    = run_nttrans_create,