diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-08-10 13:50:26 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-08-13 10:25:06 +1000 |
commit | 08ccc6ed5121dae8485328fc2ac8ad4f35db2729 (patch) | |
tree | 3d4bd0ef26012c5354edbce57ab663bf84e6cc63 /source3/passdb | |
parent | 6f21f556c1e9a6df9f7dc00aa1e270ff91ffd850 (diff) | |
download | samba-08ccc6ed5121dae8485328fc2ac8ad4f35db2729.tar.gz samba-08ccc6ed5121dae8485328fc2ac8ad4f35db2729.tar.bz2 samba-08ccc6ed5121dae8485328fc2ac8ad4f35db2729.zip |
passdb: Add a function to read secrets db from a specified path
This allows to load secrets db from a different location. The original
secrets_init() now calls secrets_init_path() with lp_private_dir().
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/secrets.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index d39390e8c6..d229640793 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -55,19 +55,24 @@ static void get_rand_seed(void *userdata, int *new_seed) } } -/* open up the secrets database */ -bool secrets_init(void) +/* open up the secrets database with specified private_dir path */ +bool secrets_init_path(const char *private_dir) { char *fname = NULL; unsigned char dummy; - if (db_ctx != NULL) + if (db_ctx != NULL) { return True; + } + + if (private_dir == NULL) { + return False; + } fname = talloc_asprintf(talloc_tos(), "%s/secrets.tdb", - lp_private_dir()); + private_dir); if (fname == NULL) { - return false; + return False; } db_ctx = db_open(NULL, fname, 0, @@ -75,7 +80,6 @@ bool secrets_init(void) if (db_ctx == NULL) { DEBUG(0,("Failed to open %s\n", fname)); - TALLOC_FREE(fname); return False; } @@ -95,6 +99,12 @@ bool secrets_init(void) return True; } +/* open up the secrets database */ +bool secrets_init(void) +{ + return secrets_init_path(lp_private_dir()); +} + struct db_context *secrets_db_ctx(void) { if (!secrets_init()) { |