The branch, master has been updated
       via  c299833bf8e6506c793d6e8283743949aaac9ef4 (commit)
       via  a4887e250b84c321c75d54b9d3adf6fcf7c27fed (commit)
       via  75de7c0e87cc5ecea1a7d7e9b0103a8cc2827895 (commit)
      from  3fe9859342c28fe9da7011fb18a5fb5de8b29fa6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c299833bf8e6506c793d6e8283743949aaac9ef4
Author: Tim Prouty <[email protected]>
Date:   Wed May 27 12:52:37 2009 -0700

    tdb: Fix some recently introduced warnings in tdbtool

commit a4887e250b84c321c75d54b9d3adf6fcf7c27fed
Author: Marc VanHeyningen <[email protected]>
Date:   Tue May 5 21:18:50 2009 +0000

    s3: Allow child processes to exit gracefully if we are out of fds
    
    When we run out of file descriptors for some reason, every new
    connection forks a child that immediately panics causing smbd to
    coredump.  This seems unnecessarily harsh; with this code change we
    now catch that error and merely log a message about it and exit
    without the core dump.
    
    Signed-off-by: Tim Prouty <[email protected]>

commit 75de7c0e87cc5ecea1a7d7e9b0103a8cc2827895
Author: Marc VanHeyningen <[email protected]>
Date:   Tue May 5 22:07:40 2009 +0000

    s3: zero an uninitialized array
    
    Invalid pointers were being dereferenced in lookup_sids causing
    occasional seg faults.
    
    Signed-off-by: Tim Prouty <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/tools/tdbtool.c          |   12 ++++++------
 source3/include/proto.h          |    2 +-
 source3/lib/util.c               |   12 ++++++------
 source3/nmbd/asyncdns.c          |    4 ++--
 source3/nmbd/nmbd.c              |    4 ++--
 source3/passdb/lookup_sid.c      |    5 ++++-
 source3/printing/print_cups.c    |    4 ++--
 source3/printing/printing.c      |    5 +++--
 source3/smbd/server.c            |   19 +++++++++++++------
 source3/winbindd/winbindd.c      |    5 +++--
 source3/winbindd/winbindd_dual.c |    5 +++--
 11 files changed, 45 insertions(+), 32 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index 3220e47..c0814e1 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -401,8 +401,8 @@ static void speed_tdb(const char *tlimit)
        do {
                long int r = random();
                TDB_DATA key, dbuf;
-               key.dptr = "store test";
-               key.dsize = strlen(key.dptr);
+               key.dptr = (unsigned char *)"store test";
+               key.dsize = strlen((char *)key.dptr);
                dbuf.dptr = (unsigned char *)&r;
                dbuf.dsize = sizeof(r);
                tdb_store(tdb, key, dbuf, TDB_REPLACE);
@@ -417,8 +417,8 @@ static void speed_tdb(const char *tlimit)
        do {
                long int r = random();
                TDB_DATA key, dbuf;
-               key.dptr = "store test";
-               key.dsize = strlen(key.dptr);
+               key.dptr = (unsigned char *)"store test";
+               key.dsize = strlen((char *)key.dptr);
                dbuf.dptr = (unsigned char *)&r;
                dbuf.dsize = sizeof(r);
                tdb_fetch(tdb, key);
@@ -433,8 +433,8 @@ static void speed_tdb(const char *tlimit)
        do {
                long int r = random();
                TDB_DATA key, dbuf;
-               key.dptr = "transaction test";
-               key.dsize = strlen(key.dptr);
+               key.dptr = (unsigned char *)"transaction test";
+               key.dsize = strlen((char *)key.dptr);
                dbuf.dptr = (unsigned char *)&r;
                dbuf.dsize = sizeof(r);
                tdb_transaction_start(tdb);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c78d2c8..717a972 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1106,7 +1106,7 @@ char *clean_name(TALLOC_CTX *ctx, const char *s);
 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T 
pos);
 int set_blocking(int fd, bool set);
 void smb_msleep(unsigned int t);
-bool reinit_after_fork(struct messaging_context *msg_ctx,
+NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                       struct event_context *ev_ctx,
                       bool parent_longlived);
 bool yesno(const char *p);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 13f7e3c..8e67ede 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -927,11 +927,11 @@ void smb_msleep(unsigned int t)
 #endif
 }
 
-bool reinit_after_fork(struct messaging_context *msg_ctx,
+NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                       struct event_context *ev_ctx,
                       bool parent_longlived)
 {
-       NTSTATUS status;
+       NTSTATUS status = NT_STATUS_OK;
 
        /* Reset the state of the random
         * number generation system, so
@@ -942,7 +942,8 @@ bool reinit_after_fork(struct messaging_context *msg_ctx,
        /* tdb needs special fork handling */
        if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
                DEBUG(0,("tdb_reopen_all failed.\n"));
-               return false;
+               status = NT_STATUS_OPEN_FAILED;
+               goto done;
        }
 
        if (ev_ctx) {
@@ -958,11 +959,10 @@ bool reinit_after_fork(struct messaging_context *msg_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("messaging_reinit() failed: %s\n",
                                 nt_errstr(status)));
-                       return false;
                }
        }
