s3-smbd: expose smbd_set_server_fd()
[samba.git] / source3 / smbd / server.c
index 8c7b146e19e9701bc1464ead080e6f7cf70a867b..29acf8d2219790e203fb4554bfbd45f68b308958 100644 (file)
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "popt_common.h"
+#include "smbd/smbd.h"
 #include "smbd/globals.h"
-#include "librpc/gen_ndr/messaging.h"
-#include "registry.h"
 #include "registry/reg_init_full.h"
 #include "libcli/auth/schannel.h"
 #include "secrets.h"
 #include "printing/pcap.h"
 #include "printing.h"
 #include "serverid.h"
+#include "passdb.h"
+#include "auth.h"
+#include "messages.h"
+#include "smbprofile.h"
 
 extern void start_epmd(struct tevent_context *ev_ctx,
                       struct messaging_context *msg_ctx);
@@ -47,35 +51,6 @@ extern void start_spoolssd(struct event_context *ev_ctx,
 extern int dcelogin_atmost_once;
 #endif /* WITH_DFS */
 
-static void smbd_set_server_fd(int fd)
-{
-       struct smbd_server_connection *sconn = smbd_server_conn;
-       char addr[INET6_ADDRSTRLEN];
-       const char *name;
-
-       sconn->sock = fd;
-
-       /*
-        * Initialize sconn->client_id: If we can't find the client's
-        * name, default to its address.
-        */
-
-       client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr));
-
-       name = client_name(sconn->sock);
-       if (strcmp(name, "UNKNOWN") != 0) {
-               name = talloc_strdup(sconn, name);
-       } else {
-               name = NULL;
-       }
-       sconn->client_id.name =
-               (name != NULL) ? name : sconn->client_id.addr;
-
-       sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name,
-                          client_socket_addr(sconn->sock, addr,
-                                             sizeof(addr)));
-}
-
 struct event_context *smbd_event_context(void)
 {
        return server_event_context();
@@ -677,6 +652,13 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
                                        continue;
                                }
 
+                               /* Keep the first port for mDNS service
+                                * registration.
+                                */
+                               if (dns_port == 0) {
+                                       dns_port = port;
+                               }
+
                                if (!smbd_open_one_socket(parent, ifss, port)) {
                                        return false;
                                }