The branch, v4-7-test has been updated via ca441a0 python: Fix talloc frame use in make_simple_acl(). via 03cfdb0 s3: smbd: printing: Re-implement delete-on-close semantics for print files missing since 3.5.x. via 1f1edc0 s4-heimdal: Fix the format-truncation errors. via db362df s3: smbtorture: Add new SMB2-DIR-FSYNC test to show behavior of FSYNC on directories. via a743be8 s3: smbd: Fix SMB2-FLUSH against directories. from d3c2cc2 smbd: Flush dfree memcache on service reload
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-7-test - Log ----------------------------------------------------------------- commit ca441a0f8ddde4458cb729eaabc6906a45458f1d Author: Jeremy Allison <j...@samba.org> Date: Thu Jun 14 14:08:36 2018 -0700 python: Fix talloc frame use in make_simple_acl(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13474 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> This was fixed differently by commit 539f51f0dfbe4ce317a2978982fd0fc9a7fd6922 in master. Autobuild-User(v4-7-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-7-test): Tue Jun 19 17:54:45 CEST 2018 on sn-devel-144 commit 03cfdb0d758d9b0697844d4c5053bd2428b16a6d Author: Jeremy Allison <j...@samba.org> Date: Thu May 31 10:35:48 2018 -0700 s3: smbd: printing: Re-implement delete-on-close semantics for print files missing since 3.5.x. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13457 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Jun 1 20:32:03 CEST 2018 on sn-devel-144 (cherry picked from commit 364175b359f018c8641359440fa07b0ea567b045) commit 1f1edc09bfa3384571254f7057703dbc5db069bf Author: Günther Deschner <g...@samba.org> Date: Wed May 30 09:27:49 2018 +0200 s4-heimdal: Fix the format-truncation errors. ../source4/heimdal/lib/com_err/compile_et.c: In function ‘generate_h’: ../source4/heimdal/lib/com_err/compile_et.c:138:33: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size 126 [-Werror=format-truncation=] snprintf(fn, sizeof(fn), "__%s__", hfn); ^~ ~~~ ../source4/heimdal/lib/com_err/compile_et.c:138:5: note: ‘snprintf’ output between 5 and 132 bytes into a destination of size 128 snprintf(fn, sizeof(fn), "__%s__", hfn); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../source4/heimdal/lib/com_err/compile_et.c: In function ‘main’: ../source4/heimdal/lib/com_err/compile_et.c:234:35: error: ‘.h’ directive output may be truncated writing 2 bytes into a region of size between 1 and 128 [-Werror=format-truncation=] snprintf(hfn, sizeof(hfn), "%s.h", Basename); ^~ ../source4/heimdal/lib/com_err/compile_et.c:234:5: note: ‘snprintf’ output between 3 and 130 bytes into a destination of size 128 snprintf(hfn, sizeof(hfn), "%s.h", Basename); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../source4/heimdal/lib/com_err/compile_et.c:235:35: error: ‘.c’ directive output may be truncated writing 2 bytes into a region of size between 1 and 128 [-Werror=format-truncation=] snprintf(cfn, sizeof(cfn), "%s.c", Basename); ^~ ../source4/heimdal/lib/com_err/compile_et.c:235:5: note: ‘snprintf’ output between 3 and 130 bytes into a destination of size 128 snprintf(cfn, sizeof(cfn), "%s.c", Basename); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Guenther Signed-off-by: Günther Deschner <g...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Fri Jun 8 13:23:51 CEST 2018 on sn-devel-144 commit db362df94261512fff0701cf4153441fc8cf0c07 Author: Jeremy Allison <j...@samba.org> Date: Thu May 10 11:30:24 2018 -0700 s3: smbtorture: Add new SMB2-DIR-FSYNC test to show behavior of FSYNC on directories. Tests against a directory handle on the root of a share, and a directory handle on a sub-directory in a share. Check SEC_DIR_ADD_FILE and SEC_DIR_ADD_SUBDIR separately, either allows flush to succeed. Passes against Windows. Regression test for: BUG: https://bugzilla.samba.org/show_bug.cgi?id=13428 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri May 18 02:38:50 CEST 2018 on sn-devel-144 (cherry picked from commit d42f467a25e75e5487a00378609a24809ddc83ee) commit a743be8440b05d8dd11170777965aac0fd06b062 Author: Jeremy Allison <j...@samba.org> Date: Thu May 10 10:26:52 2018 -0700 s3: smbd: Fix SMB2-FLUSH against directories. Directories opened with either FILE_ADD_FILE or FILE_ADD_SUBDIRECTORY can be flushed even if they're not writable in the conventional sense. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13428 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 42aadf42f27053e621f2a6b72448afebb3f5082a) ----------------------------------------------------------------------- Summary of changes: selftest/knownfail | 1 + source3/printing/printspoolss.c | 17 ++ source3/selftest/tests.py | 2 +- source3/smbd/pysmbd.c | 49 +++--- source3/smbd/smb2_flush.c | 26 ++- source3/torture/proto.h | 1 + source3/torture/test_smb2.c | 270 +++++++++++++++++++++++++++++++ source3/torture/torture.c | 1 + source4/heimdal/lib/com_err/compile_et.c | 6 +- 9 files changed, 344 insertions(+), 29 deletions(-) Changeset truncated at 500 lines: diff --git a/selftest/knownfail b/selftest/knownfail index dd23c7d..267c928 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -8,6 +8,7 @@ .*driver.add_driver_timestamps # we only can store dates, not timestamps ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test +^samba3.smbtorture_s3.*ad_dc_ntvfs.*SMB2-DIR-FSYNC.* ^samba3.smb2.session enc.reconnect # expected to give CONNECTION_DISCONNECTED, we need to fix the test ^samba3.raw.session enc # expected to give ACCESS_DENIED as SMB1 encryption isn't used ^samba3.smbtorture_s3.crypt_server # expected to give ACCESS_DENIED as SMB1 encryption isn't used diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c index 6000202..9d565de 100644 --- a/source3/printing/printspoolss.c +++ b/source3/printing/printspoolss.c @@ -309,6 +309,23 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type) WERROR werr; struct dcerpc_binding_handle *b = NULL; + if (fsp->fh->private_options & + NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE) { + int ret; + + /* + * Job was requested to be cancelled by setting + * delete on close so truncate the job file. + * print_job_end() which is called from + * _spoolss_EndDocPrinter() will take + * care of deleting it for us. + */ + ret = ftruncate(fsp->fh->fd, 0); + if (ret == -1) { + DBG_ERR("ftruncate failed: %s\n", strerror(errno)); + } + } + b = fsp->conn->spoolss_pipe->binding_handle; switch (close_type) { diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index cd5b49b..59a3a55 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -78,7 +78,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7" "GETADDRINFO", "UID-REGRESSION-TEST", "SHORTNAME-TEST", "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT", "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE", - "SMB2-ANONYMOUS", + "SMB2-ANONYMOUS", "SMB2-DIR-FSYNC", "CLEANUP1", "CLEANUP2", "CLEANUP4", diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index be30b86..41b44ad 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -268,101 +268,101 @@ static int set_acl_entry_perms(SMB_ACL_ENTRY_T entry, mode_t perm_mask) return 0; } -static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode) +static SMB_ACL_T make_simple_acl(TALLOC_CTX *mem_ctx, + gid_t gid, + mode_t chmod_mode) { - TALLOC_CTX *frame = talloc_stackframe(); - mode_t mode = SMB_ACL_READ|SMB_ACL_WRITE|SMB_ACL_EXECUTE; mode_t mode_user = (chmod_mode & 0700) >> 6; mode_t mode_group = (chmod_mode & 070) >> 3; mode_t mode_other = chmod_mode & 07; SMB_ACL_ENTRY_T entry; - SMB_ACL_T acl = sys_acl_init(frame); + SMB_ACL_T acl = sys_acl_init(mem_ctx); if (!acl) { return NULL; } if (sys_acl_create_entry(&acl, &entry) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_tag_type(entry, SMB_ACL_USER_OBJ) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (set_acl_entry_perms(entry, mode_user) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_create_entry(&acl, &entry) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_tag_type(entry, SMB_ACL_GROUP_OBJ) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (set_acl_entry_perms(entry, mode_group) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_create_entry(&acl, &entry) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_tag_type(entry, SMB_ACL_OTHER) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (set_acl_entry_perms(entry, mode_other) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (gid != -1) { if (sys_acl_create_entry(&acl, &entry) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_tag_type(entry, SMB_ACL_GROUP) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_qualifier(entry, &gid) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (set_acl_entry_perms(entry, mode_group) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } } if (sys_acl_create_entry(&acl, &entry) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (sys_acl_set_tag_type(entry, SMB_ACL_MASK) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } if (set_acl_entry_perms(entry, mode) != 0) { - TALLOC_FREE(frame); + TALLOC_FREE(acl); return NULL; } return acl; @@ -386,17 +386,20 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args, PyObject &fname, &mode, &gid, &service)) return NULL; - acl = make_simple_acl(gid, mode); - frame = talloc_stackframe(); + acl = make_simple_acl(frame, gid, mode); + if (acl == NULL) { + TALLOC_FREE(frame); + return NULL; + } + conn = get_conn(frame, service); if (!conn) { return NULL; } ret = set_sys_acl_conn(fname, SMB_ACL_TYPE_ACCESS, acl, conn); - TALLOC_FREE(acl); if (ret != 0) { TALLOC_FREE(frame); diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index d1ab3a0..ef9b7fd 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -23,6 +23,7 @@ #include "smbd/globals.h" #include "../libcli/smb/smb_common.h" #include "../lib/util/tevent_ntstatus.h" +#include "libcli/security/security.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_SMB2 @@ -147,8 +148,29 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, } if (!CHECK_WRITE(fsp)) { - tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); - return tevent_req_post(req, ev); + bool allow_dir_flush = false; + uint32_t flush_access = FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY; + + if (!fsp->is_directory) { + tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); + return tevent_req_post(req, ev); + } + + /* + * Directories are not writable in the conventional + * sense, but if opened with *either* + * FILE_ADD_FILE or FILE_ADD_SUBDIRECTORY + * they can be flushed. + */ + + if ((fsp->access_mask & flush_access) != 0) { + allow_dir_flush = true; + } + + if (allow_dir_flush == false) { + tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); + return tevent_req_post(req, ev); + } } if (fsp->fh->fd == -1) { diff --git a/source3/torture/proto.h b/source3/torture/proto.h index 6f12ff7..a840038 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -101,6 +101,7 @@ bool run_smb2_tcon_dependence(int dummy); bool run_smb2_multi_channel(int dummy); bool run_smb2_session_reauth(int dummy); bool run_smb2_ftruncate(int dummy); +bool run_smb2_dir_fsync(int dummy); bool run_chain3(int dummy); bool run_local_conv_auth_info(int dummy); bool run_local_sprintf_append(int dummy); diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c index 897d034..094a9b8 100644 --- a/source3/torture/test_smb2.c +++ b/source3/torture/test_smb2.c @@ -2065,3 +2065,273 @@ bool run_smb2_ftruncate(int dummy) } return correct; } + +/* Ensure SMB2 flush on directories behaves correctly. */ + +static bool test_dir_fsync(struct cli_state *cli, const char *path) +{ + NTSTATUS status; + uint64_t fid_persistent, fid_volatile; + uint8_t *dir_data = NULL; + uint32_t dir_data_length = 0; + + /* Open directory - no write abilities. */ + status = smb2cli_create(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, path, + SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ + SEC_STD_SYNCHRONIZE| + SEC_DIR_LIST| + SEC_DIR_READ_ATTRIBUTE, /* desired_access, */ + 0, /* file_attributes, */ + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */ + FILE_OPEN, /* create_disposition, */ + FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */ + NULL, /* smb2_create_blobs *blobs */ + &fid_persistent, + &fid_volatile, + NULL, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_create '%s' (readonly) returned %s\n", + path, + nt_errstr(status)); + return false; + } + + status = smb2cli_query_directory( + cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon, + 1, 0, 0, fid_persistent, fid_volatile, "*", 0xffff, + talloc_tos(), &dir_data, &dir_data_length); + + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_query_directory returned %s\n", + nt_errstr(status)); + return false; + } + + /* Open directory no write access. Flush should fail. */ + + status = smb2cli_flush(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, fid_persistent, fid_volatile); + if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("smb2cli_flush on a read-only directory returned %s\n", + nt_errstr(status)); + return false; + } + + status = smb2cli_close(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, 0, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_close returned %s\n", nt_errstr(status)); + return false; + } + + /* Open directory write-attributes only. Flush should still fail. */ + + status = smb2cli_create(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, path, + SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ + SEC_STD_SYNCHRONIZE| + SEC_DIR_LIST| + SEC_DIR_WRITE_ATTRIBUTE| + SEC_DIR_READ_ATTRIBUTE, /* desired_access, */ + 0, /* file_attributes, */ + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */ + FILE_OPEN, /* create_disposition, */ + FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */ + NULL, /* smb2_create_blobs *blobs */ + &fid_persistent, + &fid_volatile, + NULL, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_create '%s' (write attr) returned %s\n", + path, + nt_errstr(status)); + return false; + } + + status = smb2cli_query_directory( + cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon, + 1, 0, 0, fid_persistent, fid_volatile, "*", 0xffff, + talloc_tos(), &dir_data, &dir_data_length); + + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_query_directory returned %s\n", nt_errstr(status)); + return false; + } + + status = smb2cli_flush(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, fid_persistent, fid_volatile); + if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("smb2cli_flush on a write-attributes directory " + "returned %s\n", + nt_errstr(status)); + return false; + } + + status = smb2cli_close(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, 0, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_close returned %s\n", nt_errstr(status)); + return false; + } + + /* Open directory with SEC_DIR_ADD_FILE access. Flush should now succeed. */ + + status = smb2cli_create(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, path, + SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ + SEC_STD_SYNCHRONIZE| + SEC_DIR_LIST| + SEC_DIR_ADD_FILE, /* desired_access, */ + 0, /* file_attributes, */ + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */ + FILE_OPEN, /* create_disposition, */ + FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */ + NULL, /* smb2_create_blobs *blobs */ + &fid_persistent, + &fid_volatile, + NULL, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_create '%s' (write FILE access) returned %s\n", + path, + nt_errstr(status)); + return false; + } + + status = smb2cli_query_directory( + cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon, + 1, 0, 0, fid_persistent, fid_volatile, "*", 0xffff, + talloc_tos(), &dir_data, &dir_data_length); + + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_query_directory returned %s\n", nt_errstr(status)); + return false; + } + + status = smb2cli_flush(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_flush on a directory returned %s\n", + nt_errstr(status)); + return false; + } + + status = smb2cli_close(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, 0, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_close returned %s\n", nt_errstr(status)); + return false; + } + + /* Open directory with SEC_DIR_ADD_FILE access. Flush should now succeed. */ + + status = smb2cli_create(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, path, + SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ + SEC_STD_SYNCHRONIZE| + SEC_DIR_LIST| + SEC_DIR_ADD_SUBDIR, /* desired_access, */ + 0, /* file_attributes, */ + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */ + FILE_OPEN, /* create_disposition, */ + FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */ + NULL, /* smb2_create_blobs *blobs */ + &fid_persistent, + &fid_volatile, + NULL, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_create '%s' (write DIR access) returned %s\n", + path, + nt_errstr(status)); + return false; + } + + status = smb2cli_query_directory( + cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon, + 1, 0, 0, fid_persistent, fid_volatile, "*", 0xffff, + talloc_tos(), &dir_data, &dir_data_length); + + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_query_directory returned %s\n", nt_errstr(status)); + return false; + } + + status = smb2cli_flush(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_flush on a directory returned %s\n", + nt_errstr(status)); + return false; + } + + status = smb2cli_close(cli->conn, cli->timeout, cli->smb2.session, + cli->smb2.tcon, 0, fid_persistent, fid_volatile); + if (!NT_STATUS_IS_OK(status)) { + printf("smb2cli_close returned %s\n", nt_errstr(status)); + return false; + } + + + return true; +} + +bool run_smb2_dir_fsync(int dummy) +{ + struct cli_state *cli = NULL; + NTSTATUS status; + bool bret = false; + const char *dname = "fsync_test_dir"; + + printf("Starting SMB2-DIR-FSYNC\n"); + + if (!torture_init_connection(&cli)) { + return false; + } + + status = smbXcli_negprot(cli->conn, cli->timeout, + PROTOCOL_SMB2_02, PROTOCOL_SMB2_02); + if (!NT_STATUS_IS_OK(status)) { + printf("smbXcli_negprot returned %s\n", nt_errstr(status)); + return false; + } -- Samba Shared Repository