[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-1-29-gb4c445f

Karolin Seeger kseeger at samba.org
Wed Aug 13 14:41:53 GMT 2008


The branch, v3-2-stable has been updated
       via  b4c445fd2439df65839049371d9e9ed6373b9cd7 (commit)
       via  b8942e2d1f4160dfaa519a21a49c056ae84378bf (commit)
       via  ba0b188abb3f680ee0686f53a903d25fe363d83e (commit)
       via  377017b3a14140a8a74623c2fdf00299de441317 (commit)
       via  40dc7e9a38e6c5f9c551625a7553fb0c9eb1d867 (commit)
       via  6a658505d697c350cba7d417534f11784ac3100c (commit)
       via  5a695336462f5a21debdd20b2346c712adbfae6e (commit)
       via  9fcc15e0307ec1621482101b5730de1a635a191d (commit)
      from  9936dd1f611c275a38b9e5148bc6bf383bc306c0 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit b4c445fd2439df65839049371d9e9ed6373b9cd7
Author: Karolin Seeger <kseeger at samba.org>
Date:   Wed Aug 13 16:38:18 2008 +0200

    WHATSNEW: Update changes since 3.2.1.
    
    Karolin
    (cherry picked from commit f03ffcb78e4ea8a8bd4a5fa0d26642544314a5e4)

commit b8942e2d1f4160dfaa519a21a49c056ae84378bf
Author: Günther Deschner <gd at samba.org>
Date:   Tue Aug 12 19:38:22 2008 +0200

    netapi: add c++ guard.
    
    Guenther
    (cherry picked from commit 5ea69915a75447d9f66b651ef5601c0a7ac6cfbb)

commit ba0b188abb3f680ee0686f53a903d25fe363d83e
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 12 22:31:52 2008 +0200

    Attempt to fix bug 5684
    
    With the ctdb checkin dde9f3f006 tdb optimized out write lock checks for
    write-enabled transaction. Sadly, this also removed the possibility to ever
    remove dead records left over from tdb_delete calls within a transaction.
    
    Tridge, please check this! Did dde9f3f006 have any reason beyond performance
    optimizations?
    
    Thanks,
    
    Volker
    (cherry picked from commit 96d683d3ec1e95cddf9ec96326ebaf8e9cc2079c)

commit 377017b3a14140a8a74623c2fdf00299de441317
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Aug 10 10:43:36 2008 +1000

    I found lots of places where we assume error will be set when calling
    one of our virtualised functions, such as db_open(), but error is only
    set when a system call fails, and it is not uncommon for us to fail a
    function internally without ever making a system call. That led to us
    passing back success when a function had in fact failed.
    
    I found two places where we relied on map_nt_error_from_unix()
    returning success when errno==0, but lots and lots of places where we
    relied on the reverse, so I fixed those two places.
    
    map_nt_error_from_unix() will now always return an error, returning
    NT_STATUS_UNSUCCESSFUL if errno is 0
    (cherry picked from commit 69d40ca4c1af925d4b0e59ddc69ef8c26e6501d1)
    (cherry picked from commit 8c66020a82d9b92fb10d14359b1381d58ad4972b)

commit 40dc7e9a38e6c5f9c551625a7553fb0c9eb1d867
Author: Michael Adam <obnox at samba.org>
Date:   Tue Aug 12 14:59:59 2008 +0200

    Fix unix_convert() for "*" after changing map_nt_error_from_unix().
    
    map_nt_error_from_unix() now assumes that it is called in
    an error path and returns an error even for a given errno == 0.
    The original behaviour of unix_convert() used the mapping
    of errno == 0 ==> NT_STATUS_OK to return success through
    an error path.
    
    I think this must have been an oversight, and unix_convert() worked
    only by coincidence (or because explicitly using the knowledge
    of the conceptually wrong working of map_nt_error_from_unix().
    
    This patch puts this straight by not interpreting errno == 0
    as an error condition and proceeding in that case.
    
    Jeremy - please check!
    
    Michael
    (cherry picked from commit 736bdf15d934028b579a02dc411aed6c14a437f3)

commit 6a658505d697c350cba7d417534f11784ac3100c
Author: Michael Adam <obnox at samba.org>
Date:   Tue Aug 12 15:19:17 2008 +0200

    Make sure to always set errno on error path in OpenDir (and hence scan_directory).
    
    Michael
    (cherry picked from commit 06304f3c5f538c75bfc63c7abc1457d2b4dc0f0b)

commit 5a695336462f5a21debdd20b2346c712adbfae6e
Author: Herb Lewis <herb at samba.org>
Date:   Tue Aug 12 13:38:51 2008 -0700

    print correct test status
    (cherry picked from commit ccd413b8b10c99f18b6369717116765c3397edfb)

commit 9fcc15e0307ec1621482101b5730de1a635a191d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 12 13:34:00 2008 -0700

    Fix bug 5686 - libsmbclient segfaults with more than one SMBCCTX.
    Here is a patch to allow many subsystems to be re-initialized. The only
    functional change I made was to remove the null context tracking, as the memory
    allocated here is designed to be left for the complete lifetime of the program.
    Freeing this early (when all smb contexts are destroyed) could crash other
    users of talloc.
    Jeremy.
    (cherry picked from commit 4779f1efccc8364fd8b3ba446aa96ba0bddec689)

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

Summary of changes:
 WHATSNEW.txt                    |   19 ++++++++++++++++++-
 examples/libsmbclient/Makefile  |    4 ++++
 examples/libsmbclient/testctx.c |   17 +++++++++++++++++
 source/lib/charcnv.c            |    6 +++---
 source/lib/debug.c              |   23 +++++++++++++++++------
 source/lib/errmap_unix.c        |   12 ++++++++++--
 source/lib/netapi/netapi.h      |   10 +++++++++-
 source/lib/tdb/common/tdb.c     |    2 +-
 source/lib/util.c               |    5 +----
 source/lib/util_unistr.c        |    7 ++++---
 source/libsmb/libsmb_context.c  |   38 ++++++++++++++++----------------------
 source/param/loadparm.c         |    1 +
 source/smbd/dir.c               |    1 +
 source/smbd/filename.c          |    2 +-
 source/smbd/reply.c             |    4 ++--
 source/torture/torture.c        |    2 +-
 16 files changed, 106 insertions(+), 47 deletions(-)
 create mode 100644 examples/libsmbclient/testctx.c


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 163f7e2..a10605a 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -7,7 +7,9 @@ This is the third stable release of Samba 3.2.
 
 Major bug fixes included in Samba 3.2.2 are:
 
-  o
+  o Fix removal of dead records in tdb files. This can lead to very large
+    tdb files and to overflowing partitions as a consequence on systems
+    running an nmbd daemon.
 
 
 ######################################################################
@@ -21,11 +23,14 @@ Changes since 3.2.1
 o   Michael Adam <obnox at samba.org>
     * Fix replacement of random seed generator.
     * Fix a race condition in idmap_tdb2_allocate_id().
+    * Fix unix_convert() for "*" after changing map_nt_error_from_unix().
+    * Make sure to always set errno on error path in OpenDir.
 
 
 o   Jeremy Allison <jra at samba.org>
     * BUG 5675: Fix smbspool program assuming Kerberos authentication by
       mistake.
+    * BUG 5686: Fix segfaults in libsmbclient.
     * Several build fixes.
 
 
@@ -40,14 +45,26 @@ o   Yannick Bergeron <yaberger at ca.ibm.com>
       rep_initgroups().
 
 
+o   Günther Deschner <gd at samba.org>
+    * Fix build warning.
+    * Add add c++ guard to netapi.
+
+
 o   Volker Lendecke <vl at samba.org>
+    * BUG 5684: Fix removal of dead records in tdb files.
     * Fix smb_len calculation for chained requests.
 
 
+o   Herb Lewis <herb at samba.org>
+    * Fix output of test status.
+
+
 o   Andrew Tridgell <tridge at samba.org>
     * Fix a fd leak when trying to regain contact to a domain controller
       in Winbind.
     * Fix permissions on ctdb databases.
+    * Fix passing back success when a function had in fact failed in two
+      places.
 
 
 ######################################################################
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index dabc8e9..e6afdeb 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -94,6 +94,10 @@ testwrite: testwrite.o
 	@echo Linking testwrite
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
 
+testctx: testctx.o
+	@echo Linking testctx
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
 smbsh:
 	make -C smbwrapper
 
diff --git a/examples/libsmbclient/testctx.c b/examples/libsmbclient/testctx.c
new file mode 100644
index 0000000..8820bc8
--- /dev/null
+++ b/examples/libsmbclient/testctx.c
@@ -0,0 +1,17 @@
+#include <libsmbclient.h>
+
+void create_and_destroy_context (void)
+{
+  SMBCCTX *ctx;
+  ctx = smbc_new_context ();
+  smbc_init_context (ctx);
+
+  smbc_free_context (ctx, 1);
+}
+
+int main (int argc, char **argv)
+{
+  create_and_destroy_context ();
+  create_and_destroy_context ();
+  return 0;
+}
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index 81b7238..cea234f 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -47,6 +47,7 @@ char lp_failed_convert_char(void)
 
 static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
 static bool conv_silent; /* Should we do a debug if the conversion fails ? */
+static bool initialized;
 
 /**
  * Return the name of a charset to give to iconv().
@@ -92,12 +93,10 @@ static const char *charset_name(charset_t ch)
 
 void lazy_initialize_conv(void)
 {
-	static int initialized = False;
-
 	if (!initialized) {
-		initialized = True;
 		load_case_tables();
 		init_iconv();
+		initialized = true;
 	}
 }
 
@@ -116,6 +115,7 @@ void gfree_charcnv(void)
 			}
 		}
 	}
+	initialized = false;
 }
 
 /**
diff --git a/source/lib/debug.c b/source/lib/debug.c
index 2ded6bd..d835ea7 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -94,7 +94,7 @@ static TALLOC_CTX *tmp_debug_ctx;
 
 /*
  * This is to allow assignment to DEBUGLEVEL before the debug
- * system has been initialised.
+ * system has been initialized.
  */
 static int debug_all_class_hack = 1;
 static bool debug_all_class_isset_hack = True;
@@ -183,6 +183,8 @@ static char **classname_table = NULL;
  Free memory pointed to by global pointers.
 ****************************************************************************/
 
+static bool initialized;
+
 void gfree_debugsyms(void)
 {
 	int i;
@@ -194,13 +196,23 @@ void gfree_debugsyms(void)
 		SAFE_FREE( classname_table );
 	}
 
-	if ( DEBUGLEVEL_CLASS != &debug_all_class_hack )
+	if ( DEBUGLEVEL_CLASS != &debug_all_class_hack ) {
 		SAFE_FREE( DEBUGLEVEL_CLASS );
+		DEBUGLEVEL_CLASS = &debug_all_class_hack;
+	}
 
-	if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack )
+	if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack ) {
 		SAFE_FREE( DEBUGLEVEL_CLASS_ISSET );
+		DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack;
+	}
 
 	SAFE_FREE(format_bufr);
