#include "includes.h"
+/** Don't verify this unique id */
+#define SERVERID_UNIQUE_ID_NOT_TO_VERIFY 0xFFFFFFFFFFFFFFFFULL
+
/*
* Register a server with its unique 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
#include "includes.h"
#include "util_tdb.h"
+#include "serverid.h"
#ifdef CLUSTER_SUPPORT
}
for (i=0; i<vnn->num_srvids; i++) {
- results[vnn->pid_indexes[i]] =
- ((reply->data[i/8] & (1<<(i%8))) != 0);
+ int idx = vnn->pid_indexes[i];
+
+ if (pids[i].unique_id ==
+ SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+ results[idx] = true;
+ continue;
+ }
+ results[idx] = ((reply->data[i/8] & (1<<(i%8))) != 0);
}
TALLOC_FREE(reply);
return false;
}
+ if (id->unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+ return true;
+ }
+
db = serverid_db();
if (db == NULL) {
return false;
struct serverid_key key;
TDB_DATA tdbkey;
+ if (ids[i].unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+ results[i] = true;
+ continue;
+ }
if (!results[i]) {
continue;
}
status = dbwrap_traverse(db, serverid_traverse_fn, &state, NULL);
return NT_STATUS_IS_OK(status);
}
+
+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;
+}
* 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) {
struct smbd_parent_context *parent = NULL;
TALLOC_CTX *frame;
NTSTATUS status;
- uint64_t unique_id;
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
struct tevent_signal *se;
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
/*