r23952: Streamline and improve the logic of tdb_validate_and backup:
authorMichael Adam <obnox@samba.org>
Wed, 18 Jul 2007 11:43:50 +0000 (11:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:28:49 +0000 (12:28 -0500)
commit21a847473da54b6e4b41a94f781a2935f482ebaa
tree136766f4fac58057bb718ca9122c43f0e1003bc8
parente6875b1b45577917ff9b465623502f49755aa612
r23952: Streamline and improve the logic of tdb_validate_and backup:

- call tdb_validate on the given tdb.
- if validation is successful, create a backup
  return 0 (success) even if the backup fails.
- if validation fails:
  - move tdb to name.corrupt (don't exit if this fails)
  - look for a valid backup
  - if a valid backup is found, restore it, else return -1 (failure)
    if restoring succeeds, return 0 (success), else -1 (failure)

Summing up:

If 0 is returned, there is a valid tdb at the given location:
either the original one ore one restrored from a backup.

If -1 is returned, there is no valid tdb at the given location:
Either there is no file at all, or the original file is still
in place (if moving it away failed).

Michael
(This used to be commit 1c36ccd86d85b02f27ec66d37bdf7f04ad760901)
source3/lib/util_tdb.c