-
-       return true;
+ done:
+       return status;
 }
 
 /****************************************************************************
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index 0736a66..85729ae 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -164,8 +164,8 @@ void start_async_dns(void)
        CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, SIGNAL_CAST sig_term );
 
-       if (!reinit_after_fork(nmbd_messaging_context(),
-                              nmbd_event_context(), true)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(),
+                                              nmbd_event_context(), true))) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                smb_panic("reinit_after_fork() failed");
        }
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index daf4c29..903dc36 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -913,8 +913,8 @@ static bool open_sockets(bool isdaemon, int port)
 
        pidfile_create("nmbd");
 
-       if (!reinit_after_fork(nmbd_messaging_context(),
-                              nmbd_event_context(), false)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(),
+                                              nmbd_event_context(), false))) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index b45000e..3a03cfe 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -468,12 +468,15 @@ static bool lookup_rids(TALLOC_CTX *mem_ctx, const 
DOM_SID *domain_sid,
                   sid_string_dbg(domain_sid)));
 
        if (num_rids) {
-               *names = TALLOC_ARRAY(mem_ctx, const char *, num_rids);
+               *names = TALLOC_ZERO_ARRAY(mem_ctx, const char *, num_rids);
                *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids);
 
                if ((*names == NULL) || (*types == NULL)) {
                        return false;
                }
+
+               for (i = 0; i < num_rids; i++)
+                       (*types)[i] = SID_NAME_UNKNOWN;
        } else {
                *names = NULL;
                *types = NULL;
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 7edfb5e..18f4213 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -433,8 +433,8 @@ static bool cups_pcap_load_async(int *pfd)
 
        close_all_print_db();
 
-       if (!reinit_after_fork(smbd_messaging_context(),
-                              smbd_event_context(), true)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
+                                              smbd_event_context(), true))) {
                DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n"));
                smb_panic("cups_pcap_load_async: reinit_after_fork() failed");
        }
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 3f337d0..e73669f 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1436,8 +1436,9 @@ void start_background_queue(void)
                close(pause_pipe[0]);
                pause_pipe[0] = -1;
 
-               if (!reinit_after_fork(smbd_messaging_context(),
-                                      smbd_event_context(), true)) {
+               if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
+                                                      smbd_event_context(),
+                                                      true))) {
                        DEBUG(0,("reinit_after_fork() failed\n"));
                        smb_panic("reinit_after_fork() failed");
                }
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 67836f7..685b26f 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -356,6 +356,7 @@ static void smbd_accept_connection(struct tevent_context 
*ev,
 
        pid = sys_fork();
        if (pid == 0) {
+               NTSTATUS status = NT_STATUS_OK;
                /* Child code ... */
                am_parent = 0;
 
@@ -374,10 +375,15 @@ static void smbd_accept_connection(struct tevent_context 
*ev,
                talloc_free(s->parent);
                s = NULL;
 
-               if (!reinit_after_fork(
-                           smbd_messaging_context(),
-                           smbd_event_context(),
-                           true)) {
+               status = reinit_after_fork(smbd_messaging_context(),
+                                          smbd_event_context(), true);
+               if (!NT_STATUS_IS_OK(status)) {
+                       if (NT_STATUS_EQUAL(status,
+                                           NT_STATUS_TOO_MANY_OPENED_FILES)) {
+                               DEBUG(0,("child process cannot initialize "
+                                        "because too many files are open\n"));
+                               goto exit;
+                       }
                        DEBUG(0,("reinit_after_fork() failed\n"));
                        smb_panic("reinit_after_fork() failed");
                }
@@ -386,6 +392,7 @@ static void smbd_accept_connection(struct tevent_context 
*ev,
                smbd_setup_sig_hup_handler();
 
                smbd_process();
+        exit:
                exit_server_cleanly("end of child");
                return;
        } else if (pid < 0) {
@@ -1122,8 +1129,8 @@ extern void build_options(bool screen);
        if (is_daemon)
                pidfile_create("smbd");
 
-       if (!reinit_after_fork(smbd_messaging_context(),
-                              smbd_event_context(), false)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
+                            smbd_event_context(), false))) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index e1ce223..2b25616 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1304,8 +1304,9 @@ int main(int argc, char **argv, char **envp)
         * winbindd-specific resources we must free yet. JRA.
         */
 
-       if (!reinit_after_fork(winbind_messaging_context(),
-                              winbind_event_context(), false)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(),
+                                              winbind_event_context(),
+                                              false))) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                exit(1);
        }
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index a69d34f..6fb0b58 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1121,8 +1121,9 @@ bool winbindd_reinit_after_fork(const char *logfilename)
        struct winbindd_domain *domain;
        struct winbindd_child *cl;
 
-       if (!reinit_after_fork(winbind_messaging_context(),
-                              winbind_event_context(), true)) {
+       if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(),
+                                              winbind_event_context(),
+                                              true))) {
                DEBUG(0,("reinit_after_fork() failed\n"));
                return false;
        }


-- 
Samba Shared Repository

Reply via email to