[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Oct 30 18:17:02 MDT 2013


The branch, master has been updated
       via  127fc67 libcli/smb: fix smb2cli_ioctl*() against Windows 2008.
       via  71dc7e5 s3:libsmb: SMBC_getatr() if no method worked, try all methods again on next attempt
       via  f959dd4 client: use cli_qpathinfo3 for allinfo
       via  569722e s3:libsmb: cli_qpathinfo3 use cli_qpathinfo2 for smb2
       via  7e35a4d client: remove a write only variable
       via  0a3cc7e s3:libsmb: SMBC_getatr use pathinfo3 for second try
       via  0abe678 s3:libsmb: SMBC_getatr do not let ino undefined on success
       via  cfedd4f s3:libsmb: SMBC_getatr try pathinfo2 only once
       via  30ba2c0 s3:libsmb: add function cli_qpathinfo3()
       via  8228c3c s3:libsmb: add function cli_qpathinfo_standard()
       via  878f375 s3:libsmb: pass creation or birth time in cli_qpathinfo_basic()
      from  508b86e s3:modules: nfs4_acls ACLs with zero entries are fine.

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


- Log -----------------------------------------------------------------
commit 127fc670a39d15eaa3869045fca0287ba7df9efa
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 28 15:43:03 2013 +0100

    libcli/smb: fix smb2cli_ioctl*() against Windows 2008.
    
    The subsections of [MS-SMB2] "3.2.5.14 Receiving an SMB2 IOCTL Response"
    say the client should ignore the InputOffset/InputCount.
    
    We do that only if we ask for max_input_length = 0.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10232
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Oct 31 01:16:10 CET 2013 on sn-devel-104

commit 71dc7e593ef17db7875d3d9a2e42ae588679392e
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 18 15:32:55 2013 +0200

    s3:libsmb: SMBC_getatr() if no method worked, try all methods again on next attempt
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f959dd44a015ba0a844f85e7e0896e8c46e6e5a3
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Oct 14 11:44:36 2013 +0200

    client: use cli_qpathinfo3 for allinfo
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 569722ee4081d154d65caa192b9caed21730db93
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Oct 14 11:43:45 2013 +0200

    s3:libsmb: cli_qpathinfo3 use cli_qpathinfo2 for smb2
    
    cli_qpathinfo3 only works (and is only needed as fallback so far) for smb1.
    Use cli_qpathinfo2 in the smb2 case to make it universally usable.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7e35a4dc7369e4389ebdc373310c6ff7c48b036f
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 11:05:06 2013 +0200

    client: remove a write only variable
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0a3cc7e25ca54c5dc0b836680668401582b105b0
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 11:02:24 2013 +0200

    s3:libsmb: SMBC_getatr use pathinfo3 for second try
    
    The pathinfo2 call might fail against NetApp because it is sending broken
    packages.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0abe678af8d763279fd218736e6df29c21b27c5c
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 11:00:48 2013 +0200

    s3:libsmb: SMBC_getatr do not let ino undefined on success
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cfedd4fe6951493368dd758d16fcd650845ac4b9
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 10:59:59 2013 +0200

    s3:libsmb: SMBC_getatr try pathinfo2 only once
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 30ba2c0580e1f1218243f62efdfb24db992660a5
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 10:53:45 2013 +0200

    s3:libsmb: add function cli_qpathinfo3()
    
    This is a reimplemantation of cli_qpathinfo2 without the use of info level
    SMB_QFILEINFO_ALL_INFO which leads to broken responses from NetApp.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8228c3c68c8d5b6e5e4ec2f4ec6e4a9c99e35f48
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 10:52:21 2013 +0200

    s3:libsmb: add function cli_qpathinfo_standard()
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 878f3758202a9a9c1f3ff18730f5d4a10f1bab31
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Oct 11 10:50:39 2013 +0200

    s3:libsmb: pass creation or birth time in cli_qpathinfo_basic()
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 libcli/smb/smb2cli_ioctl.c        |   33 ++++++++++-
 source3/client/client.c           |    7 +-
 source3/include/libsmb_internal.h |    1 +
 source3/libsmb/clirap.c           |  110 +++++++++++++++++++++++++++++++++++++
 source3/libsmb/clirap.h           |   11 ++++
 source3/libsmb/libsmb_file.c      |   27 ++++++++-
 source3/libsmb/libsmb_server.c    |    1 +
 7 files changed, 178 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb2cli_ioctl.c b/libcli/smb/smb2cli_ioctl.c
index 8de7635..3090693 100644
--- a/libcli/smb/smb2cli_ioctl.c
+++ b/libcli/smb/smb2cli_ioctl.c
@@ -213,7 +213,21 @@ static void smb2cli_ioctl_done(struct tevent_req *subreq)
 			return;
 		}
 
