From 80d714e75b48b6ed75de48ea0ca878736eb9b259 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 3 Aug 1999 17:21:34 +0000 Subject: close socket issues: - ssl close from cli_reestablish_connection() not called. - ntlmv2 fall-back to ntlmv1 failed. (This used to be commit fdc275353de85fde0c348320e4d64ba66365b73b) --- source3/libsmb/clientgen.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'source3/libsmb/clientgen.c') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index beb73e736b..765160ffe4 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -2555,6 +2555,24 @@ struct cli_state *cli_initialise(struct cli_state *cli) return cli; } +/**************************************************************************** +close the socket descriptor +****************************************************************************/ +void cli_close_socket(struct cli_state *cli) +{ +#ifdef WITH_SSL + if (cli->fd != -1) + { + sslutil_disconnect(cli->fd); + } +#endif /* WITH_SSL */ + if (cli->fd != -1) + { + close(cli->fd); + } + cli->fd = -1; +} + /**************************************************************************** shutdown a client structure ****************************************************************************/ @@ -2569,14 +2587,7 @@ void cli_shutdown(struct cli_state *cli) { free(cli->inbuf); } -#ifdef WITH_SSL - if (cli->fd != -1) - sslutil_disconnect(cli->fd); -#endif /* WITH_SSL */ - if (cli->fd != -1) - { - close(cli->fd); - } + cli_close_socket(cli); memset(cli, 0, sizeof(*cli)); } @@ -2702,15 +2713,19 @@ BOOL cli_reestablish_connection(struct cli_state *cli) /* copy the parameters necessary to re-establish the connection */ if (cli->cnum != 0) + { + do_tcon = True; + } + + if (do_tcon) { fstrcpy(share, cli->share); fstrcpy(dev , cli->dev); - do_tcon = True; } memcpy(&called , &(cli->called ), sizeof(called )); memcpy(&calling, &(cli->calling), sizeof(calling)); - fstrcpy(dest_host, cli->full_dest_host_name); + fstrcpy(dest_host, cli->desthost); DEBUG(5,("cli_reestablish_connection: %s connecting to %s (ip %s) - %s [%s]\n", nmb_namestr(&calling), nmb_namestr(&called), @@ -2728,7 +2743,7 @@ BOOL cli_reestablish_connection(struct cli_state *cli) { if (dup2(cli->fd, oldfd) == oldfd) { - close(cli->fd); + cli_close_socket(cli); } } return True; @@ -2873,6 +2888,13 @@ BOOL cli_establish_connection(struct cli_state *cli, { DEBUG(10,("NTLMv2 failed. Using NTLMv1\n")); cli->use_ntlmv2 = False; + if (do_tcon) + { + fstrcpy(cli->share, service); + fstrcpy(cli->dev, service_type); + } + fstrcpy(cli->desthost, dest_host); + cli_close_socket(cli); return cli_establish_connection(cli, dest_host, dest_ip, calling, called, -- cgit