]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: only do dns_port logic in one central place.
authorStefan Metzmacher <metze@samba.org>
Thu, 3 Apr 2025 12:37:02 +0000 (14:37 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:29 +0000 (10:17 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/server.c

index abd53e23c0503d4e520b1b39d704b0360f227fdf..b966739cff670b782858616cbc684703cfc01f6e 100644 (file)
@@ -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)) {