Changeset 988 for vendor/current/source4/param/secrets.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/param/secrets.c
r740 r988 26 26 #include "param/param.h" 27 27 #include "system/filesys.h" 28 #include "lib/ util/tdb_wrap.h"28 #include "lib/tdb_wrap/tdb_wrap.h" 29 29 #include "lib/ldb-samba/ldb_wrap.h" 30 30 #include <ldb.h> … … 34 34 35 35 /** 36 * Use a TDB to store an incrementing random seed.37 *38 * Initialised to the current pid, the very first time Samba starts,39 * and incremented by one each time it is needed.40 *41 * @note Not called by systems with a working /dev/urandom.42 */43 static void get_rand_seed(struct tdb_wrap *secretsdb, int *new_seed)44 {45 *new_seed = getpid();46 if (secretsdb != NULL) {47 tdb_change_int32_atomic(secretsdb->tdb, "INFO/random_seed", new_seed, 1);48 }49 }50 51 /**52 * open up the secrets database53 */54 struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)55 {56 char *fname;57 uint8_t dummy;58 struct tdb_wrap *tdb;59 60 fname = private_path(mem_ctx, lp_ctx, "secrets.tdb");61 62 tdb = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);63 64 if (!tdb) {65 DEBUG(0,("Failed to open %s\n", fname));66 talloc_free(fname);67 return NULL;68 }69 talloc_free(fname);70 71 /**72 * Set a reseed function for the crypto random generator73 *74 * This avoids a problem where systems without /dev/urandom75 * could send the same challenge to multiple clients76 */77 set_rand_reseed_callback((void (*) (void *, int *))get_rand_seed, tdb);78 79 /* Ensure that the reseed is done now, while we are root, etc */80 generate_random_buffer(&dummy, sizeof(dummy));81 82 return tdb;83 }84 85 /**86 36 connect to the secrets ldb 87 37 */ … … 89 39 struct loadparm_context *lp_ctx) 90 40 { 91 return ldb_wrap_connect(mem_ctx, NULL, lp_ctx, lpcfg_secrets_url(lp_ctx),41 return ldb_wrap_connect(mem_ctx, NULL, lp_ctx, "secrets.ldb", 92 42 NULL, NULL, 0); 93 43 }
Note:
See TracChangeset
for help on using the changeset viewer.