s3: Make winbindd_reinit_after_fork return NTSTATUS
authorVolker Lendecke <vl@samba.org>
Fri, 29 Apr 2011 10:53:13 +0000 (12:53 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 29 Apr 2011 14:57:37 +0000 (16:57 +0200)
source3/winbindd/winbindd.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_proto.h

index 232f9b4c60f928ee35bd8262c01c2cef7c476f88..071b3ccdc945721508c426a49e6166a04fd85831 100644 (file)
@@ -378,6 +378,7 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
 {
        uint8 ret;
        pid_t child_pid;
+       NTSTATUS status;
 
        DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache "
                   "message.\n"));
@@ -404,7 +405,10 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
 
        /* child */
 
-       if (!winbindd_reinit_after_fork(NULL, NULL)) {
+       status = winbindd_reinit_after_fork(NULL, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+                         nt_errstr(status)));
                _exit(0);
        }
 
index f065d839950ed2c6a8ca4065b0fc02c32c37570e..d9fca5f5dcedc849e07c661da5bb6ef86e28978c 100644 (file)
@@ -189,6 +189,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
        TALLOC_CTX *mem_ctx = NULL;
        pid_t parent_pid = sys_getpid();
        char *lfile = NULL;
+       NTSTATUS status;
 
        if (domain->dc_probe_pid != (pid_t)-1) {
                /*
@@ -233,7 +234,10 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
                }
        }
 
-       if (!winbindd_reinit_after_fork(NULL, lfile)) {
+       status = winbindd_reinit_after_fork(NULL, lfile);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+                         nt_errstr(status)));
                messaging_send_buf(winbind_messaging_context(),
                                   pid_to_procid(parent_pid),
                                   MSG_WINBIND_FAILED_TO_GO_ONLINE,
index 47ab6c17b707991f5e43236ba9c9f3e2c3338470..8df6708778bf62346e7710d425c9824685fb628a 100644 (file)
@@ -1167,8 +1167,8 @@ static void child_msg_dump_event_list(struct messaging_context *msg,
        dump_event_list(winbind_event_context());
 }
 
-bool winbindd_reinit_after_fork(const struct winbindd_child *myself,
-                               const char *logfilename)
+NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
+                                   const char *logfilename)
 {
        struct winbindd_domain *domain;
        struct winbindd_child *cl;
@@ -1181,7 +1181,7 @@ bool winbindd_reinit_after_fork(const struct winbindd_child *myself,
                true);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
-               return false;
+               return status;
        }
 
        close_conns_after_fork();
@@ -1192,10 +1192,10 @@ bool winbindd_reinit_after_fork(const struct winbindd_child *myself,
        }
 
        if (!winbindd_setup_sig_term_handler(false))
-               return false;
+               return NT_STATUS_NO_MEMORY;
        if (!winbindd_setup_sig_hup_handler(override_logfile ? NULL :
                                            logfilename))
-               return false;
+               return NT_STATUS_NO_MEMORY;
 
        /* Stop zombies in children */
        CatchChild();
@@ -1271,7 +1271,7 @@ bool winbindd_reinit_after_fork(const struct winbindd_child *myself,
        cl = idmap_child();
        cl->pid = (pid_t)0;
 
-       return true;
+       return NT_STATUS_OK;
 }
 
 /*
@@ -1291,6 +1291,7 @@ static bool fork_domain_child(struct winbindd_child *child)
        struct winbindd_request request;
        struct winbindd_response response;
        struct winbindd_domain *primary_domain = NULL;
+       NTSTATUS status;
 
        if (child->domain) {
                DEBUG(10, ("fork_domain_child called for domain '%s'\n",
@@ -1334,7 +1335,10 @@ static bool fork_domain_child(struct winbindd_child *child)
        state.sock = fdpair[0];
        close(fdpair[1]);
 
-       if (!winbindd_reinit_after_fork(child, child->logfilename)) {
+       status = winbindd_reinit_after_fork(child, child->logfilename);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+                         nt_errstr(status)));
                _exit(0);
        }
 
@@ -1434,7 +1438,6 @@ static bool fork_domain_child(struct winbindd_child *child)
                TALLOC_CTX *frame = talloc_stackframe();
                struct iovec iov[2];
                int iov_count;
-               NTSTATUS status;
 
                if (run_events_poll(winbind_event_context(), 0, NULL, 0)) {
                        TALLOC_FREE(frame);
index 725bf6f8a7004efe134b8d5f29d4faec6a48944f..d0619f6e094bdb1aa7865b45729ad2d9dd1b946f 100644 (file)
@@ -291,8 +291,8 @@ void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
                                   uint32_t msg_type,
                                   struct server_id server_id,
                                   DATA_BLOB *data);
-bool winbindd_reinit_after_fork(const struct winbindd_child *myself,
-                               const char *logfilename);
+NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
+                                   const char *logfilename);
 struct winbindd_domain *wb_child_domain(void);
 
 /* The following definitions come from winbindd/winbindd_group.c  */