dbwrap_local_open: open NTDB if extension is .ntdb
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:29:42 +0000 (14:59 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:31:19 +0000 (05:31 +0100)
commitf3c0d1d7fe71be7e8b2d1a9780586f8654b46469
tree6a810060c42d3798eaa6f39534a311bbdbf830f6
parent48a42708aead320bfbcee16ae76d095c014802de
dbwrap_local_open: open NTDB if extension is .ntdb

This switches dbwrap_local_open() based on the extension of the
database name, so it handles both TDB and NTDB files.

Moreover, if asked to open a .ntdb, and there's no ntdb file but
there's a .tdb file, it converts that then moves it to .tdb.bak before
opening, and turn the .tdb file into a dangling symlink to make sure
it's never accidentally re-created or used:

$ ls -l secrets.tdb
lrwxrwxrwx 1 rusty rusty 23 Feb 11 11:31 secrets.tdb -> This is now in an NTDB

This provides transparent upgrade if people decide to use NTDB on a
database.  Downgrade would be manual, eg:

ntdbdump foo.ntdb | tdbrestore foo.tdb && mv foo.ntdb foo.ntdb.bak

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/dbwrap/dbwrap_local_open.c