Fix bug 6673 - smbpasswd does not work with "unix password sync = yes". Revert change...
authorJeremy Allison <jra@samba.org>
Tue, 8 Sep 2009 23:22:46 +0000 (16:22 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 9 Sep 2009 10:45:09 +0000 (12:45 +0200)
(cherry picked from commit 91a5b8561e2f13f77fa5648f7cc373aff1701954)

source3/include/proto.h
source3/lib/util_sock.c
source3/libsmb/clientgen.c
source3/smbd/chgpasswd.c
source3/smbd/process.c

index 18555bcc0c2290f8bccdd617a1f5784e1133ed95..85619eecf793fc13e25a57a0dfae810bc4b553d5 100644 (file)
@@ -1373,7 +1373,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);
index 43ea8b5a0fb73105dca04754d701acfc2c325d38..da79aca9df55e5e0d5dbc0ca57117186f2ebca70 100644 (file)
@@ -490,13 +490,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)
@@ -519,10 +521,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;
                        }
@@ -531,12 +533,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(errno) ));
                                } else {
-                                       DEBUG(0,("read_socket_with_timeout: "
+                                       DEBUG(0,("read_fd_with_timeout: "
                                                "read error = %s.\n",
                                                strerror(errno) ));
                                }
@@ -569,12 +571,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(errno) ));
                        } else {
-                               DEBUG(0,("read_socket_with_timeout: timeout "
+                               DEBUG(0,("read_fd_with_timeout: timeout "
                                "read. select error = %s.\n",
                                strerror(errno) ));
                        }
@@ -583,16 +585,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;
                }
@@ -602,12 +604,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(errno) ));
                        } else {
-                               DEBUG(0,("read_socket_with_timeout: timeout "
+                               DEBUG(0,("read_fd_with_timeout: timeout "
                                        "read. read error = %s.\n",
                                        strerror(errno) ));
                        }
@@ -626,16 +628,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)
@@ -705,6 +711,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)
@@ -765,7 +773,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;
@@ -846,7 +854,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)) {
index c1ba4e5c4f6909f325a10d73048573a3c06877c0..356db57730d9ff1b5b07e6af3e478f1dc5acee78 100644 (file)
@@ -218,7 +218,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;
index 100c0b9ec9db0734a93a29d51b25c5555624a78d..61c3afb0dc99c75a8198091cda0f96269a592429 100644 (file)
@@ -268,7 +268,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);
index e1069ebd8705ea62547dbd9db12b5dc217931455..caf92413372848b931a29667124d69facbbb7421 100644 (file)
@@ -127,7 +127,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);
 }
 
 /****************************************************************************
@@ -161,7 +161,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,