Index: source3/include/serverid.h =================================================================== --- source3/include/serverid.h.orig +++ source3/include/serverid.h @@ -22,6 +22,8 @@ #include "includes.h" +#define UNIQUE_ID_NOT_TO_VERIFY 0xFFFFFFFFFFFFFFFFULL /** Don't verify this unique id */ + /* * Register a server with its unique id */ @@ -64,4 +66,9 @@ bool serverid_traverse_read(int (*fn)(co */ bool serverid_parent_init(TALLOC_CTX *mem_ctx); +/* + * Get a random unique_id and make sure that it is not UNIQUE_ID_NOT_TO_VERIFY + */ +uint64_t get_random_unique_id(); + #endif Index: source3/lib/serverid.c =================================================================== --- source3/lib/serverid.c.orig +++ source3/lib/serverid.c @@ -241,6 +241,11 @@ bool serverid_exists(const struct server return false; } + if (id->unique_id == UNIQUE_ID_NOT_TO_VERIFY) + { + return true; + } + db = serverid_db(); if (db == NULL) { return false; @@ -355,3 +360,14 @@ bool serverid_traverse(int (*fn)(struct state.private_data = private_data; return db->traverse(db, serverid_traverse_fn, &state); } + +uint64_t get_random_unique_id() +{ + uint64_t unique_id; + + do { + generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id)); + } while (unique_id == UNIQUE_ID_NOT_TO_VERIFY); + + return unique_id; +} Index: source3/smbd/server.c =================================================================== --- source3/smbd/server.c.orig +++ source3/smbd/server.c @@ -441,7 +441,7 @@ static void smbd_accept_connection(struc * 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 = get_random_unique_id(); pid = sys_fork(); if (pid == 0) { @@ -914,7 +914,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 @@ -1113,8 +1112,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(get_random_unique_id()); #if HAVE_SETPGID /*