s3:smbd: add exit_server to the smbd_shim hooks
authorStefan Metzmacher <metze@samba.org>
Tue, 9 Oct 2012 12:35:04 +0000 (08:35 -0400)
committerMichael Adam <obnox@samba.org>
Fri, 19 Oct 2012 10:14:58 +0000 (12:14 +0200)
This is in preparation of moving sessionid_tdb and conn_tdb
to smbd exclusively.

metze

Signed-off-by: Michael Adam <obnox@samba.org>
source3/lib/smbd_shim.c
source3/lib/smbd_shim.h
source3/smbd/proto.h
source3/smbd/server.c
source3/smbd/server_exit.c
source3/torture/vfstest.c

index 78a101c2a78d7fbb336f51fbdce80b7cddb5d283..d5ad5779753d0be4f6f565b8c56c3310723e3394 100644 (file)
@@ -98,3 +98,19 @@ void unbecome_root(void)
        }
        return;
 }
+
+void exit_server(const char *reason)
+{
+       if (shim.exit_server) {
+               shim.exit_server(reason);
+       }
+       exit(1);
+}
+
+void exit_server_cleanly(const char *const reason)
+{
+       if (shim.exit_server_cleanly) {
+               shim.exit_server_cleanly(reason);
+       }
+       exit(0);
+}
index a51decc28c49c7658eadc6a3a78b137f80f3eab4..1645837f36ed62311a067e1bdbb28ea503ad309a 100644 (file)
@@ -46,6 +46,10 @@ struct smbd_shim
        void (*become_root)(void);
 
        void (*unbecome_root)(void);
+
+       void (*exit_server)(const char *const explanation) _NORETURN_;
+
+       void (*exit_server_cleanly)(const char *const explanation) _NORETURN_;
 };
 
 void set_smbd_shim(const struct smbd_shim *shim_functions);
index 1b3c23227d25d2ae1a928646156522e3f5376a41..a01629aaea83f1b198a8b41ac609c71dd26392e9 100644 (file)
@@ -963,11 +963,14 @@ void delete_and_reload_printers(struct tevent_context *ev,
 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);
 NTSTATUS messaging_send_to_children(struct messaging_context *msg_ctx,
                                    uint32_t msg_type, DATA_BLOB* data);
 
+/* The following definitions come from smbd/server_exit.c  */
+
+void smbd_exit_server(const char *reason) _NORETURN_;
+void smbd_exit_server_cleanly(const char *const reason) _NORETURN_;
+
 /* The following definitions come from smbd/service.c  */
 
 bool set_conn_connectpath(connection_struct *conn, const char *connectpath);
index d34ee4cbf25858a7db15513fcb297582e6fe1bc3..8eb3d9ef9330de1bbb299c5d29dcb56f3160d8fd 100644 (file)
@@ -1065,6 +1065,9 @@ extern void build_options(bool screen);
 
                .become_root = smbd_become_root,
                .unbecome_root = smbd_unbecome_root,
+
+               .exit_server = smbd_exit_server,
+               .exit_server_cleanly = smbd_exit_server_cleanly,
        };
 
        /*
index 517d4c27da6994f15b4e91b637e57a1f6b48f5f6..fa28374ba05011348ea1bbc69334ba8c5414d79c 100644 (file)
@@ -225,12 +225,12 @@ static void exit_server_common(enum server_exit_reason how,
        exit(0);
 }
 
-void exit_server(const char *const explanation)
+void smbd_exit_server(const char *const explanation)
 {
        exit_server_common(SERVER_EXIT_ABNORMAL, explanation);
 }
 
-void exit_server_cleanly(const char *const explanation)
+void smbd_exit_server_cleanly(const char *const explanation)
 {
        exit_server_common(SERVER_EXIT_NORMAL, explanation);
 }
index 3b474597e9d2f64fc87eb906ded3c26ef6dbc945..72156a5752bab08f85eebf096799dcafb079ce41 100644 (file)
@@ -33,6 +33,7 @@
 #include "serverid.h"
 #include "messages.h"
 #include "libcli/security/security.h"
+#include "lib/smbd_shim.h"
 
 /* List to hold groups of commands */
 static struct cmd_list {
@@ -405,15 +406,15 @@ static void process_file(struct vfs_state *pvfs, char *filename) {
        }
 }
 
-void exit_server(const char *reason)
+static void vfstest_exit_server(const char * const reason)
 {
        DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
        exit(0);
 }
 
-void exit_server_cleanly(const char *const reason)
+static void vfstest_exit_server_cleanly(const char * const reason)
 {
-       exit_server("normal exit");
+       vfstest_exit_server("normal exit");
 }
 
 struct smb_request *vfstest_get_smbreq(TALLOC_CTX *mem_ctx,
@@ -464,6 +465,11 @@ int main(int argc, char *argv[])
                POPT_COMMON_SAMBA
                POPT_TABLEEND
        };
+       static const struct smbd_shim vfstest_shim_fns =
+       {
+               .exit_server = vfstest_exit_server,
+               .exit_server_cleanly = vfstest_exit_server_cleanly,
+       };
 
        load_case_tables();
 
@@ -486,6 +492,8 @@ int main(int argc, char *argv[])
           facilities.  See lib/debug.c */
        setup_logging("vfstest", DEBUG_STDOUT);
 
+       set_smbd_shim(&vfstest_shim_fns);
+
        /* Load command lists */
 
        cmd_set = vfstest_command_list;