+
+	debug_num_classes = 0;
+
+	debug_level = DEBUGLEVEL_CLASS;
+
+	initialized = false;
 }
 
 /****************************************************************************
@@ -530,13 +542,12 @@ Init debugging (one time stuff)
 
 void debug_init(void)
 {
-	static bool initialised = False;
 	const char **p;
 
-	if (initialised)
+	if (initialized)
 		return;
 
-	initialised = True;
+	initialized = true;
 
 	for(p = default_classname_table; *p; p++) {
 		debug_add_class(*p);
diff --git a/source/lib/errmap_unix.c b/source/lib/errmap_unix.c
index 8194cf8..2cd2386 100644
--- a/source/lib/errmap_unix.c
+++ b/source/lib/errmap_unix.c
@@ -107,8 +107,16 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
 {
 	int i = 0;
 
-	if (unix_error == 0)
-		return NT_STATUS_OK;
+	if (unix_error == 0) {
+		/* we map this to an error, not success, as this
+		   function is only called in an error path. Lots of
+		   our virtualised functions may fail without making a
+		   unix system call that fails (such as when they are
+		   checking for some handle existing), so unix_error
+		   may be unset
+		*/
+		return NT_STATUS_UNSUCCESSFUL;
+	}
 
 	/* Look through list */
 	while(unix_dos_nt_errmap[i].unix_error != 0) {
diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h
index e9fcc37..ce97e4c 100644
--- a/source/lib/netapi/netapi.h
+++ b/source/lib/netapi/netapi.h
@@ -20,6 +20,10 @@
 #ifndef __LIB_NETAPI_H__
 #define __LIB_NETAPI_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 /****************************************************************
  NET_API_STATUS
 ****************************************************************/
@@ -459,4 +463,8 @@ NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [uniq
 					  uint32_t *entries_read /* [out] [ref] */,
 					  void **buffer /* [out] [noprint,ref] */);
 
-#endif
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LIB_NETAPI_H__ */
diff --git a/source/lib/tdb/common/tdb.c b/source/lib/tdb/common/tdb.c
index 767452c..c7cec29 100644
--- a/source/lib/tdb/common/tdb.c
+++ b/source/lib/tdb/common/tdb.c
@@ -243,7 +243,7 @@ int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct
 
 	if (tdb->read_only || tdb->traverse_read) return -1;
 
-	if (tdb->traverse_write != 0 || 
+	if (((tdb->traverse_write != 0) && (!TDB_DEAD(rec))) ||
 	    tdb_write_lock_record(tdb, rec_ptr) == -1) {
 		/* Someone traversing here: mark it as dead */
 		rec->magic = TDB_DEAD_MAGIC;
diff --git a/source/lib/util.c b/source/lib/util.c
index 0a32f0f..dafaf03 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -191,12 +191,9 @@ void gfree_all( void )
 	gfree_names();
 	gfree_loadparm();
 	gfree_case_tables();
-	gfree_debugsyms();
 	gfree_charcnv();
 	gfree_interfaces();
-
-	/* release the talloc null_context memory last */
-	talloc_disable_null_tracking();
+	gfree_debugsyms();
 }
 
 const char *my_netbios_names(int i)
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index 84ee673..5b769df 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -33,6 +33,7 @@ static uint8 *valid_table;
 static bool upcase_table_use_unmap;
 static bool lowcase_table_use_unmap;
 static bool valid_table_use_unmap;
+static bool initialized;
 
 /**
  * Destroy global objects allocated by load_case_tables()
@@ -59,6 +60,7 @@ void gfree_case_tables(void)
 		else
 			SAFE_FREE(valid_table);
 	}
+	initialized = false;
 }
 
 /**
@@ -70,15 +72,14 @@ void gfree_case_tables(void)
 
 void load_case_tables(void)
 {
-	static int initialised;
 	char *old_locale = NULL, *saved_locale = NULL;
 	int i;
 	TALLOC_CTX *frame = NULL;
 
-	if (initialised) {
+	if (initialized) {
 		return;
 	}
-	initialised = 1;
+	initialized = true;
 
 	frame = talloc_stackframe();
 
diff --git a/source/libsmb/libsmb_context.c b/source/libsmb/libsmb_context.c
index 85de44e..5e075d1 100644
--- a/source/libsmb/libsmb_context.c
+++ b/source/libsmb/libsmb_context.c
@@ -30,9 +30,8 @@
 /*
  * Is the logging working / configfile read ? 
  */
-static int SMBC_initialized = 0;
-
-
+static bool SMBC_initialized;
+static unsigned int initialized_ctx_count;
 
 /*
  * Get a new empty handle to fill in with your own info
@@ -201,22 +200,19 @@ smbc_free_context(SMBCCTX *context,
         
         DEBUG(3, ("Context %p successfully freed\n", context));
 
-	gfree_names();
-	gfree_loadparm();
-	gfree_case_tables();
-	gfree_charcnv();
-	gfree_interfaces();
-
-	gencache_shutdown();
-	secrets_shutdown();
-
-	/* release the talloc null_context memory last */
-	talloc_disable_null_tracking();
+	SAFE_FREE(context->internal);
+        SAFE_FREE(context);
 
-	gfree_debugsyms();
+	if (initialized_ctx_count) {
+		initialized_ctx_count--;
+	}
 
-        SAFE_FREE(context->internal);
-        SAFE_FREE(context);
+	if (initialized_ctx_count == 0 && SMBC_initialized) {
+		gencache_shutdown();
+		secrets_shutdown();
+		gfree_all();
+		SMBC_initialized = false;
+	}
         return 0;
 }
 
@@ -427,9 +423,6 @@ smbc_init_context(SMBCCTX *context)
         char *user = NULL;
         char *home = NULL;
         
-        /* track talloc null_context memory */
-        talloc_enable_null_tracking();
-
         if (!context) {
                 errno = EBADF;
                 return NULL;
@@ -527,7 +520,7 @@ smbc_init_context(SMBCCTX *context)
                 BlockSignals(True, SIGPIPE);
                 
                 /* Done with one-time initialisation */
-                SMBC_initialized = 1;
+                SMBC_initialized = true;
                 
                 TALLOC_FREE(frame);
         }
@@ -616,7 +609,8 @@ smbc_init_context(SMBCCTX *context)
          */
         
         context->internal->initialized = True;
-        
+	initialized_ctx_count++;
+
         return context;
 }
 
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 14939fb..c894b7f 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -8682,6 +8682,7 @@ void gfree_loadparm(void)
 		SAFE_FREE( f );
 		f = next;
 	}
