diff options
Diffstat (limited to 'source3/libsmb/samlogon_cache.c')
-rw-r--r-- | source3/libsmb/samlogon_cache.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index facdbc7dc1..618a570c4e 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -25,6 +25,7 @@ #include "system/filesys.h" #include "librpc/gen_ndr/ndr_krb5pac.h" #include "../libcli/security/security.h" +#include "util_tdb.h" #define NETSAMLOGON_TDB "netsamlogon_cache.tdb" @@ -70,16 +71,9 @@ clear: } first_try = false; - DEBUG(0,("retry after CLEAR_IF_FIRST for '%s'\n", path)); - tdb = tdb_open_log(path, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, - O_RDWR | O_CREAT, 0600); - if (tdb) { - tdb_close(tdb); - goto again; - } - DEBUG(0,("tdb_open_log(%s) with CLEAR_IF_FIRST - failed\n", path)); - - return false; + DEBUG(0,("retry after truncate for '%s'\n", path)); + truncate(path, 0); + goto again; } @@ -155,7 +149,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3) /* Prepare data */ - if (!(mem_ctx = TALLOC_P( NULL, int))) { + if (!(mem_ctx = talloc( NULL, int))) { DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n")); return false; } @@ -185,7 +179,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3) data.dsize = blob.length; data.dptr = blob.data; - if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) != -1) { + if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) == 0) { result = true; } @@ -223,7 +217,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do return NULL; } - info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3); + info3 = talloc_zero(mem_ctx, struct netr_SamInfo3); if (!info3) { goto done; } |