From b8d76d07393cd7ca1db30440f91aa8c9ee26235e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 3 Apr 2025 14:37:02 +0200 Subject: [PATCH] s3:smbd: only do dns_port logic in one central place. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- source3/smbd/server.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index abd53e23c05..b966739cff6 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1178,6 +1178,13 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, exit_server_cleanly("Invalid port in the config or on " "the commandline specified!"); } + + /* Keep the first port for mDNS service + * registration. + */ + if (dns_port == 0) { + dns_port = port; + } } if (lp_interfaces() && lp_bind_interfaces_only()) { @@ -1201,13 +1208,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, for (j = 0; ports && ports[j]; j++) { unsigned port = atoi(ports[j]); - /* Keep the first port for mDNS service - * registration. - */ - if (dns_port == 0) { - dns_port = port; - } - if (!smbd_open_one_socket(parent, ev_ctx, ifss, @@ -1236,13 +1236,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, struct sockaddr_storage ss; unsigned port = atoi(ports[j]); - /* Keep the first port for mDNS service - * registration. - */ - if (dns_port == 0) { - dns_port = port; - } - /* open an incoming socket */ if (!interpret_string_addr(&ss, sock_tok, AI_NUMERICHOST|AI_PASSIVE)) { -- 2.47.3