LCOV - code coverage report
Current view: top level - source4/torture/smb2 - notify_disabled.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 39 44 88.6 %
Date: 2024-02-29 22:57:05 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    SMB2 notify test suite
       5             : 
       6             :    Copyright (C) Stefan Metzmacher 2006
       7             :    Copyright (C) Andrew Tridgell 2009
       8             :    Copyright (C) Ralph Boehme 2015
       9             : 
      10             :    This program is free software; you can redistribute it and/or modify
      11             :    it under the terms of the GNU General Public License as published by
      12             :    the Free Software Foundation; either version 3 of the License, or
      13             :    (at your option) any later version.
      14             : 
      15             :    This program is distributed in the hope that it will be useful,
      16             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :    GNU General Public License for more details.
      19             : 
      20             :    You should have received a copy of the GNU General Public License
      21             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      22             : */
      23             : 
      24             : #include "includes.h"
      25             : #include "libcli/smb2/smb2.h"
      26             : #include "libcli/smb2/smb2_calls.h"
      27             : #include "../libcli/smb/smbXcli_base.h"
      28             : 
      29             : #include "torture/torture.h"
      30             : #include "torture/smb2/proto.h"
      31             : #include "librpc/gen_ndr/ndr_security.h"
      32             : #include "libcli/security/security.h"
      33             : #include "torture/util.h"
      34             : 
      35             : #include "system/filesys.h"
      36             : #include "auth/credentials/credentials.h"
      37             : #include "lib/cmdline/cmdline.h"
      38             : #include "librpc/gen_ndr/security.h"
      39             : 
      40             : #include "lib/events/events.h"
      41             : 
      42             : #include "libcli/raw/libcliraw.h"
      43             : #include "libcli/raw/raw_proto.h"
      44             : #include "libcli/libcli.h"
      45             : 
      46             : #define BASEDIR "test_notify_disabled"
      47             : 
      48             : /*
      49             :    basic testing of change notify on directories
      50             : */
      51           2 : static bool torture_smb2_notify_disabled(struct torture_context *torture,
      52             :                                          struct smb2_tree *tree1)
      53             : {
      54           2 :         bool ret = true;
      55           0 :         NTSTATUS status;
      56           0 :         union smb_notify notify;
      57           0 :         union smb_open io;
      58           0 :         struct smb2_handle h1;
      59           0 :         struct smb2_request *req;
      60             : 
      61           2 :         torture_comment(torture, "TESTING CHANGE NOTIFY DISABLED\n");
      62             : 
      63           2 :         smb2_deltree(tree1, BASEDIR);
      64           2 :         smb2_util_rmdir(tree1, BASEDIR);
      65             :         /*
      66             :           get a handle on the directory
      67             :         */
      68           2 :         ZERO_STRUCT(io.smb2);
      69           2 :         io.generic.level = RAW_OPEN_SMB2;
      70           2 :         io.smb2.in.create_flags = 0;
      71           2 :         io.smb2.in.desired_access = SEC_FILE_ALL;
      72           2 :         io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
      73           2 :         io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
      74           2 :         io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
      75             :                                 NTCREATEX_SHARE_ACCESS_WRITE;
      76           2 :         io.smb2.in.alloc_size = 0;
      77           2 :         io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
      78           2 :         io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
      79           2 :         io.smb2.in.security_flags = 0;
      80           2 :         io.smb2.in.fname = BASEDIR;
      81             : 
      82           2 :         status = smb2_create(tree1, torture, &(io.smb2));
      83           2 :         torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_OK,
      84             :                                            ret, done, "smb2_create");
      85           2 :         h1 = io.smb2.out.file.handle;
      86             : 
      87           2 :         ZERO_STRUCT(notify.smb2);
      88           2 :         notify.smb2.level = RAW_NOTIFY_SMB2;
      89           2 :         notify.smb2.in.buffer_size = 1000;
      90           2 :         notify.smb2.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
      91           2 :         notify.smb2.in.file.handle = h1;
      92           2 :         notify.smb2.in.recursive = true;
      93             : 
      94           2 :         req = smb2_notify_send(tree1, &(notify.smb2));
      95           2 :         status = smb2_notify_recv(req, torture, &(notify.smb2));
      96           2 :         torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_NOT_IMPLEMENTED,
      97             :                                            ret, done, "smb2_notify_recv");
      98             : 
      99           2 :         status = smb2_util_close(tree1, h1);
     100           2 :         torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_OK,
     101             :                                            ret, done, "smb2_create");
     102             : 
     103           2 : done:
     104           2 :         smb2_deltree(tree1, BASEDIR);
     105           2 :         return ret;
     106             : }
     107             : 
     108             : /*
     109             :    basic testing of SMB2 change notify
     110             : */
     111        2354 : struct torture_suite *torture_smb2_notify_disabled_init(TALLOC_CTX *ctx)
     112             : {
     113        2354 :         struct torture_suite *suite = torture_suite_create(ctx,
     114             :                 "change_notify_disabled");
     115             : 
     116        2354 :         torture_suite_add_1smb2_test(suite, "notfiy_disabled", torture_smb2_notify_disabled);
     117        2354 :         suite->description = talloc_strdup(suite, "SMB2-CHANGE-NOTIFY-DISABLED tests");
     118             : 
     119        2354 :         return suite;
     120             : }

Generated by: LCOV version 1.14