-		if (input_buffer_length < dyn_len) {
+		ofs = input_buffer_length;
+		ofs = NDR_ROUND(ofs, 8);
+
+		if (state->max_input_length == 0) {
+			/*
+			 * If max_input_length is 0 we ignore
+			 * the input_buffer_length, because
+			 * Windows 2008 echos the DCERPC request
+			 * from the requested input_buffer
+			 * to the response input_buffer.
+			 */
+			input_buffer_length = 0;
+		}
+
+		if (input_buffer_length > dyn_len) {
 			tevent_req_nterror(
 				req, NT_STATUS_INVALID_NETWORK_RESPONSE);
 			return;
@@ -228,8 +242,11 @@ static void smb2cli_ioctl_done(struct tevent_req *subreq)
 		state->out_input_buffer.data = dyn;
 		state->out_input_buffer.length = input_buffer_length;
 
-		ofs = input_buffer_length;
-		ofs = NDR_ROUND(ofs, 8);
+		if (ofs > dyn_len) {
+			tevent_req_nterror(
+				req, NT_STATUS_INVALID_NETWORK_RESPONSE);
+			return;
+		}
 
 		dyn_ofs += ofs;
 		dyn += ofs;
@@ -243,7 +260,15 @@ static void smb2cli_ioctl_done(struct tevent_req *subreq)
 			return;
 		}
 
-		if (output_buffer_length < dyn_len) {
+		if (state->max_output_length == 0) {
+			/*
+			 * We do the same logic as for
+			 * max_input_length.
+			 */
+			output_buffer_length = 0;
+		}
+
+		if (output_buffer_length > dyn_len) {
 			tevent_req_nterror(
 				req, NT_STATUS_INVALID_NETWORK_RESPONSE);
 			return;
diff --git a/source3/client/client.c b/source3/client/client.c
index c3a557e..2ed47c4 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1695,7 +1695,6 @@ static int do_allinfo(const char *name)
 	struct timespec b_time, a_time, m_time, c_time;
 	off_t size;
 	uint16_t mode;
-	SMB_INO_T ino;
 	NTTIME tmp;
 	uint16_t fnum;
 	unsigned int num_streams;
@@ -1722,8 +1721,8 @@ static int do_allinfo(const char *name)
 	}
 	d_printf("altname: %s\n", altname);
 
-	status = cli_qpathinfo2(cli, name, &b_time, &a_time, &m_time, &c_time,
-				&size, &mode, &ino);
+	status = cli_qpathinfo3(cli, name, &b_time, &a_time, &m_time, &c_time,
+				&size, &mode, NULL);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("%s getting pathinfo for %s\n", nt_errstr(status),
 			 name);
@@ -1800,7 +1799,7 @@ static int do_allinfo(const char *name)
 		d_printf("%s\n", snapshots[i]);
 		snap_name = talloc_asprintf(talloc_tos(), "%s%s",
 					    snapshots[i], name);
-		status = cli_qpathinfo2(cli, snap_name, &b_time, &a_time,
+		status = cli_qpathinfo3(cli, snap_name, &b_time, &a_time,
 					&m_time, &c_time, &size,
 					NULL, NULL);
 		if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 63c96fe..ce73181 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -78,6 +78,7 @@ struct _SMBCSRV {
 	dev_t dev;
 	bool no_pathinfo;
 	bool no_pathinfo2;
+	bool no_pathinfo3;
         bool no_nt_session;
         struct policy_handle pol;
 
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index d6d2fae..7e6f8d7 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -1265,6 +1265,7 @@ NTSTATUS cli_qpathinfo_basic_recv(struct tevent_req *req,
 		return status;
 	}
 
+	sbuf->st_ex_btime = interpret_long_date((char *)state->data);
 	sbuf->st_ex_atime = interpret_long_date((char *)state->data+8);
 	sbuf->st_ex_mtime = interpret_long_date((char *)state->data+16);
 	sbuf->st_ex_ctime = interpret_long_date((char *)state->data+24);
@@ -1362,3 +1363,112 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin
 
 	return NT_STATUS_OK;
 }
+
+/****************************************************************************
+ Send a qpathinfo SMB_QUERY_FILE_STADNDARD_INFO call.
+****************************************************************************/
+
+NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname,
+				uint64_t *allocated, uint64_t *size,
+				uint32_t *nlinks,
+				bool *is_del_pending, bool *is_dir)
+{
+	uint8_t *rdata;
+	uint32_t num_rdata;
+	NTSTATUS status;
+
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		return NT_STATUS_NOT_IMPLEMENTED;
+	}
+
+	status = cli_qpathinfo(talloc_tos(), cli, fname,
+			       SMB_QUERY_FILE_STANDARD_INFO,
+			       24, CLI_BUFFER_SIZE, &rdata, &num_rdata);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (allocated) {
+		*allocated = BVAL(rdata, 0);
+	}
+
+	if (size) {
+		*size = BVAL(rdata, 8);
+	}
+
+	if (nlinks) {
+		*nlinks = IVAL(rdata, 16);
+	}
+
+	if (is_del_pending) {
+		*is_del_pending = CVAL(rdata, 20);
+	}
+
+	if (is_dir) {
+		*is_dir = CVAL(rdata, 20);
+	}
+
+	TALLOC_FREE(rdata);
+
+	return NT_STATUS_OK;
+}
+
+
+/* like cli_qpathinfo2 but do not use SMB_QUERY_FILE_ALL_INFO with smb1 */
+NTSTATUS cli_qpathinfo3(struct cli_state *cli, const char *fname,
+			struct timespec *create_time,
+			struct timespec *access_time,
+			struct timespec *write_time,
+			struct timespec *change_time,
+			off_t *size, uint16 *mode,
+			SMB_INO_T *ino)
+{
+	NTSTATUS status = NT_STATUS_OK;
+	SMB_STRUCT_STAT st;
+	uint32_t attr;
+	uint64_t pos;
+
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		return cli_qpathinfo2(cli, fname,
+				      create_time, access_time, write_time, change_time,
+				      size, mode, ino);
+	}
+
+	if (create_time || access_time || write_time || change_time || mode) {
+		status = cli_qpathinfo_basic(cli, fname, &st, &attr);
+		if (!NT_STATUS_IS_OK(status)) {
+			return status;
+		}
+	}
+
+	if (size) {
+		status = cli_qpathinfo_standard(cli, fname,
+						NULL, &pos, NULL, NULL, NULL);
+		if (!NT_STATUS_IS_OK(status)) {
+			return status;
+		}
+
+		*size = pos;
+	}
+
+	if (create_time) {
+		*create_time = st.st_ex_btime;
+	}
+	if (access_time) {
+		*access_time = st.st_ex_atime;
+	}
+	if (write_time) {
+		*write_time = st.st_ex_mtime;
+	}
+	if (change_time) {
+		*change_time = st.st_ex_ctime;
+	}
+	if (mode) {
+		*mode = attr;
+	}
+	if (ino) {
+		*ino = 0;
+	}
+
+	return NT_STATUS_OK;
+}
diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h
index e105182..54f06b4 100644
--- a/source3/libsmb/clirap.h
+++ b/source3/libsmb/clirap.h
@@ -82,6 +82,13 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
 			struct timespec *change_time,
 			off_t *size, uint16 *mode,
 			SMB_INO_T *ino);
