}
struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
- int fd,
+ struct smbXcli_transport **ptransport,
const char *remote_name,
enum smb_signing_setting signing_state,
uint32_t smb1_capabilities,
uint32_t smb2_capabilities,
const struct smb311_capabilities *smb3_capabilities)
{
- struct smb_transport tp = { .type = SMB_TRANSPORT_TYPE_UNKNOWN, };
struct smbXcli_conn *conn = NULL;
if (smb3_capabilities != NULL) {
return NULL;
}
- conn->transport = smbXcli_transport_bsd(conn, fd, &tp);
- if (conn->transport == NULL) {
- goto error;
- }
+ conn->transport = talloc_move(conn, ptransport);
conn->remote_name = talloc_strdup(conn, remote_name);
if (conn->remote_name == NULL) {
const struct smb_transport *tp);
struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
- int fd,
+ struct smbXcli_transport **ptransport,
const char *remote_name,
enum smb_signing_setting signing_state,
uint32_t smb1_capabilities,
enum smb_signing_setting signing_state,
int flags)
{
+ struct smb_transport tp = { .type = SMB_TRANSPORT_TYPE_UNKNOWN, };
+ struct smbXcli_transport *transport = NULL;
struct cli_state *cli = NULL;
bool use_spnego = lp_client_use_spnego();
bool force_dos_errors = false;
smb2_capabilities = SMB2_CAP_ALL;
- cli->conn = smbXcli_conn_create(cli, fd, remote_name,
+ transport = smbXcli_transport_bsd(cli, fd, &tp);
+ if (transport == NULL) {
+ goto error;
+ }
+
+ cli->conn = smbXcli_conn_create(cli,
+ &transport,
+ remote_name,
signing_state,
smb1_capabilities,
&client_guid,
{
struct tevent_context *ev;
struct tevent_req *req;
+ struct smb_transport tp = {
+ .type = SMB_TRANSPORT_TYPE_TCP,
+ .port = 445,
+ };
+ struct smbXcli_transport *xtp = NULL;
struct smbXcli_conn *conn;
struct sockaddr_storage ss;
NTSTATUS status;
return false;
}
- conn = smbXcli_conn_create(talloc_tos(), fd, host, SMB_SIGNING_OFF, 0,
+ xtp = smbXcli_transport_bsd(talloc_tos(), fd, &tp);
+ if (xtp == NULL) {
+ d_fprintf(stderr, "smbXcli_transport_bsd failed\n");
+ return false;
+ }
+
+ conn = smbXcli_conn_create(talloc_tos(), &xtp, host, SMB_SIGNING_OFF, 0,
NULL, 0, NULL);
if (conn == NULL) {
d_fprintf(stderr, "smbXcli_conn_create failed\n");
static bool run_smb1_negotiate_exit(int dummy)
{
struct tevent_context *ev;
+ struct smb_transport tp = {
+ .type = SMB_TRANSPORT_TYPE_TCP,
+ .port = 445,
+ };
+ struct smbXcli_transport *xtp = NULL;
struct smbXcli_conn *conn;
struct sockaddr_storage ss;
NTSTATUS status;
return false;
}
- conn = smbXcli_conn_create(talloc_tos(), fd, host, SMB_SIGNING_OFF, 0,
+ xtp = smbXcli_transport_bsd(talloc_tos(), fd, &tp);
+ if (xtp == NULL) {
+ d_fprintf(stderr, "smbXcli_transport_bsd failed\n");
+ return false;
+ }
+
+ conn = smbXcli_conn_create(talloc_tos(), &xtp, host, SMB_SIGNING_OFF, 0,
NULL, 0, NULL);
if (conn == NULL) {
d_fprintf(stderr, "smbXcli_conn_create failed\n");
{
struct tevent_context *ev;
struct tevent_req *req;
+ struct smb_transport tp = {
+ .type = SMB_TRANSPORT_TYPE_TCP,
+ .port = 445,
+ };
+ struct smbXcli_transport *xtp = NULL;
struct smbXcli_conn *conn;
struct sockaddr_storage ss;
NTSTATUS status;
return false;
}
- conn = smbXcli_conn_create(talloc_tos(), fd, host, SMB_SIGNING_OFF, 0,
+ xtp = smbXcli_transport_bsd(talloc_tos(), fd, &tp);
+ if (xtp == NULL) {
+ d_fprintf(stderr, "smbXcli_transport_bsd failed\n");
+ return false;
+ }
+
+ conn = smbXcli_conn_create(talloc_tos(), &xtp, host, SMB_SIGNING_OFF, 0,
NULL, 0, NULL);
if (conn == NULL) {
d_fprintf(stderr, "smbXcli_conn_create failed\n");
struct smbcli_options *options)
{
struct smbcli_transport *transport;
+ struct smb_transport tp = { .type = SMB_TRANSPORT_TYPE_UNKNOWN, };
+ struct smbXcli_transport *xtp = NULL;
uint32_t smb1_capabilities;
transport = talloc_zero(parent_ctx, struct smbcli_transport);
smb1_capabilities |= CAP_LEVEL_II_OPLOCKS;
}
+ xtp = smbXcli_transport_bsd(transport, sock->sockfd, &tp);
+ if (xtp == NULL) {
+ TALLOC_FREE(sock);
+ TALLOC_FREE(transport);
+ return NULL;
+ }
+ sock->sockfd = -1;
+ TALLOC_FREE(sock);
+
transport->conn = smbXcli_conn_create(transport,
- sock->sockfd,
+ &xtp,
sock->hostname,
options->signing,
smb1_capabilities,
0, /* smb2_capabilities */
NULL); /* smb3_ciphers */
if (transport->conn == NULL) {
- TALLOC_FREE(sock);
+ TALLOC_FREE(xtp);
TALLOC_FREE(transport);
return NULL;
}
- sock->sockfd = -1;
- TALLOC_FREE(sock);
talloc_set_destructor(transport, transport_destructor);
struct smbcli_options *options)
{
struct smb2_transport *transport;
+ struct smb_transport tp = { .type = SMB_TRANSPORT_TYPE_UNKNOWN, };
+ struct smbXcli_transport *xtp = NULL;
transport = talloc_zero(parent_ctx, struct smb2_transport);
if (!transport) return NULL;
transport->options.max_protocol = PROTOCOL_LATEST;
}
+ xtp = smbXcli_transport_bsd(transport, sock->sockfd, &tp);
+ if (xtp == NULL) {
+ TALLOC_FREE(sock);
+ TALLOC_FREE(transport);
+ return NULL;
+ }
+ sock->sockfd = -1;
+ TALLOC_FREE(sock);
+
transport->conn = smbXcli_conn_create(transport,
- sock->sockfd,
+ &xtp,
sock->hostname,
options->signing,
0, /* smb1_capabilities */
options->smb2_capabilities,
&options->smb3_capabilities);
if (transport->conn == NULL) {
- talloc_free(transport);
+ TALLOC_FREE(xtp);
+ TALLOC_FREE(transport);
return NULL;
}
- sock->sockfd = -1;
- TALLOC_FREE(sock);
talloc_set_destructor(transport, transport_destructor);
struct smb_connect_nego_state);
struct tevent_req *subreq = NULL;
struct smbcli_socket *sock = NULL;
+ struct smb_transport tp = { .type = SMB_TRANSPORT_TYPE_UNKNOWN, };
+ struct smbXcli_transport *xtp = NULL;
uint32_t smb1_capabilities;
uint32_t timeout_msec = state->options.request_timeout * 1000;
NTSTATUS status;
smb1_capabilities |= CAP_LEVEL_II_OPLOCKS;
}
+ xtp = smbXcli_transport_bsd(state, sock->sockfd, &tp);
+ if (tevent_req_nomem(xtp, req)) {
+ return;
+ }
+ sock->sockfd = -1;
+ TALLOC_FREE(sock);
+
state->conn = smbXcli_conn_create(state,
- sock->sockfd,
+ &xtp,
state->target_hostname,
state->options.signing,
smb1_capabilities,
if (tevent_req_nomem(state->conn, req)) {
return;
}
- sock->sockfd = -1;
- TALLOC_FREE(sock);
subreq = smbXcli_negprot_send(state,
state->ev,
struct socket_context *sock = NULL;
uint16_t port = 445;
struct smbcli_options options = transport1->options;
+ struct smb_transport tp = {
+ .type = SMB_TRANSPORT_TYPE_TCP,
+ .port = port,
+ };
+ struct smbXcli_transport *xtp = NULL;
conn->state = state;
conn->idx = i;
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"socket_connect_multi failed");
+ xtp = smbXcli_transport_bsd(state->conns, sock->fd, &tp);
+ torture_assert_goto(tctx, xtp != NULL, ret, done,
+ "smbXcli_transport_bsd failed");
+ sock->fd = -1;
+ TALLOC_FREE(sock);
+
conn->smbXcli = smbXcli_conn_create(state->conns,
- sock->fd,
+ &xtp,
host,
SMB_SIGNING_OFF,
0,
&options.smb3_capabilities);
torture_assert_goto(tctx, conn->smbXcli != NULL, ret, done,
"smbXcli_conn_create failed");
- sock->fd = -1;
- TALLOC_FREE(sock);
}
/*