diff options
author | Gerald Carter <jerry@samba.org> | 2006-02-21 14:03:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:10:16 -0500 |
commit | 87ef96e6be75fb4988fac48b2e21892720c20426 (patch) | |
tree | 9eb8577a08268745b8bcdd620093f36bec9242f9 /source3/passdb | |
parent | a57f37420b2b41b1905e2eefa385036b9ddb5bcf (diff) | |
download | samba-87ef96e6be75fb4988fac48b2e21892720c20426.tar.gz samba-87ef96e6be75fb4988fac48b2e21892720c20426.tar.bz2 samba-87ef96e6be75fb4988fac48b2e21892720c20426.zip |
r13589: Make sure we only try to close the tdbsam file in endsampwent() when we
have a valid pwent list from a setsampwent(). Fixes a bug with the
reference count on the open tdb.
(This used to be commit 77332f0738423d16a2b5e21af6aaf92b029da0ef)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_tdb.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index a5e2f7ae02..0a05e1f2a5 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -50,6 +50,7 @@ struct pwent_list { TDB_DATA key; }; static struct pwent_list *tdbsam_pwent_list; +static BOOL pwent_initialized; /* GLOBAL TDB SAM CONTEXT */ @@ -292,6 +293,7 @@ static NTSTATUS tdbsam_setsampwent(struct pdb_methods *my_methods, BOOL update, } tdb_traverse( tdbsam, tdbsam_traverse_setpwent, NULL ); + pwent_initialized = True; return NT_STATUS_OK; } @@ -305,6 +307,13 @@ static void tdbsam_endsampwent(struct pdb_methods *my_methods) { struct pwent_list *ptr, *ptr_next; + /* close the tdb only if we have a valid pwent state */ + + if ( pwent_initialized ) { + DEBUG(7, ("endtdbpwent: closed sam database.\n")); + tdbsam_close(); + } + /* clear out any remaining entries in the list */ for ( ptr=tdbsam_pwent_list; ptr; ptr = ptr_next ) { @@ -312,11 +321,9 @@ static void tdbsam_endsampwent(struct pdb_methods *my_methods) DLIST_REMOVE( tdbsam_pwent_list, ptr ); SAFE_FREE( ptr->key.dptr); SAFE_FREE( ptr ); - } + } - DEBUG(7, ("endtdbpwent: closed sam database.\n")); - - tdbsam_close(); + pwent_initialized = False; } /***************************************************************** |