+NTSTATUS cli_qpathinfo3(struct cli_state *cli, const char *fname,
+			struct timespec *create_time,
+			struct timespec *access_time,
+			struct timespec *write_time,
+			struct timespec *change_time,
+			off_t *size, uint16 *mode,
+			SMB_INO_T *ino);
 struct tevent_req *cli_qpathinfo_streams_send(TALLOC_CTX *mem_ctx,
 					      struct tevent_context *ev,
 					      struct cli_state *cli,
@@ -115,6 +122,10 @@ NTSTATUS cli_qpathinfo_basic_recv(struct tevent_req *req,
 				  SMB_STRUCT_STAT *sbuf, uint32 *attributes);
 NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
 			     SMB_STRUCT_STAT *sbuf, uint32 *attributes);
+NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname,
+				uint64_t *allocated, uint64_t *size,
+				uint32_t *nlinks,
+				bool *is_del_pending, bool *is_dir);
 NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name);
 struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
 				      struct tevent_context *ev,
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 32210b6..8fb7a2e 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -558,11 +558,24 @@ SMBC_getatr(SMBCCTX * context,
 		return True;
         }
 
+	srv->no_pathinfo2 = True;
+
+	if (!srv->no_pathinfo3 &&
+            NT_STATUS_IS_OK(cli_qpathinfo3(targetcli, targetpath,
+                           create_time_ts,
+                           access_time_ts,
+                           write_time_ts,
+                           change_time_ts,
+			   size, mode, ino))) {
+		TALLOC_FREE(frame);
+		return True;
+        }
+
+	srv->no_pathinfo3 = True;
+
 	/* if this is NT then don't bother with the getatr */
 	if (smb1cli_conn_capabilities(targetcli->conn) & CAP_NT_SMBS) {
-                errno = EPERM;
-		TALLOC_FREE(frame);
-                return False;
+		goto all_failed;
         }
 
 	if (NT_STATUS_IS_OK(cli_getatr(targetcli, targetpath, mode, size, &write_time))) {
@@ -581,11 +594,17 @@ SMBC_getatr(SMBCCTX * context,
                 if (change_time_ts != NULL) {
                         *change_time_ts = w_time_ts;
                 }
-		srv->no_pathinfo2 = True;
+		if (ino) {
+			*ino = 0;
+		}
 		TALLOC_FREE(frame);
 		return True;
 	}
 
+all_failed:
+	srv->no_pathinfo2 = False;
+	srv->no_pathinfo3 = False;
+
         errno = EPERM;
 	TALLOC_FREE(frame);
 	return False;
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 9d87f42..2f3ea96 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -606,6 +606,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 	srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
         srv->no_pathinfo = False;
         srv->no_pathinfo2 = False;
+	srv->no_pathinfo3 = False;
         srv->no_nt_session = False;
 
 done:


-- 
Samba Shared Repository


More information about the samba-cvs mailing list