[SCM] Samba Shared Repository - branch v3-6-test updated

Volker Lendecke vlendec at samba.org
Wed Feb 23 08:55:20 MST 2011


The branch, v3-6-test has been updated
       via  18e048e s3:libsmb only log a dead connection if it was not closed
       via  8cca1d3 s3: Fix 64-bit errors
       via  e953d4d s3: Fix an uninitialized variable use
       via  6d360c4 s3:idmap:autorid prevent fatal configuration changes
      from  171cc2d s3: Improve an error msg in vfs_gpfs

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


- Log -----------------------------------------------------------------
commit 18e048e04426fb24a2f5cb7ef04bb1748ae3f7bc
Author: Christian Ambach <christian.ambach at de.ibm.com>
Date:   Tue Feb 22 15:45:44 2011 +0100

    s3:libsmb only log a dead connection if it was not closed
    
    in case the cli was closed before (e.g. via a dropped ip message)
    it can be expected that the read here returns with an error and so
    we should not log that a connection is dead when it was closed before
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Wed Feb 23 16:51:03 CET 2011 on sn-devel-104
    (cherry picked from commit 051611256b043a8841c456ce34a37ef4ac806155)

commit 8cca1d3927c9d46ef5a5978efa9ce82c0a1932aa
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 23 15:26:38 2011 +0100

    s3: Fix 64-bit errors
    
    Casting those variables will lead to sscanf believing that it sees pointers to
    unsigned longs. These might be 64 bit long, thus sscanf will overwrite memory
    it should not overwrite. Assigning the vars later is okay, there we get
    automatic type conversion. C can be nasty ...
    
    Christian, please check!
    (cherry picked from commit dfd33bcbb81998e68c00d2a01aab6b5c468ecf87)

commit e953d4df99f056c2cfd6dad376ecbc731283c18d
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 23 15:25:36 2011 +0100

    s3: Fix an uninitialized variable use
    
    The "goto error;" lead to the invalid talloc_free.
    
    Christian, please check!
    (cherry picked from commit 9671615592a2e539a661698373dd3f7c7dd82d73)

commit 6d360c4e9cf6a9e5a99c415ced707e27cb217f96
Author: Christian Ambach <christian.ambach at de.ibm.com>
Date:   Wed Feb 16 19:05:21 2011 +0100

    s3:idmap:autorid prevent fatal configuration changes
    
    as the autorid module relies on a stable minimum uid/gid value
    and rangesize, it now saves the values used at first successful start
    and refuses to work if these values get changed in smb.conf later.
    Changing the values after the first mapping was done will result
    in unpredictable behaviour.
    Another check covers the maximum uid value. If this gets decreased
    later and domain range mappings already exist that would result
    in uid values higher than the new uid value, initialization will
    be aborted
    (cherry picked from commit 8283cdbb1f28517d3e25a958aede0e5a31131f90)

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

Summary of changes:
 source3/libsmb/clientgen.c       |   19 ++++--
 source3/winbindd/idmap_autorid.c |  117 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 128 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 3816419..e26c171 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -248,13 +248,18 @@ bool cli_receive_smb(struct cli_state *cli)
 
 	/* If the server is not responding, note that now */
 	if (len < 0) {
-		char addr[INET6_ADDRSTRLEN];
-
-		print_sockaddr(addr, sizeof(addr), &cli->dest_ss);
-                DEBUG(0, ("Receiving SMB: Server %s stopped responding\n",
-			  addr));
-		close(cli->fd);
-		cli->fd = -1;
+		/*
+		 * only log if the connection should still be open and not when
+		 * the connection was closed due to a dropped ip message
+		 */
+		if (cli->fd != -1) {
+			char addr[INET6_ADDRSTRLEN];
+			print_sockaddr(addr, sizeof(addr), &cli->dest_ss);
+			DEBUG(0, ("Receiving SMB: Server %s stopped responding\n",
+				addr));
+			close(cli->fd);
+			cli->fd = -1;
+		}
 		return false;
 	}
 
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 6485d78..ae65647 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -5,7 +5,7 @@
  *  based on the idmap_rid module, but this module defines the ranges
  *  for the domains by automatically allocating a range for each domain
  *
- *  Copyright (C) Christian Ambach, 2010
+ *  Copyright (C) Christian Ambach, 2010-2011
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,6 +32,8 @@
 #define DBGC_CLASS DBGC_IDMAP
 
 #define HWM "NEXT RANGE"
