[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Tue Aug 17 14:44:54 MDT 2010


The branch, master has been updated
       via  f8ecec2... s3: Remove smbd_server_fd() from read_smb_length()
       via  840b0f5... s3: Move read_smb_length() to smbd/reply.c
       via  e65197e... s3: Remove smbd_server_fd from receive_smb_raw
       via  a58cea0... s3: Lift smbd_server_fd() from receive_smb_raw_talloc
       via  1f0afe1... s3: Lift smbd_server_fd() from read_smb_length_return_keepalive
       via  7d16449... s3: Lift smbd_server_fd() from read_data()
       via  9671547... s3: Lift smbd_server_fd() from read_fd_with_timeout()
      from  786c41b... s4:netlogon RPC server - "ServerPasswordSet" operations - introduce also here the new password change syntax

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


- Log -----------------------------------------------------------------
commit f8ecec21e2c4451fe892885cfc12afa98a8c14f6
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:46:29 2010 +0200

    s3: Remove smbd_server_fd() from read_smb_length()

commit 840b0f523b978aa6cb9acbac26023a756afcea81
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:45:21 2010 +0200

    s3: Move read_smb_length() to smbd/reply.c

commit e65197e56f86fd523516fc3ef577e72877cfab22
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:40:08 2010 +0200

    s3: Remove smbd_server_fd from receive_smb_raw
    
    This is only called from client code

commit a58cea002626cee2db77ac12aa091e5b48381662
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:38:31 2010 +0200

    s3: Lift smbd_server_fd() from receive_smb_raw_talloc

commit 1f0afe1aed5cc267c3c24322992bfcb7c82847b1
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:36:28 2010 +0200

    s3: Lift smbd_server_fd() from read_smb_length_return_keepalive

commit 7d164498dbad77e2072eaae9e421ee1c45336257
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:30:21 2010 +0200

    s3: Lift smbd_server_fd() from read_data()
    
    All callers have appropriate debug messages themselves

commit 9671547d17fa8152dbad127fde2a963b2ba834a0
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 15 15:23:47 2010 +0200

    s3: Lift smbd_server_fd() from read_fd_with_timeout()

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

Summary of changes:
 source3/include/proto.h                 |    2 -
 source3/lib/util_sock.c                 |   77 ++-----------------------------
 source3/rpc_server/srv_samr_chgpasswd.c |    2 +
 source3/smbd/process.c                  |   23 ++++++++-
 source3/smbd/reply.c                    |   48 ++++++++++++++++++-
 5 files changed, 72 insertions(+), 80 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index ebb3432..8e4c311 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1448,8 +1448,6 @@ bool send_keepalive(int client);
 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
 					  unsigned int timeout,
 					  size_t *len);
-NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
-			 size_t *len);
 NTSTATUS receive_smb_raw(int fd,
 			char *buffer,
 			size_t buflen,
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 5a658bc..3bc60db 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -442,7 +442,6 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf,
 	ssize_t readret;
 	size_t nread = 0;
 	struct timeval timeout;
-	char addr[INET6_ADDRSTRLEN];
 	int save_errno;
 
 	/* just checking .... */
@@ -465,19 +464,6 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf,
 			}
 
 			if (readret == -1) {
-				save_errno = errno;
-				if (fd == smbd_server_fd()) {
-					/* Try and give an error message
-					 * saying what client failed. */
-					DEBUG(0,("read_fd_with_timeout: "
-						"client %s read error = %s.\n",
-						get_peer_addr(fd,addr,sizeof(addr)),
-						strerror(save_errno) ));
-				} else {
-					DEBUG(0,("read_fd_with_timeout: "
-						"read error = %s.\n",
-						strerror(save_errno) ));
-				}
 				return map_nt_error_from_unix(save_errno);
 			}
 			nread += readret;
