/** * Use a TDB to store an incrementing random seed. * * Initialised to the current pid, the very first time Samba starts, * and incremented by one each time it is needed. * * @note Not called by systems with a working /dev/urandom. */ static void get_rand_seed(struct tdb_wrap *secretsdb, int *new_seed) { *new_seed = getpid(); if (secretsdb != NULL) { tdb_change_int32_atomic(secretsdb->tdb, "INFO/random_seed", new_seed, 1); } }
void reset_globals_after_fork(void) { unsigned char dummy; /* * Increment the global seed value to ensure every smbd starts * with a new random seed. */ if (tdb) { int32 initial_val = sys_getpid(); tdb_change_int32_atomic(tdb, "INFO/random_seed", (int *)&initial_val, 1); set_rand_reseed_data((unsigned char *)&initial_val, sizeof(initial_val)); } /* * Re-seed the random crypto generator, so all smbd's * started from the same parent won't generate the same * sequence. */ generate_random_buffer( &dummy, 1, True); }