s3:net registry check: handle missing version info
authorGregor Beck <gbeck@sernet.de>
Mon, 24 Oct 2011 12:29:45 +0000 (14:29 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 29 Nov 2011 17:20:06 +0000 (18:20 +0100)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/utils/net_registry_check.c

index 8e67edd7f1f9728cab1f0ef347c4e1bfd9f8a2f7..2c278319f594ccd34bf6231d1aaafdb9908d8d45 100644 (file)
@@ -917,6 +917,36 @@ done:
        return NT_STATUS_IS_OK(status);
 }
 
+static bool
+dbwrap_store_uint32_verbose(struct db_context *db, const char *key, uint32_t nval)
+{
+       uint32_t oval;
+       NTSTATUS status;
+
+       status = dbwrap_fetch_uint32(db, key, &oval);
+       if (NT_STATUS_IS_OK(status)) {
+               if (nval == oval) {
+                       goto done;
+               }
+               printf("store %s:\n overwrite: %d\n with:      %d\n", key,
+                      (int)oval, (int)nval);
+
+       } else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+               printf("store %s:\n write: %d\n", key, (int)nval);
+       } else {
+               printf ("store %s:\n  failed to fetch old value: %s\n", key,
+                       nt_errstr(status));
+               goto done;
+       }
+
+       status = dbwrap_store_uint32(db, key, nval);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf ("store %s failed: %s\n", key, nt_errstr(status));
+       }
+
+done:
+       return NT_STATUS_IS_OK(status);
+}
 
 static int cmp_keynames(char **p1, char **p2)
 {
@@ -1200,6 +1230,12 @@ static bool check_ctx_fix_inplace(struct check_ctx *ctx) {
                DEBUG(0, ("delete traverse failed: %s\n", nt_errstr(status)));
                return false;
        }
+
+       if (!dbwrap_store_uint32_verbose(ctx->odb, "INFO/version", ctx->version)) {
+               DEBUG(0, ("storing version failed: %s\n", nt_errstr(status)));
+               return false;
+       }
+
        return true;
 }