@@ -503,20 +489,6 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf,
 
 		/* Check if error */
 		if (selrtn == -1) {
-			save_errno = errno;
-			/* something is wrong. Maybe the socket is dead? */
-			if (fd == smbd_server_fd()) {
-				/* Try and give an error message saying
-				 * what client failed. */
-				DEBUG(0,("read_fd_with_timeout: timeout "
-				"read for client %s. select error = %s.\n",
-				get_peer_addr(fd,addr,sizeof(addr)),
-				strerror(save_errno) ));
-			} else {
-				DEBUG(0,("read_fd_with_timeout: timeout "
-				"read. select error = %s.\n",
-				strerror(save_errno) ));
-			}
 			return map_nt_error_from_unix(save_errno);
 		}
 
@@ -537,20 +509,6 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf,
 		}
 
 		if (readret == -1) {
-			save_errno = errno;
-			/* the descriptor is probably dead */
-			if (fd == smbd_server_fd()) {
-				/* Try and give an error message
-				 * saying what client failed. */
-				DEBUG(0,("read_fd_with_timeout: timeout "
-					"read to client %s. read error = %s.\n",
-					get_peer_addr(fd,addr,sizeof(addr)),
-					strerror(save_errno) ));
-			} else {
-				DEBUG(0,("read_fd_with_timeout: timeout "
-					"read. read error = %s.\n",
-					strerror(save_errno) ));
-			}
 			return map_nt_error_from_unix(errno);
 		}
 
