diff options
author | Michael Adam <obnox@samba.org> | 2009-04-01 12:23:07 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-04-01 13:20:22 +0200 |
commit | af0163fdfc774f3a032610aadbc1203a770970dc (patch) | |
tree | e470658f6a5690d94e0018bdb7f40327179ffc03 | |
parent | ebd468e96843d64f5078624764c230328d69197c (diff) | |
download | samba-af0163fdfc774f3a032610aadbc1203a770970dc.tar.gz samba-af0163fdfc774f3a032610aadbc1203a770970dc.tar.xz samba-af0163fdfc774f3a032610aadbc1203a770970dc.zip |
s3: fix the fix for bug #6195 - dont let smbd child processes panic
This patch makes sure the original and temporary TDBs are closed
_before_ the rename. Originally, the open TDB was renamed, and so
the name passdb.tdb.tmp stayed around in the db context. Hence
upon client connect, the smbd children died because reinit_after_fork()
calling tdb_reopen_all() would try to reopen passdb.tdb.tmp which
existed no longer...
Michael
(cherry picked from commit 1ab40fbca806f1136dd1d65edd688beb5ec592c7)
-rw-r--r-- | source/passdb/pdb_tdb.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c index f8fd11de6b7..154ee62eac6 100644 --- a/source/passdb/pdb_tdb.c +++ b/source/passdb/pdb_tdb.c @@ -880,6 +880,11 @@ static bool tdbsam_convert_backup(const char *dbname, struct db_context **pp_db) smb_panic("tdbsam_convert_backup: orig commit failed\n"); } + /* be sure to close the DBs _before_ renaming the file */ + + TALLOC_FREE(orig_db); + TALLOC_FREE(tmp_db); + /* This is safe from other users as we know we're * under a mutex here. */ @@ -892,13 +897,22 @@ static bool tdbsam_convert_backup(const char *dbname, struct db_context **pp_db) } TALLOC_FREE(frame); - TALLOC_FREE(orig_db); + + /* re-open the converted TDB */ + + orig_db = db_open_trans(NULL, dbname, 0, + TDB_DEFAULT, O_CREAT|O_RDWR, 0600); + if (orig_db == NULL) { + DEBUG(0, ("tdbsam_convert_backup: Failed to re-open " + "converted passdb TDB [%s]\n", dbname)); + return false; + } DEBUG(1, ("tdbsam_convert_backup: updated %s file.\n", dbname )); /* Replace the global db pointer. */ - *pp_db = tmp_db; + *pp_db = orig_db; return true; cancel: |