The branch, master has been updated
       via  9fb2562 libcli/smb: debug an error if smb1cli_req_writev_submit() 
is called for SMB2/3
       via  428fc22 s3: libsmb: Add cli_smb2_chkpath() and use from 
cli_chkpath().
      from  c477124 util: Add documentation for PID file handling

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9fb2562324e4381f8d0d5eaf864790ad770293b9
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Aug 16 22:27:15 2017 +0200

    libcli/smb: debug an error if smb1cli_req_writev_submit() is called for 
SMB2/3
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12968
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Fri Aug 18 04:45:03 CEST 2017 on sn-devel-144

commit 428fc22e8bb7b7a74ba9e29bf962ebfbfd50c47b
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 16 15:48:01 2017 -0700

    s3: libsmb: Add cli_smb2_chkpath() and use from cli_chkpath().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12968
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 libcli/smb/smbXcli_base.c      |  3 +++
 source3/libsmb/cli_smb2_fnum.c | 41 +++++++++++++++++++++++++++++++++++++++++
 source3/libsmb/cli_smb2_fnum.h |  2 ++
 source3/libsmb/clifile.c       |  8 +++++++-
 4 files changed, 53 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index cc89789..d73949b 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -1661,6 +1661,9 @@ static NTSTATUS smb1cli_req_writev_submit(struct 
tevent_req *req,
        }
 
        if (state->conn->protocol > PROTOCOL_NT1) {
+               DBG_ERR("called for dialect[%s] server[%s]\n",
+                       smb_protocol_types_string(state->conn->protocol),
+                       smbXcli_conn_remote_name(state->conn));
                return NT_STATUS_REVISION_MISMATCH;
        }
 
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 2d2667e..b8179b0 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1101,6 +1101,47 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
 }
 
 /***************************************************************
+ Wrapper that allows SMB2 to check if a path is a directory.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_chkpath(struct cli_state *cli,
+                               const char *name)
+{
+       NTSTATUS status;
+       uint16_t fnum = 0xffff;
+
+       if (smbXcli_conn_has_async_calls(cli->conn)) {
+               /*
+                * Can't use sync call while an async call is in flight
+                */
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       /* Ensure this is a directory. */
+       status = cli_smb2_create_fnum(cli,
+                       name,
+                       0,                      /* create_flags */
+                       FILE_READ_ATTRIBUTES,   /* desired_access */
+                       FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
+                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* 
share_access */
+                       FILE_OPEN,              /* create_disposition */
+                       FILE_DIRECTORY_FILE,    /* create_options */
+                       &fnum,
+                       NULL);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       return cli_smb2_close_fnum(cli, fnum);
+}
+
+/***************************************************************
  Helper function for pathname operations.
 ***************************************************************/
 
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 402801b..a6c3627 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -79,6 +79,8 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
 NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
                        const char *name,
                        fstring alt_name);
+NTSTATUS cli_smb2_chkpath(struct cli_state *cli,
+                       const char *name);
 NTSTATUS cli_smb2_qfileinfo_basic(struct cli_state *cli,
                        uint16_t fnum,
                        uint16_t *mode,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 828448f..a6a0baf 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -4233,12 +4233,18 @@ NTSTATUS cli_chkpath_recv(struct tevent_req *req)
 
 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path)
 {
-       TALLOC_CTX *frame = talloc_stackframe();
+       TALLOC_CTX *frame = NULL;
        struct tevent_context *ev = NULL;
        struct tevent_req *req = NULL;
        char *path2 = NULL;
        NTSTATUS status = NT_STATUS_OK;
 
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               return cli_smb2_chkpath(cli, path);
+       }
+
+       frame = talloc_stackframe();
+
        if (smbXcli_conn_has_async_calls(cli->conn)) {
                /*
                 * Can't use sync call while an async call is in flight


-- 
Samba Shared Repository

Reply via email to