@@ -710,36 +668,6 @@ NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
 }
 
 /****************************************************************************
- Read 4 bytes of a smb packet and return the smb length of the packet.
- Store the result in the buffer. This version of the function will
- never return a session keepalive (length of zero).
- Timeout is in milliseconds.
-****************************************************************************/
-
-NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
-			 size_t *len)
-{
-	uint8_t msgtype = SMBkeepalive;
-
-	while (msgtype == SMBkeepalive) {
-		NTSTATUS status;
-
-		status = read_smb_length_return_keepalive(fd, inbuf, timeout,
-							  len);
-		if (!NT_STATUS_IS_OK(status)) {
-			return status;
-		}
-
-		msgtype = CVAL(inbuf, 0);
-	}
-
-	DEBUG(10,("read_smb_length: got smb length of %lu\n",
-		  (unsigned long)len));
-
-	return NT_STATUS_OK;
-}
-
-/****************************************************************************
  Read an smb from a fd.
  The timeout is in milliseconds.
  This function will return on receipt of a session keepalive packet.
@@ -757,7 +685,8 @@ NTSTATUS receive_smb_raw(int fd, char *buffer, size_t buflen, unsigned int timeo
 	status = read_smb_length_return_keepalive(fd,buffer,timeout,&len);
 
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(10, ("receive_smb_raw: %s!\n", nt_errstr(status)));
+		DEBUG(0, ("read_fd_with_timeout failed, read "
+			  "error = %s.\n", nt_errstr(status)));
 		return status;
 	}
 
@@ -776,6 +705,8 @@ NTSTATUS receive_smb_raw(int fd, char *buffer, size_t buflen, unsigned int timeo
 			fd, buffer+4, len, len, timeout, &len);
 
 		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0, ("read_fd_with_timeout failed, read error = "
+				  "%s.\n", nt_errstr(status)));
 			return status;
 		}
 
diff --git a/source3/rpc_server/srv_samr_chgpasswd.c b/source3/rpc_server/srv_samr_chgpasswd.c
index 2e76e55..525f838 100644
--- a/source3/rpc_server/srv_samr_chgpasswd.c
+++ b/source3/rpc_server/srv_samr_chgpasswd.c
@@ -269,6 +269,8 @@ static int expect(int master, char *issue, char *expected)
 				timeout, &len);
 
 			if (!NT_STATUS_IS_OK(status)) {
+				DEBUG(2, ("expect: read error %s\n",
+					  nt_errstr(status)));
 				break;
 			}
 			nread += len;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index c44d86a..07b53a2 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -206,11 +206,21 @@ static bool valid_packet_size(size_t len)
 static NTSTATUS read_packet_remainder(int fd, char *buffer,
 				      unsigned int timeout, ssize_t len)
 {
+	NTSTATUS status;
+
 	if (len <= 0) {
 		return NT_STATUS_OK;
 	}
 
-	return read_fd_with_timeout(fd, buffer, len, len, timeout, NULL);
+	status = read_fd_with_timeout(fd, buffer, len, len, timeout, NULL);
+	if (!NT_STATUS_IS_OK(status)) {
+		char addr[INET6_ADDRSTRLEN];
+		DEBUG(0, ("read_fd_with_timeout failed for client %s read "
+			  "error = %s.\n",
+			  get_peer_addr(fd, addr, sizeof(addr)),
+			  nt_errstr(status)));
+	}
+	return status;
 }
 
 /****************************************************************************
@@ -251,6 +261,11 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
 		timeout, NULL);
 
 	if (!NT_STATUS_IS_OK(status)) {
+		char addr[INET6_ADDRSTRLEN];
+		DEBUG(0, ("read_fd_with_timeout failed for client %s read "
+			  "error = %s.\n",
+			  get_peer_addr(fd, addr, sizeof(addr)),
+			  nt_errstr(status)));
 		return status;
 	}
 
@@ -352,7 +367,6 @@ static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
 
 	status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len);
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status)));
 		return status;
 	}
 
@@ -408,6 +422,11 @@ static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx,	int fd,
 	status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout,
 					p_unread, &len);
 	if (!NT_STATUS_IS_OK(status)) {
+		char addr[INET6_ADDRSTRLEN];
+		DEBUG(0, ("read_smb_length_return_keepalive failed for "
+			  "client %s read error = %s.\n",
+			  get_peer_addr(fd, addr, sizeof(addr)),
+			  nt_errstr(status)));
 		return status;
 	}
 
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index a2b6b33..97269df 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3797,6 +3797,43 @@ void error_to_writebrawerr(struct smb_request *req)
 }
 
 /****************************************************************************
+ Read 4 bytes of a smb packet and return the smb length of the packet.
+ Store the result in the buffer. This version of the function will
+ never return a session keepalive (length of zero).
+ Timeout is in milliseconds.
+****************************************************************************/
+
+static NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
+				size_t *len)
+{
+	uint8_t msgtype = SMBkeepalive;
+
+	while (msgtype == SMBkeepalive) {
+		NTSTATUS status;
+
+		status = read_smb_length_return_keepalive(fd, inbuf, timeout,
+							  len);
+		if (!NT_STATUS_IS_OK(status)) {
+			char addr[INET6_ADDRSTRLEN];
+			/* Try and give an error message
+			 * saying what client failed. */
+			DEBUG(0, ("read_fd_with_timeout failed for "
+				  "client %s read error = %s.\n",
+				  get_peer_addr(fd,addr,sizeof(addr)),
+				  nt_errstr(status)));
+			return status;
+		}
+
+		msgtype = CVAL(inbuf, 0);
+	}
+
+	DEBUG(10,("read_smb_length: got smb length of %lu\n",
+		  (unsigned long)len));
+
+	return NT_STATUS_OK;
+}
+
+/****************************************************************************
  Reply to a writebraw (core+ or LANMAN1.0 protocol).
 ****************************************************************************/
 
@@ -3966,9 +4003,14 @@ void reply_writebraw(struct smb_request *req)
 		status = read_data(req->sconn->sock, buf+4, numtowrite);
 
 		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0,("reply_writebraw: Oversize secondary write "
-				 "raw read failed (%s). Terminating\n",
-				 nt_errstr(status)));
+			char addr[INET6_ADDRSTRLEN];
+			/* Try and give an error message
+			 * saying what client failed. */
+			DEBUG(0, ("reply_writebraw: Oversize secondary write "
+				  "raw read failed (%s) for client %s. "
+				  "Terminating\n", nt_errstr(status),
+				  get_peer_addr(req->sconn->sock, addr,
+						sizeof(addr))));
 			exit_server_cleanly("secondary writebraw failed");
 		}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list