+	file_lists = NULL;
 
 	/* Free resources allocated to services */
 
diff --git a/source/smbd/dir.c b/source/smbd/dir.c
index 6e02401..604db98 100644
--- a/source/smbd/dir.c
+++ b/source/smbd/dir.c
@@ -1152,6 +1152,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
 
 	dirp->dir_path = talloc_strdup(dirp, name);
 	if (!dirp->dir_path) {
+		errno = ENOMEM;
 		goto fail;
 	}
 
diff --git a/source/smbd/filename.c b/source/smbd/filename.c
index 4323e84..41a0b92 100644
--- a/source/smbd/filename.c
+++ b/source/smbd/filename.c
@@ -477,7 +477,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 				}
 
 				/* ENOENT is the only valid error here. */
-				if (errno != ENOENT) {
+				if ((errno != 0) && (errno != ENOENT)) {
 					/*
 					 * ENOTDIR and ELOOP both map to
 					 * NT_STATUS_OBJECT_PATH_NOT_FOUND
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index ac9ccd6..ef49d58 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -2497,7 +2497,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
 		TALLOC_FREE(dir_hnd);
 	}
 
-	if (count == 0 && NT_STATUS_IS_OK(status)) {
+	if (count == 0 && NT_STATUS_IS_OK(status) && errno != 0) {
 		status = map_nt_error_from_unix(errno);
 	}
 
@@ -5880,7 +5880,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
 	}
 	TALLOC_FREE(dir_hnd);
 
-	if (count == 0 && NT_STATUS_IS_OK(status)) {
+	if (count == 0 && NT_STATUS_IS_OK(status) && errno != 0) {
 		status = map_nt_error_from_unix(errno);
 	}
 
diff --git a/source/torture/torture.c b/source/torture/torture.c
index d8add20..e909f8c 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -3685,7 +3685,7 @@ static bool run_rename(int dummy)
 	}
 
 	if (!cli_rename(cli1, fname, fname1)) {
-		printf("Fifth rename failed (SHARE_READ | SHARE_WRITE | SHARE_DELETE) - this should have failed ! \n");
+		printf("Fifth rename failed (SHARE_READ | SHARE_WRITE | SHARE_DELETE) - this should have succeeded - %s\n", cli_errstr(cli1));
 		correct = False;
 	} else {
 		printf("Fifth rename succeeded (SHARE_READ | SHARE_WRITE | SHARE_DELETE) (this is correct) - %s\n", cli_errstr(cli1));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list