s4:dsdb/common: add samdb_domain_guid() helper function
[samba.git] / file_server / file_server.c
index 5d44d5a85cabf455a33e4da2f2f32beee4cdd8b8..1b6a01b0b565d94e334f4d8e665bbbd3c07a4691 100644 (file)
@@ -26,8 +26,8 @@
 #include "lib/param/param.h"
 #include "source4/smbd/service.h"
 #include "source4/smbd/process_model.h"
-#include "file_server/file_server.h"
 #include "dynconfig.h"
+#include "nsswitch/winbind_client.h"
 
 /*
   called if smbd exits
@@ -64,6 +64,8 @@ static void s3fs_task_init(struct task_server *task)
        smbd_path = talloc_asprintf(task, "%s/smbd", dyn_SBINDIR);
        smbd_cmd[0] = smbd_path;
 
+       /* the child should be able to call through nss_winbind */
+       (void)winbind_on();
        /* start it as a child process */
        subreq = samba_runcmd_send(task, task->event_ctx, timeval_zero(), 1, 0,
                                smbd_cmd,
@@ -72,6 +74,12 @@ static void s3fs_task_init(struct task_server *task)
                                "--foreground",
                                debug_get_output_is_stdout()?"--log-stdout":NULL,
                                NULL);
+       /* the parent should not be able to call through nss_winbind */
+       if (!winbind_off()) {
+               DEBUG(0,("Failed to re-disable recursive winbindd calls after forking smbd\n"));
+               task_server_terminate(task, "Failed to re-disable recursive winbindd calls", true);
+               return;
+       }
        if (subreq == NULL) {
                DEBUG(0, ("Failed to start smbd as child daemon\n"));
                task_server_terminate(task, "Failed to startup s3fs smb task", true);
@@ -84,9 +92,13 @@ static void s3fs_task_init(struct task_server *task)
 }
 
 /* called at smbd startup - register ourselves as a server service */
-NTSTATUS server_service_s3fs_init(void);
+NTSTATUS server_service_s3fs_init(TALLOC_CTX *);
 
-NTSTATUS server_service_s3fs_init(void)
+NTSTATUS server_service_s3fs_init(TALLOC_CTX *ctx)
 {
-       return register_server_service("s3fs", s3fs_task_init);
+       struct service_details details = {
+               .inhibit_fork_on_accept = true,
+               .inhibit_pre_fork = true
+       };
+       return register_server_service(ctx, "s3fs", s3fs_task_init, &details);
 }