From: Stefan Metzmacher Date: Sun, 6 Apr 2025 17:05:19 +0000 (+0200) Subject: s3:libsmb: pass struct smb_transports to smbsock_any_connect() X-Git-Tag: tevent-0.17.0~274 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffa72afa65f012dfe9cc02b586d92ba8683f2c27;p=thirdparty%2Fsamba.git s3:libsmb: pass struct smb_transports to smbsock_any_connect() Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 23e30959b97..7cf2572e6ee 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -690,10 +690,11 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, const char **calling_names, int *calling_types, size_t num_addrs, - uint16_t port, + const struct smb_transports *transports, int sec_timeout, int *pfd, size_t *chosen_index, - uint16_t *chosen_port); + uint16_t *chosen_port) + NONNULL(1) NONNULL(7) NONNULL(9); /* The following definitions come from lib/util_wellknown.c */ diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index c327cc7566f..0691a677cdd 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -1030,7 +1030,7 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, const char **calling_names, int *calling_types, size_t num_addrs, - uint16_t port, + const struct smb_transports *transports, int sec_timeout, int *pfd, size_t *chosen_index, uint16_t *chosen_port) @@ -1038,7 +1038,6 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, TALLOC_CTX *frame = talloc_stackframe(); struct tevent_context *ev; struct tevent_req *req; - struct smb_transports ts = smbsock_transports_from_port(port); NTSTATUS status = NT_STATUS_NO_MEMORY; ev = samba_tevent_context_init(frame); @@ -1048,7 +1047,7 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, req = smbsock_any_connect_send(frame, ev, addrs, called_names, called_types, calling_names, calling_types, - num_addrs, &ts); + num_addrs, transports); if (req == NULL) { goto fail; } diff --git a/source3/torture/test_smbsock_any_connect.c b/source3/torture/test_smbsock_any_connect.c index a964e0fd831..8fbf0ac6f8a 100644 --- a/source3/torture/test_smbsock_any_connect.c +++ b/source3/torture/test_smbsock_any_connect.c @@ -25,6 +25,9 @@ bool run_smb_any_connect(int dummy) int fd; NTSTATUS status; struct sockaddr_storage addrs[5]; + struct smb_transports ts = + smb_transports_parse("client smb transports", + lp_client_smb_transports()); size_t chosen_index; uint16_t port; @@ -35,7 +38,7 @@ bool run_smb_any_connect(int dummy) interpret_string_addr(&addrs[4], "192.168.99.9", 0); status = smbsock_any_connect(addrs, NULL, NULL, NULL, NULL, - ARRAY_SIZE(addrs), 0, 0, + ARRAY_SIZE(addrs), &ts, 0, &fd, &chosen_index, &port); d_printf("smbsock_any_connect returned %s (fd %d)\n", diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index dd8d2fae830..d0fa451e83a 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1551,7 +1551,9 @@ static bool find_dc(TALLOC_CTX *mem_ctx, struct sockaddr_storage *addrs = NULL; int num_addrs = 0; - + struct smb_transports ts = + smb_transports_parse("client smb transports", + lp_client_smb_transports()); int i; size_t fd_index; @@ -1600,7 +1602,7 @@ static bool find_dc(TALLOC_CTX *mem_ctx, "(timeout of 10 sec for each DC).\n", num_dcs); status = smbsock_any_connect(addrs, dcnames, NULL, NULL, NULL, - num_addrs, 0, 10, fd, &fd_index, NULL); + num_addrs, &ts, 10, fd, &fd_index, NULL); if (!NT_STATUS_IS_OK(status)) { for (i=0; i