return NULL;
}
+static int smbcli_socket_destructor(struct smbcli_socket *sock)
+{
+ if (sock->sockfd != -1) {
+ close(sock->sockfd);
+ sock->sockfd = -1;
+ }
+
+ return 0;
+}
+
static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
{
struct sock_connect_state *state =
state->result = talloc_zero(state, struct smbcli_socket);
if (composite_nomem(state->result, state->ctx)) return;
- state->result->sock = talloc_steal(state->result, sock);
- state->result->port = port;
+ state->result->sockfd = sock->fd;
+ sock->fd = -1;
+ TALLOC_FREE(sock);
state->result->hostname = talloc_steal(state->result, state->host_name);
+ talloc_set_destructor(state->result, smbcli_socket_destructor);
+
state->result->event.ctx = state->ctx->event_ctx;
if (composite_nomem(state->result->event.ctx, state->ctx)) return;
transport->options.max_protocol = PROTOCOL_NT1;
}
- TALLOC_FREE(sock->event.fde);
- TALLOC_FREE(sock->event.te);
-
smb1_capabilities = 0;
smb1_capabilities |= CAP_LARGE_FILES;
smb1_capabilities |= CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
}
transport->conn = smbXcli_conn_create(transport,
- sock->sock->fd,
+ sock->sockfd,
sock->hostname,
options->signing,
smb1_capabilities,
TALLOC_FREE(transport);
return NULL;
}
- sock->sock->fd = -1;
+ sock->sockfd = -1;
TALLOC_FREE(sock);
talloc_set_destructor(transport, transport_destructor);
/* this is the context for a SMB socket associated with the socket itself */
struct smbcli_socket {
- struct socket_context *sock;
-
- /* what port we ended up connected to */
- int port;
+ int sockfd;
/* the hostname we connected to */
const char *hostname;
/* the event handle for waiting for socket IO */
struct {
struct tevent_context *ctx;
- struct tevent_fd *fde;
- struct tevent_timer *te;
} event;
};
transport->options.max_protocol = PROTOCOL_LATEST;
}
- TALLOC_FREE(sock->event.fde);
- TALLOC_FREE(sock->event.te);
-
transport->conn = smbXcli_conn_create(transport,
- sock->sock->fd,
+ sock->sockfd,
sock->hostname,
options->signing,
0, /* smb1_capabilities */
talloc_free(transport);
return NULL;
}
- sock->sock->fd = -1;
+ sock->sockfd = -1;
TALLOC_FREE(sock);
talloc_set_destructor(transport, transport_destructor);
return;
}
- TALLOC_FREE(sock->event.fde);
- TALLOC_FREE(sock->event.te);
-
smb1_capabilities = 0;
smb1_capabilities |= CAP_LARGE_FILES;
smb1_capabilities |= CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
}
state->conn = smbXcli_conn_create(state,
- sock->sock->fd,
+ sock->sockfd,
state->target_hostname,
state->options.signing,
smb1_capabilities,
if (tevent_req_nomem(state->conn, req)) {
return;
}
- sock->sock->fd = -1;
+ sock->sockfd = -1;
TALLOC_FREE(sock);
subreq = smbXcli_negprot_send(state,