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

Karolin Seeger kseeger at samba.org
Tue Feb 21 12:47:19 MST 2012


The branch, v3-6-test has been updated
       via  271a1f4 s3: Add SERVERID_UNIQUE_ID_NOT_TO_VERIFY, bug 8760
      from  43f9e74 s3-printing: fix crash in printer_list_set_printer()

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


- Log -----------------------------------------------------------------
commit 271a1f42b5dc95bff6ffd93a653ca8a1269e92af
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 16 14:22:42 2012 -0800

    s3: Add SERVERID_UNIQUE_ID_NOT_TO_VERIFY, bug 8760
    
    Back-port of commit dd5868d41eeaa304a471822d7783526d9f4c37f5
    from master. Back-port done by Manoj Dahal <mdahal at novell.com>.

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

Summary of changes:
 source3/include/serverid.h |    9 +++++++++
 source3/lib/serverid.c     |   16 ++++++++++++++++
 source3/smbd/server.c      |    6 ++----
 3 files changed, 27 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 62bf638..435c88b 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -22,6 +22,9 @@
 
 #include "includes.h"
 
+/** Don't verify this unique id */
+#define SERVERID_UNIQUE_ID_NOT_TO_VERIFY 0xFFFFFFFFFFFFFFFFULL
+
 /*
  * Register a server with its unique id
  */
@@ -64,4 +67,10 @@ bool serverid_traverse_read(int (*fn)(const struct server_id *id,
  */
 bool serverid_parent_init(TALLOC_CTX *mem_ctx);
 
+/*
+ * Get a random unique_id and make sure that it is not
+ * SERVERID_UNIQUE_ID_NOT_TO_VERIFY
+ */
+uint64_t serverid_get_random_unique_id(void);
+
 #endif
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 8cd7f5a..00dd6c4 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -241,6 +241,10 @@ bool serverid_exists(const struct server_id *id)
 		return false;
 	}
 
+	if (id->unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+		return true;
+	}
+
 	db = serverid_db();
 	if (db == NULL) {
 		return false;
@@ -355,3 +359,15 @@ bool serverid_traverse(int (*fn)(struct db_record *rec,
 	state.private_data = private_data;
 	return db->traverse(db, serverid_traverse_fn, &state);
 }
+
+uint64_t serverid_get_random_unique_id(void)
+{
+	uint64_t unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY;
+
+	while (unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+		generate_random_buffer((uint8_t *)&unique_id,
+					sizeof(unique_id));
+	}
+
+	return unique_id;
+}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index db68ace..28bb947 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -447,7 +447,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
 	 * Generate a unique id in the parent process so that we use
 	 * the global random state in the parent.
 	 */
-	generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id));
+	unique_id = serverid_get_random_unique_id();
 
 	pid = sys_fork();
 	if (pid == 0) {
@@ -920,7 +920,6 @@ extern void build_options(bool screen);
 	struct smbd_parent_context *parent = NULL;
 	TALLOC_CTX *frame;
 	NTSTATUS status;
-	uint64_t unique_id;
 
 	/*
 	 * Do this before any other talloc operation
@@ -1119,8 +1118,7 @@ extern void build_options(bool screen);
 		become_daemon(Fork, no_process_group, log_stdout);
 	}
 
-        generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id));
-        set_my_unique_id(unique_id);
+	set_my_unique_id(serverid_get_random_unique_id());
 
 #if HAVE_SETPGID
 	/*


-- 
Samba Shared Repository


More information about the samba-cvs mailing list