]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:smb_server: make use of smb_transports_parse() in smbsrv_add_socket()
authorStefan Metzmacher <metze@samba.org>
Thu, 3 Apr 2025 11:43:46 +0000 (13:43 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:29 +0000 (10:17 +0000)
Here we will only support tcp and nbt...,
but that will simplify the global transition from 'smb ports' to
'server smb transports'.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/smb_server/smb_server.c

index c45df702c3f08d5e39d6d3bfe57e4e6ba2e4a6cd..f6118bafd51a11f9783cadefc29e320657b0f091 100644 (file)
@@ -181,19 +181,45 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx,
                                    const char *address,
                                    void *process_context)
 {
-       const char **ports = lpcfg_smb_ports(lp_ctx);
+       struct smb_transports ts =
+               smb_transports_parse("smb ports",
+                       lpcfg_smb_ports(lp_ctx));
+       bool found_valid = false;
        int i;
        NTSTATUS status;
 
-       for (i=0;ports[i];i++) {
-               uint16_t port = atoi(ports[i]);
-               if (port == 0) continue;
+       for (i=0; i < ts.num_transports;i++) {
+               const struct smb_transport *t = &ts.transports[i];
+               uint16_t port = 0;
+
+               switch (t->type) {
+               case SMB_TRANSPORT_TYPE_NBT:
+               case SMB_TRANSPORT_TYPE_TCP:
+                       port = t->port;
+                       break;
+               case SMB_TRANSPORT_TYPE_UNKNOWN:
+                       break;
+               }
+
+               if (port == 0) {
+                       /*
+                        * Ignore unsupported transports
+                        */
+                       continue;
+               }
+
                status = stream_setup_socket(mem_ctx, event_context, lp_ctx,
                                             model_ops, &smb_stream_ops, 
                                             "ip", address, &port,
                                             lpcfg_socket_options(lp_ctx),
                                             NULL, process_context);
                NT_STATUS_NOT_OK_RETURN(status);
+
+               found_valid = true;
+       }
+
+       if (!found_valid) {
+               return NT_STATUS_NO_IP_ADDRESSES;
        }
 
        return NT_STATUS_OK;