diff options
author | Jeremy Allison <jra@samba.org> | 2006-02-28 06:33:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:10:51 -0500 |
commit | ddf14cc286944e11cebfcf550cf57a7a9436a5a0 (patch) | |
tree | 3ad4699f8fa0c23376617177509cbc816690d1e3 /source3/passdb | |
parent | 51d3bbe2858c8ed1afd9b3fd46ae952fd22d48f0 (diff) | |
download | samba-ddf14cc286944e11cebfcf550cf57a7a9436a5a0.tar.gz samba-ddf14cc286944e11cebfcf550cf57a7a9436a5a0.tar.bz2 samba-ddf14cc286944e11cebfcf550cf57a7a9436a5a0.zip |
r13747: Fix the reference count for tdbsam_open() - on an
upgrade it calls tdbsam_convert() which calls tdbsam_open()
deep inside the init_sam_from_buffer_vX call.
If the ref count hasn't been set yet then we will close
the tdbsam reference in tdbsam_getsampwsid().
smbpasswd -a was core-dumping again :-).
Jeremy
(This used to be commit 993069eb87c190ba8ee92224340c8f9ffb3ade74)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_tdb.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index fdf22d9c42..b38ebe436a 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -817,17 +817,24 @@ static BOOL tdbsam_open( const char *name ) return False; } + /* set the initial reference count - must be done before tdbsam_convert + as that calls tdbsam_open()/tdbsam_close(). */ + + ref_count = 1; + /* Check the version */ version = tdb_fetch_int32( tdbsam, TDBSAM_VERSION_STRING ); - if (version == -1) + if (version == -1) { version = 0; /* Version not found, assume version 0 */ + } /* Compare the version */ if (version > TDBSAM_VERSION) { /* Version more recent than the latest known */ DEBUG(0, ("tdbsam_open: unknown version => %d\n", version)); tdb_close( tdbsam ); + ref_count = 0; return False; } @@ -839,16 +846,13 @@ static BOOL tdbsam_open( const char *name ) if ( !tdbsam_convert(version) ) { DEBUG(0, ("tdbsam_open: Error when trying to convert tdbsam [%s]\n",name)); tdb_close(tdbsam); + ref_count = 0; return False; } DEBUG(3, ("TDBSAM converted successfully.\n")); } - /* set the initial reference count */ - - ref_count = 1; - DEBUG(4,("tdbsam_open: successfully opened %s\n", name )); return True; |