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 | 77332f0738423d16a2b5e21af6aaf92b029da0ef (patch) | |
tree | 738dc649f6f8faac6533d18d52dbfceb13be507f /source | |
parent | 7a17b39c80703909f102487690d2117d874b0e15 (diff) | |
download | samba-77332f0738423d16a2b5e21af6aaf92b029da0ef.tar.gz samba-77332f0738423d16a2b5e21af6aaf92b029da0ef.tar.xz samba-77332f0738423d16a2b5e21af6aaf92b029da0ef.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.
Diffstat (limited to 'source')
-rw-r--r-- | source/passdb/pdb_tdb.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c index a5e2f7ae024..0a05e1f2a51 100644 --- a/source/passdb/pdb_tdb.c +++ b/source/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; } /***************************************************************** |