summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-08-15 15:23:47 +0200
committerVolker Lendecke <vl@samba.org>2010-08-17 22:44:03 +0200
commit9671547d17fa8152dbad127fde2a963b2ba834a0 (patch)
treed7c43c162b321f912172c3640d5b5b9c85630805 /source3
parent786c41b0954b541518d1096019e1ce7ca11e5e98 (diff)
downloadsamba-9671547d17fa8152dbad127fde2a963b2ba834a0.tar.gz
samba-9671547d17fa8152dbad127fde2a963b2ba834a0.tar.bz2
samba-9671547d17fa8152dbad127fde2a963b2ba834a0.zip
s3: Lift smbd_server_fd() from read_fd_with_timeout()
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_sock.c87
-rw-r--r--source3/rpc_server/srv_samr_chgpasswd.c2
-rw-r--r--source3/smbd/process.c17
3 files changed, 62 insertions, 44 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 5a658bcad3..b61a3f703e 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);
}
@@ -573,7 +531,25 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf,
NTSTATUS read_data(int fd, char *buffer, size_t N)
{
- return read_fd_with_timeout(fd, buffer, N, N, 0, NULL);
+ NTSTATUS status;
+
+ status = read_fd_with_timeout(fd, buffer, N, N, 0, NULL);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (fd == smbd_server_fd()) {
+ 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)));
+ } else {
+ DEBUG(0, ("read_fd_with_timeout failed, read error = %s.\n",
+ nt_errstr(status)));
+ }
+ return status;
}
/****************************************************************************
@@ -694,6 +670,18 @@ NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
status = read_fd_with_timeout(fd, inbuf, 4, 4, timeout, NULL);
if (!NT_STATUS_IS_OK(status)) {
+ if (fd == smbd_server_fd()) {
+ 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)));
+ } else {
+ DEBUG(0, ("read_fd_with_timeout failed, read error = "
+ "%s.\n", nt_errstr(status)));
+ }
return status;
}
@@ -776,6 +764,19 @@ 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)) {
+ if (fd == smbd_server_fd()) {
+ 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)));
+ } else {
+ 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 2e76e55dfa..525f8382c6 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 c44d86a6b8..8c781c8955 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;
}