summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-24 02:58:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:14:39 -0500
commit3cf367f0e76f44c7b14a54e0fcf510cc79a15c6a (patch)
tree850ac71d21c53a0b62833780770f89566d00be6c
parent8761f5dcc4db5c825a600fe25792ec47cb6cbdc7 (diff)
downloadsamba-3cf367f0e76f44c7b14a54e0fcf510cc79a15c6a.tar.gz
samba-3cf367f0e76f44c7b14a54e0fcf510cc79a15c6a.tar.bz2
samba-3cf367f0e76f44c7b14a54e0fcf510cc79a15c6a.zip
r18868: just in case there is a disaster (with our code? never ...) use a
rename to group_mapping.tdb.upgraded rather than an unlink when upgrading. So if we absolutely have to go back to the tdb, we can change mapping_ldb.o to mapping_tdb.o in Makefile.in and recover peoples group mappings. We could go one step futher and make the backend configurable. Any opinions on that? (This used to be commit 203fc0b03c7397f7339a917456cb1701ed592f32)
-rw-r--r--source3/groupdb/mapping_ldb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c
index c8824674e1..6368e41a06 100644
--- a/source3/groupdb/mapping_ldb.c
+++ b/source3/groupdb/mapping_ldb.c
@@ -643,6 +643,8 @@ static BOOL mapping_upgrade(const char *tdb_path)
{
static TDB_CONTEXT *tdb;
int ret, status=0;
+ pstring old_path;
+ pstring new_path;
tdb = tdb_open_log(tdb_path, 0, TDB_DEFAULT, O_RDWR, 0600);
if (tdb == NULL) goto failed;
@@ -657,8 +659,11 @@ static BOOL mapping_upgrade(const char *tdb_path)
if (tdb) tdb_close(tdb);
- if (unlink(tdb_path) != 0) {
- DEBUG(0,("Failed to delete old group mapping database\n"));
+ pstrcpy(old_path, tdb_path);
+ pstrcpy(new_path, lock_path("group_mapping.tdb.upgraded"));
+
+ if (rename(old_path, new_path) != 0) {
+ DEBUG(0,("Failed to rename old group mapping database\n"));
goto failed;
}
return True;