This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
a composite API for making a full SMB connection
#include "libcli/composite/composite.h"
#include "libcli/smb_composite/smb_composite.h"
#include "lib/events/events.h"
+#include "libcli/resolve/resolve.h"
+#include "auth/credentials/credentials.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/* the stages of this call */
enum connect_stage {CONNECT_RESOLVE,
{
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
- state->req = smb_raw_negotiate_send(state->transport, lp_maxprotocol());
+ state->req = smb_raw_negotiate_send(state->transport,
+ lp_cli_maxprotocol(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(state->req);
state->req->async.fn = request_handler;
state->io_setup->in.credentials = cli_credentials_init(state);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
- cli_credentials_set_conf(state->io_setup->in.credentials);
+ cli_credentials_set_conf(state->io_setup->in.credentials,
+ global_loadparm);
cli_credentials_set_anonymous(state->io_setup->in.credentials);
/* If the preceding attempt was with extended security, we
* have been given a uid in the NTLMSSP_CHALLENGE reply. This
* would lead to an invalid uid in the anonymous fallback */
state->session->vuid = 0;
+ data_blob_free(&state->session->user_session_key);
+ talloc_free(state->session->gensec);
+ state->session->gensec = NULL;
state->creq = smb_composite_sesssetup_send(state->session,
state->io_setup);
state->transport = smbcli_transport_init(state->sock, state, True);
NT_STATUS_HAVE_NO_MEMORY(state->transport);
- if (state->io->in.called_name != NULL) {
+ if (is_ipaddress(state->sock->hostname) &&
+ (state->io->in.called_name != NULL)) {
/* If connecting to an IP address, we might want the real name
* of the host for later kerberos. The called name is a better
* approximation */
c = talloc_zero(mem_ctx, struct composite_context);
if (c == NULL) goto failed;
- state = talloc(c, struct connect_state);
+ state = talloc_zero(c, struct connect_state);
if (state == NULL) goto failed;
if (event_ctx == NULL) {
state->stage = CONNECT_RESOLVE;
make_nbt_name_server(&name, io->in.dest_host);
- state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ state->creq = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
if (state->creq == NULL) goto failed;
state->creq->async.private_data = c;