+#define CONFIGKEY "CONFIG"
+
 struct autorid_global_config {
 	uint32_t minvalue;
 	uint32_t rangesize;
@@ -388,11 +390,79 @@ static NTSTATUS idmap_autorid_db_init(void)
 	return NT_STATUS_OK;
 }
 
+static struct autorid_global_config *idmap_autorid_loadconfig(TALLOC_CTX * ctx)
+{
+
+	TDB_DATA data;
+	struct autorid_global_config *cfg;
+	unsigned long minvalue, rangesize, maxranges;
+
+	data = dbwrap_fetch_bystring(autorid_db, ctx, CONFIGKEY);
+
+	if (!data.dptr) {
+		DEBUG(10, ("No saved config found\n"));
+		return NULL;
+	}
+
+	cfg = TALLOC_ZERO_P(ctx, struct autorid_global_config);
+	if (!cfg) {
+		return NULL;
+	}
+
+	if (sscanf((char *)data.dptr,
+		   "minvalue:%lu rangesize:%lu maxranges:%lu",
+		   &minvalue, &rangesize, &maxranges) != 3) {
+		DEBUG(1,
+		      ("Found invalid configuration data"
+		       "creating new config\n"));
+		return NULL;
+	}
+
+	cfg->minvalue = minvalue;
+	cfg->rangesize = rangesize;
+	cfg->maxranges = maxranges;
+
+	DEBUG(10, ("Loaded previously stored configuration "
+		   "minvalue:%d rangesize:%d\n",
+		   cfg->minvalue, cfg->rangesize));
+
+	return cfg;
+
+}
+
+static NTSTATUS idmap_autorid_saveconfig(struct autorid_global_config *cfg)
+{
+
+	NTSTATUS status;
+	TDB_DATA data;
+	char *cfgstr;
+
+	cfgstr =
+	    talloc_asprintf(talloc_tos(),
+			    "minvalue:%u rangesize:%u maxranges:%u",
+			    cfg->minvalue, cfg->rangesize, cfg->maxranges);
+
+	if (!cfgstr) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	data = string_tdb_data(cfgstr);
+
+	status = dbwrap_trans_store_bystring(autorid_db, CONFIGKEY,
+					     data, TDB_REPLACE);
+
+	talloc_free(cfgstr);
+
+	return status;
+}
+
 static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom,
 					 const char *params)
 {
 	struct autorid_global_config *config;
+	struct autorid_global_config *storedconfig = NULL;
 	NTSTATUS status;
+	uint32_t hwm;
 
 	config = TALLOC_ZERO_P(dom, struct autorid_global_config);
 	if (!config) {
@@ -433,6 +503,49 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom,
 			  config->maxranges));
 	}
 
+	DEBUG(10, ("Current configuration in config is "
+		   "minvalue:%d rangesize:%d maxranges:%d\n",
+		   config->minvalue, config->rangesize, config->maxranges));
+
+	/* read previously stored config and current HWM */
+	storedconfig = idmap_autorid_loadconfig(talloc_tos());
+
+	if (!dbwrap_fetch_uint32(autorid_db, HWM, &hwm)) {
+		DEBUG(1, ("Fatal error while fetching current "
+			  "HWM value!\n"));
+		status = NT_STATUS_INTERNAL_ERROR;
+		goto error;
+	}
+
+	/* did the minimum value or rangesize change? */
+	if (storedconfig &&
+	    ((storedconfig->minvalue != config->minvalue) ||
+	     (storedconfig->rangesize != config->rangesize))) {
+		DEBUG(1, ("New configuration values for rangesize or "
+			  "minimum uid value conflict with previously "
+			  "used values! Aborting initialization\n"));
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto error;
+	}
+
+	/*
+	 * has the highest uid value been reduced to setting that is not
+	 * sufficient any more for already existing ranges?
+	 */
+	if (hwm > config->maxranges) {
+		DEBUG(1, ("New upper uid limit is too low to cover "
+			  "existing mappings! Aborting initialization\n"));
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto error;
+	}
+
+	status = idmap_autorid_saveconfig(config);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(1, ("Failed to store configuration data!\n"));
+		goto error;
+	}
+
 	DEBUG(5, ("%d domain ranges with a size of %d are available\n",
 		  config->maxranges, config->rangesize));
 
@@ -446,6 +559,8 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom,
 
       error:
 	talloc_free(config);
+	talloc_free(storedconfig);
+
 	return status;
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list