r23952: Streamline and improve the logic of tdb_validate_and backup:
commit1c36ccd86d85b02f27ec66d37bdf7f04ad760901
authorMichael Adam <obnox@samba.org>
Wed, 18 Jul 2007 11:43:50 +0000 (18 11:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:28:49 +0000 (10 12:28 -0500)
tree7b7114486d5b542d4d52bdc6485f3ba415a1bbd3
parent1a5c8780ae79e5ae4e6a36bfb66cd92ae7d3aa88
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
source/lib/util_tdb.c