diff options
author | Jeremy Allison <jra@samba.org> | 2009-09-06 21:38:50 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-09-06 21:38:50 -0700 |
commit | 43c766a14a5eeed80e57bae9fde21eb2b542c209 (patch) | |
tree | b0330fce78ed8ec8fc30e039acf701787ebca90e /source3 | |
parent | 5a22c0225abe2da11e844888475cbd9c40c6c47c (diff) | |
download | samba-43c766a14a5eeed80e57bae9fde21eb2b542c209.tar.gz samba-43c766a14a5eeed80e57bae9fde21eb2b542c209.tar.bz2 samba-43c766a14a5eeed80e57bae9fde21eb2b542c209.zip |
Fix bug 6673 - smbpasswd does not work with "unix password sync = yes".
Revert change from 3.3 -> 3.4 with read_socket_with_timeout changed
from sys_read() to sys_recv(). read_socket_with_timeout() is called
with non-fd's (with a pty in chgpasswd.c and with a disk file in
lib/dbwrap_file.c via read_data()). recv works for the disk file,
but not the pty. Change the name of read_socket_with_timeout() to
read_fd_with_timeout() to make this clear (and add comments).
Jeremy.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 42 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 2 | ||||
-rw-r--r-- | source3/smbd/chgpasswd.c | 2 | ||||
-rw-r--r-- | source3/smbd/process.c | 4 |
5 files changed, 30 insertions, 22 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 9314e57cc2..4bdd306c0b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1383,7 +1383,7 @@ ssize_t read_udp_v4_socket(int fd, char *buf, size_t len, struct sockaddr_storage *psa); -NTSTATUS read_socket_with_timeout(int fd, char *buf, +NTSTATUS read_fd_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, unsigned int time_out, size_t *size_ret); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 638a92d23b..6cc2e53811 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -538,13 +538,15 @@ ssize_t read_udp_v4_socket(int fd, } /**************************************************************************** - Read data from a socket with a timout in msec. + Read data from a file descriptor with a timout in msec. mincount = if timeout, minimum to read before returning maxcount = number to be read. time_out = timeout in milliseconds + NB. This can be called with a non-socket fd, don't change + sys_read() to sys_recv() or other socket call. ****************************************************************************/ -NTSTATUS read_socket_with_timeout(int fd, char *buf, +NTSTATUS read_fd_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, unsigned int time_out, size_t *size_ret) @@ -568,10 +570,10 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, } while (nread < mincnt) { - readret = sys_recv(fd, buf + nread, maxcnt - nread, 0); + readret = sys_read(fd, buf + nread, maxcnt - nread); if (readret == 0) { - DEBUG(5,("read_socket_with_timeout: " + DEBUG(5,("read_fd_with_timeout: " "blocking read. EOF from client.\n")); return NT_STATUS_END_OF_FILE; } @@ -581,12 +583,12 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, if (fd == get_client_fd()) { /* Try and give an error message * saying what client failed. */ - DEBUG(0,("read_socket_with_timeout: " + 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_socket_with_timeout: " + DEBUG(0,("read_fd_with_timeout: " "read error = %s.\n", strerror(save_errno) )); } @@ -620,12 +622,12 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, if (fd == get_client_fd()) { /* Try and give an error message saying * what client failed. */ - DEBUG(0,("read_socket_with_timeout: timeout " + 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_socket_with_timeout: timeout " + DEBUG(0,("read_fd_with_timeout: timeout " "read. select error = %s.\n", strerror(save_errno) )); } @@ -634,16 +636,16 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, /* Did we timeout ? */ if (selrtn == 0) { - DEBUG(10,("read_socket_with_timeout: timeout read. " + DEBUG(10,("read_fd_with_timeout: timeout read. " "select timed out.\n")); return NT_STATUS_IO_TIMEOUT; } - readret = sys_recv(fd, buf+nread, maxcnt-nread, 0); + readret = sys_read(fd, buf+nread, maxcnt-nread); if (readret == 0) { /* we got EOF on the file descriptor */ - DEBUG(5,("read_socket_with_timeout: timeout read. " + DEBUG(5,("read_fd_with_timeout: timeout read. " "EOF from client.\n")); return NT_STATUS_END_OF_FILE; } @@ -654,12 +656,12 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, if (fd == get_client_fd()) { /* Try and give an error message * saying what client failed. */ - DEBUG(0,("read_socket_with_timeout: timeout " + 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_socket_with_timeout: timeout " + DEBUG(0,("read_fd_with_timeout: timeout " "read. read error = %s.\n", strerror(save_errno) )); } @@ -678,16 +680,20 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, } /**************************************************************************** - Read data from the client, reading exactly N bytes. + Read data from an fd, reading exactly N bytes. + NB. This can be called with a non-socket fd, don't add dependencies + on socket calls. ****************************************************************************/ NTSTATUS read_data(int fd, char *buffer, size_t N) { - return read_socket_with_timeout(fd, buffer, N, N, 0, NULL); + return read_fd_with_timeout(fd, buffer, N, N, 0, NULL); } /**************************************************************************** Write all data from an iov array + NB. This can be called with a non-socket fd, don't add dependencies + on socket calls. ****************************************************************************/ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt) @@ -757,6 +763,8 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt) /**************************************************************************** Write data to a fd. + NB. This can be called with a non-socket fd, don't add dependencies + on socket calls. ****************************************************************************/ ssize_t write_data(int fd, const char *buffer, size_t N) @@ -817,7 +825,7 @@ NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf, int msg_type; NTSTATUS status; - status = read_socket_with_timeout(fd, inbuf, 4, 4, timeout, NULL); + status = read_fd_with_timeout(fd, inbuf, 4, 4, timeout, NULL); if (!NT_STATUS_IS_OK(status)) { return status; @@ -898,7 +906,7 @@ NTSTATUS receive_smb_raw(int fd, char *buffer, size_t buflen, unsigned int timeo len = MIN(len,maxlen); } - status = read_socket_with_timeout( + status = read_fd_with_timeout( fd, buffer+4, len, len, timeout, &len); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index bc2a092de3..1ea8033fc6 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -296,7 +296,7 @@ ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len) set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK); - status = read_socket_with_timeout( + status = read_fd_with_timeout( cli->fd, buffer, len, len, cli->timeout, NULL); if (NT_STATUS_IS_OK(status)) { return len; diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 64f988f1f7..eaee3d8509 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -269,7 +269,7 @@ static int expect(int master, char *issue, char *expected) buffer[nread] = 0; while (True) { - status = read_socket_with_timeout( + status = read_fd_with_timeout( master, buffer + nread, 1, sizeof(buffer) - nread - 1, timeout, &len); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 6ec46071ff..dd58ea88fa 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -128,7 +128,7 @@ static NTSTATUS read_packet_remainder(int fd, char *buffer, return NT_STATUS_OK; } - return read_socket_with_timeout(fd, buffer, len, len, timeout, NULL); + return read_fd_with_timeout(fd, buffer, len, len, timeout, NULL); } /**************************************************************************** @@ -162,7 +162,7 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx, memcpy(writeX_header, lenbuf, 4); - status = read_socket_with_timeout( + status = read_fd_with_timeout( fd, writeX_header + 4, STANDARD_WRITE_AND_X_HEADER_SIZE, STANDARD_WRITE_AND_X_HEADER_SIZE, |