s3:smbd: pass smbd_server_connection and a snumused function pointer to reload_services()
authorStefan Metzmacher <metze@samba.org>
Wed, 14 Dec 2011 12:25:20 +0000 (13:25 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 15 Dec 2011 10:11:24 +0000 (11:11 +0100)
metze

source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/smbd/negprot.c
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/reply.c
source3/smbd/server.c
source3/smbd/server_reload.c
source3/smbd/sesssetup.c
source3/smbd/smb2_sesssetup.c
source3/torture/vfstest.c

index 491d96566a8e10b80bd3ab0e9d40287b8dfda156..87df5659c7819d9984b382065e37734c9bf38bcc 100644 (file)
@@ -6202,6 +6202,16 @@ static WERROR add_port_hook(TALLOC_CTX *ctx, struct security_token *token, const
 /****************************************************************************
 ****************************************************************************/
 
+static bool spoolss_conn_snum_used(struct smbd_server_connection *sconn,
+                                  int snum)
+{
+       /*
+        * As we do not know if we are embedded in the file server process
+        * or not, we have to pretend that all shares are in use.
+        */
+       return true;
+}
+
 static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
                             struct spoolss_SetPrinterInfo2 *info2,
                             const char *remote_machine,
@@ -6260,7 +6270,7 @@ static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
 
        /* reload our services immediately */
        become_root();
-       reload_services(msg_ctx, -1, false);
+       reload_services(NULL, spoolss_conn_snum_used, false);
        unbecome_root();
 
        numlines = 0;
index ae9ce5a2cfcb414341c7ed7e15a8f222028d2fef..52ef96d5fc9ab93a768d1919ffbb1da3e7e60d66 100644 (file)
@@ -714,7 +714,7 @@ void reply_negprot(struct smb_request *req)
        }
 
        /* possibly reload - change of architecture */
-       reload_services(sconn->msg_ctx, sconn->sock, True);
+       reload_services(sconn, conn_snum_used, true);
 
        /* moved from the netbios session setup code since we don't have that 
           when the client connects to port 445.  Of course there is a small
@@ -740,7 +740,7 @@ void reply_negprot(struct smb_request *req)
 
        if(choice != -1) {
                fstrcpy(remote_proto,supported_protocols[protocol].short_name);
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
                supported_protocols[protocol].proto_reply_fn(req, choice);
                DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
        } else {
index 2b35680949b21531bdaa5e092e9ad07e967241c2..c44826778188f13bcaf4358cc1628e897598e310 100644 (file)
@@ -908,7 +908,7 @@ static void smbd_sig_hup_handler(struct tevent_context *ev,
 
        change_to_root_user();
        DEBUG(1,("Reloading services after SIGHUP\n"));
-       reload_services(sconn->msg_ctx, sconn->sock, false);
+       reload_services(sconn, conn_snum_used, false);
 }
 
 void smbd_setup_sig_hup_handler(struct smbd_server_connection *sconn)
@@ -938,7 +938,7 @@ static void smbd_conf_updated(struct messaging_context *msg,
        DEBUG(10,("smbd_conf_updated: Got message saying smb.conf was "
                  "updated. Reloading.\n"));
        change_to_root_user();
-       reload_services(sconn->msg_ctx, sconn->sock, False);
+       reload_services(sconn, conn_snum_used, false);
 }
 
 static NTSTATUS smbd_server_connection_loop_once(struct tevent_context *ev_ctx,
@@ -2221,7 +2221,7 @@ static void check_reload(struct smbd_server_connection *sconn, time_t t)
        }
 
        if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) {
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
                last_smb_conf_reload_time = t;
        }
 }
@@ -3183,7 +3183,7 @@ void smbd_process(struct tevent_context *ev_ctx,
        /* this is needed so that we get decent entries
           in smbstatus for port 445 connects */
        set_remote_machine_name(remaddr, false);
-       reload_services(sconn->msg_ctx, sconn->sock, true);
+       reload_services(sconn, conn_snum_used, true);
 
        /*
         * Before the first packet, check the global hosts allow/ hosts deny
index 2fd59a1f47132b0c71a89977e4c5f9b86c1ba28a..92b1443a98d56d2e6d4cc856e5975b83b500ba95 100644 (file)
@@ -955,7 +955,8 @@ void init_sec_ctx(void);
 struct memcache *smbd_memcache(void);
 void delete_and_reload_printers(struct tevent_context *ev,
                                struct messaging_context *msg_ctx);
-bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
+bool reload_services(struct smbd_server_connection *sconn,
+                    bool (*snumused) (struct smbd_server_connection *, int),
                     bool test);
 void exit_server(const char *const explanation);
 void exit_server_cleanly(const char *const explanation);
index a06e7b83391c0700fc192922450fb52898ebfa23..d9b7500707860e24b70714c45a2fcb6978d9c65b 100644 (file)
@@ -606,7 +606,7 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
                        add_session_user(sconn, get_remote_machine_name());
                }
 
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
                reopen_logs();
 
                sconn->nbt.got_session = true;
index e58128ea58eae72a23c54612ffbbb206b065d45e..369b7ab450d69a3889a9a21ab0ca93204a72c9d9 100644 (file)
@@ -99,7 +99,7 @@ static void smbd_parent_conf_updated(struct messaging_context *msg,
        DEBUG(10,("smbd_parent_conf_updated: Got message saying smb.conf was "
                  "updated. Reloading.\n"));
        change_to_root_user();
-       reload_services(msg, -1, false);
+       reload_services(NULL, NULL, false);
        printing_subsystem_update(ev_ctx, msg, false);
 }
 
@@ -910,7 +910,7 @@ static void smbd_parent_sig_hup_handler(struct tevent_context *ev,
 
        change_to_root_user();
        DEBUG(1,("parent: Reloading services after SIGHUP\n"));
-       reload_services(parent->msg_ctx, -1, false);
+       reload_services(NULL, NULL, false);
 
        printing_subsystem_update(parent->ev_ctx, parent->msg_ctx, true);
 }
@@ -1138,7 +1138,7 @@ extern void build_options(bool screen);
         * Reloading of the printers will not work here as we don't have a
         * server info and rpc services set up. It will be called later.
         */
-       if (!reload_services(NULL, -1, False)) {
+       if (!reload_services(NULL, NULL, false)) {
                exit(1);
        }
 
index 0c2ea2c5b127d36d9a52949530a6f1bdb352c762..f15f80e13fadfa3fe8a8a2dafbf3d900c67d1ad4 100644 (file)
@@ -106,7 +106,8 @@ void delete_and_reload_printers(struct tevent_context *ev,
  Reload the services file.
 **************************************************************************/
 
-bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
+bool reload_services(struct smbd_server_connection *sconn,
+                    bool (*snumused) (struct smbd_server_connection *, int),
                     bool test)
 {
        bool ret;
@@ -125,25 +126,22 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
        if (test && !lp_file_list_changed())
                return(True);
 
-       if (msg_ctx) {
-               lp_killunused(msg_ctx_to_sconn(msg_ctx), conn_snum_used);
-       } else {
-               lp_killunused(NULL, NULL);
-       }
+       lp_killunused(sconn, snumused);
 
        ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
 
        /* perhaps the config filename is now set */
-       if (!test)
-               reload_services(msg_ctx, smb_sock, True);
+       if (!test) {
+               reload_services(sconn, snumused, true);
+       }
 
        reopen_logs();
 
        load_interfaces();
 
-       if (smb_sock != -1) {
-               set_socket_options(smb_sock,"SO_KEEPALIVE");
-               set_socket_options(smb_sock, lp_socket_options());
+       if (sconn != NULL) {
+               set_socket_options(sconn->sock, "SO_KEEPALIVE");
+               set_socket_options(sconn->sock, lp_socket_options());
        }
 
        mangle_reset_cache();
index 5fa571a0e9cbbfad6aebad55aab0cc9e7cf5fda0..889361acb8d745218753fac2b3b1fda712ec5abd 100644 (file)
@@ -341,7 +341,7 @@ static void reply_spnego_kerberos(struct smb_request *req,
        sub_set_smb_name(real_username);
 
        /* reload services so that the new %U is taken into account */
-       reload_services(sconn->msg_ctx, sconn->sock, True);
+       reload_services(sconn, conn_snum_used, true);
 
        ret = make_session_info_krb5(mem_ctx,
                                     user, domain, real_username, pw,
@@ -377,7 +377,7 @@ static void reply_spnego_kerberos(struct smb_request *req,
                ret = NT_STATUS_LOGON_FAILURE;
        } else {
                /* current_user_info is changed on new vuid */
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
 
                SSVAL(req->outbuf, smb_vwv3, 0);
 
@@ -462,7 +462,7 @@ static void reply_spnego_ntlmssp(struct smb_request *req,
                }
 
                /* current_user_info is changed on new vuid */
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
 
                SSVAL(req->outbuf, smb_vwv3, 0);
 
@@ -1574,7 +1574,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
 
        sub_set_smb_name(sub_user);
 
-       reload_services(sconn->msg_ctx, sconn->sock, True);
+       reload_services(sconn, conn_snum_used, true);
 
        if (lp_security() == SEC_SHARE) {
                char *sub_user_mapped = NULL;
@@ -1727,7 +1727,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
                }
 
                /* current_user_info is changed on new vuid */
-               reload_services(sconn->msg_ctx, sconn->sock, True);
+               reload_services(sconn, conn_snum_used, true);
        }
 
        data_blob_free(&nt_resp);
index 64fa44605916caafc46fc6379f1df344e3eca19b..f2ce989eb60fb392cdad321b6c14d49cec8f2be6 100644 (file)
@@ -209,7 +209,7 @@ static NTSTATUS smbd_smb2_session_setup_krb5(struct smbd_smb2_session *session,
        sub_set_smb_name(real_username);
 
        /* reload services so that the new %U is taken into account */
-       reload_services(smb2req->sconn->msg_ctx, smb2req->sconn->sock, true);
+       reload_services(smb2req->sconn, conn_snum_used, true);
 
        status = make_session_info_krb5(session,
                                        user, domain, real_username, pw,
index 3ed49c021e5b5d9a1c562e0dfe14b9029de56ba4..01deba00d30cd0fd8d5e5dba4f2cbb17f8a25672 100644 (file)
@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
        lp_load_initial_only(get_dyn_CONFIGFILE());
 
        /* TODO: check output */
-       reload_services(NULL, -1, False);
+       reload_services(NULL, NULL, false);
 
        /* the following functions are part of the Samba debugging
           facilities.  See lib/debug.c */