diff options
-rw-r--r-- | source3/client/client.c | 17 | ||||
-rw-r--r-- | source3/include/client.h | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 4 | ||||
-rw-r--r-- | source3/include/smb.h | 13 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 20 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 8 | ||||
-rw-r--r-- | source3/libsmb/clierror.c | 80 |
7 files changed, 10 insertions, 134 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 130dbe0dcff..780b3ebaa01 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -4937,8 +4937,6 @@ static void readline_callback(void) NTSTATUS status; size_t len; - set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK); - status = receive_smb_raw(cli->fd, cli->inbuf, cli->bufsize, 0, 0, &len); if (!NT_STATUS_IS_OK(status)) { @@ -4948,23 +4946,10 @@ static void readline_callback(void) } DEBUG(0, ("Read from server failed, maybe it closed " - "the connection\n")); + "the connection: %s\n", nt_errstr(status))); finished = true; smb_readline_done(); - if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { - set_smb_read_error(&cli->smb_rw_error, - SMB_READ_EOF); - return; - } - - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - set_smb_read_error(&cli->smb_rw_error, - SMB_READ_TIMEOUT); - return; - } - - set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR); return; } if(CVAL(cli->inbuf,0) != SMBkeepalive) { diff --git a/source3/include/client.h b/source3/include/client.h index 2f8a572202f..fc591828ae9 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -53,8 +53,6 @@ struct cli_state { struct cli_state *prev, *next; int port; int fd; - /* Last read or write error. */ - enum smb_read_errors smb_rw_error; uint16 cnum; uint16 pid; uint16 mid; diff --git a/source3/include/proto.h b/source3/include/proto.h index 715641fc723..822ed1cd15a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -731,10 +731,6 @@ int get_socket_port(int fd); const char *client_addr(int fd, char *addr, size_t addrlen); const char *client_socket_addr(int fd, char *addr, size_t addr_len); int client_socket_port(int fd); -void set_smb_read_error(enum smb_read_errors *pre, - enum smb_read_errors newerr); -void cond_set_smb_read_error(enum smb_read_errors *pre, - enum smb_read_errors newerr); bool is_a_socket(int fd); void set_socket_options(int fd, const char *options); ssize_t read_udp_v4_socket(int fd, diff --git a/source3/include/smb.h b/source3/include/smb.h index 0c1a76eaf71..11664b32ac3 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -71,19 +71,6 @@ /* how long to wait for secondary SMB packets (milli-seconds) */ #define SMB_SECONDARY_WAIT (60*1000) -/* this defines the error codes that receive_smb can put in smb_read_error */ -enum smb_read_errors { - SMB_READ_OK = 0, - SMB_READ_TIMEOUT, - SMB_READ_EOF, - SMB_READ_ERROR, - SMB_WRITE_ERROR, /* This error code can go into the client smb_rw_error. */ - SMB_READ_BAD_SIG, - SMB_NO_MEMORY, - SMB_DO_NOT_DO_TDIS, /* cli_close_connection() check for this when smbfs wants to keep tree connected */ - SMB_READ_BAD_DECRYPT -}; - #define DIR_STRUCT_SIZE 43 /* deny modes */ diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 867646bc503..da84d76aa6a 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -48,26 +48,6 @@ int client_socket_port(int fd) #endif /**************************************************************************** - Accessor functions to make thread-safe code easier later... -****************************************************************************/ - -void set_smb_read_error(enum smb_read_errors *pre, - enum smb_read_errors newerr) -{ - if (pre) { - *pre = newerr; - } -} - -void cond_set_smb_read_error(enum smb_read_errors *pre, - enum smb_read_errors newerr) -{ - if (pre && *pre == SMB_READ_OK) { - *pre = newerr; - } -} - -/**************************************************************************** Determine if a file descriptor is in fact a socket. ****************************************************************************/ diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 91e7fd4b7f7..41f5cb59399 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -204,7 +204,6 @@ struct cli_state *cli_initialise_ex(int signing_state) cli->inbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN); cli->oplock_handler = cli_oplock_ack; cli->case_sensitive = false; - cli->smb_rw_error = SMB_READ_OK; cli->use_spnego = lp_client_use_spnego(); @@ -303,12 +302,8 @@ static void _cli_shutdown(struct cli_state *cli) * can remain active on the peer end, until some (long) timeout period * later. This tree disconnect forces the peer to clean up, since the * connection will be going away. - * - * Also, do not do tree disconnect when cli->smb_rw_error is SMB_DO_NOT_DO_TDIS - * the only user for this so far is smbmount which passes opened connection - * down to kernel's smbfs module. */ - if ( (cli->cnum != (uint16)-1) && (cli->smb_rw_error != SMB_DO_NOT_DO_TDIS ) ) { + if (cli->cnum != (uint16)-1) { cli_tdis(cli); } @@ -321,7 +316,6 @@ static void _cli_shutdown(struct cli_state *cli) close(cli->fd); } cli->fd = -1; - cli->smb_rw_error = SMB_READ_OK; /* * Need to free pending first, they remove themselves diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 32de7ecd44a..4b6f0448816 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -31,33 +31,6 @@ static const char *cli_smb_errstr(struct cli_state *cli) return smb_dos_errstr(cli->inbuf); } -/**************************************************************************** - Convert a socket error into an NTSTATUS. -****************************************************************************/ - -static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) -{ - switch(cli->smb_rw_error) { - case SMB_READ_TIMEOUT: - return NT_STATUS_IO_TIMEOUT; - case SMB_READ_EOF: - return NT_STATUS_END_OF_FILE; - /* What we shoud really do for read/write errors is convert from errno. */ - /* FIXME. JRA. */ - case SMB_READ_ERROR: - return NT_STATUS_INVALID_NETWORK_RESPONSE; - case SMB_WRITE_ERROR: - return NT_STATUS_UNEXPECTED_NETWORK_ERROR; - case SMB_READ_BAD_SIG: - return NT_STATUS_INVALID_PARAMETER; - case SMB_NO_MEMORY: - return NT_STATUS_NO_MEMORY; - default: - break; - } - return NT_STATUS_UNSUCCESSFUL; -} - /*************************************************************************** Return an error message - either an NT error, SMB error or a RAP error. Note some of the NT errors are actually warnings or "informational" errors @@ -76,42 +49,6 @@ const char *cli_errstr(struct cli_state *cli) goto done; } - /* Was it server socket error ? */ - if (cli->fd == -1 && cli->smb_rw_error) { - switch(cli->smb_rw_error) { - case SMB_READ_TIMEOUT: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Call timed out: server did not respond after %d milliseconds", - cli->timeout); - break; - case SMB_READ_EOF: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Call returned zero bytes (EOF)" ); - break; - case SMB_READ_ERROR: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Read error: %s", strerror(errno) ); - break; - case SMB_WRITE_ERROR: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Write error: %s", strerror(errno) ); - break; - case SMB_READ_BAD_SIG: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Server packet had invalid SMB signature!"); - break; - case SMB_NO_MEMORY: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Out of memory"); - break; - default: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Unknown error code %d\n", cli->smb_rw_error ); - break; - } - goto done; - } - /* Case #1: RAP error */ if (cli->rap_error) { strlcpy(cli_error_message, win_errstr(W_ERROR(cli->rap_error)), @@ -148,8 +85,8 @@ NTSTATUS cli_nt_error(struct cli_state *cli) int flgs2 = SVAL(cli->inbuf,smb_flg2); /* Deal with socket errors first. */ - if (cli->fd == -1 && cli->smb_rw_error) { - return cli_smb_rw_error_to_ntstatus(cli); + if (cli->fd == -1) { + return NT_STATUS_CONNECTION_DISCONNECTED; } if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) { @@ -175,10 +112,9 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) return; } - /* Deal with socket errors first. */ - if (cli->fd == -1 && cli->smb_rw_error) { - NTSTATUS status = cli_smb_rw_error_to_ntstatus(cli); - ntstatus_to_dos( status, eclass, ecode); + if (cli->fd == -1) { + *eclass = ERRDOS; + *ecode = ERRnotconnected; return; } @@ -236,7 +172,7 @@ bool cli_is_error(struct cli_state *cli) uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; /* A socket error is always an error. */ - if (cli->fd == -1 && cli->smb_rw_error != 0) { + if (cli->fd == -1) { return True; } @@ -259,7 +195,7 @@ bool cli_is_nt_error(struct cli_state *cli) uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); /* A socket error is always an NT error. */ - if (cli->fd == -1 && cli->smb_rw_error != 0) { + if (cli->fd == -1) { return True; } @@ -273,7 +209,7 @@ bool cli_is_dos_error(struct cli_state *cli) uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); /* A socket error is always a DOS error. */ - if (cli->fd == -1 && cli->smb_rw_error != 0) { + if (cli->fd == -1) { return True; } |