diff options
author | Colin Walters <walters@verbum.org> | 2017-12-05 14:27:15 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-12 14:03:09 +0000 |
commit | 73d910e82eb9076c3551eb9323d55d0a9c768e22 (patch) | |
tree | 86e5f51c9a14ce7186eca53ea98830d5f75be596 /tests/test-corruption.sh | |
parent | 102f30f6cc601aeafd92481ff788bdd35e3f052d (diff) | |
download | ostree-73d910e82eb9076c3551eb9323d55d0a9c768e22.tar.gz |
Add public API for fsck, use it before loading metadata
A while ago I did `truncate -s 0 /path/to/repo/00/123.commit`, and expected a
checksum error, but I actually got a validation error due to us loading the
commit into a variant and trying to parse out the parent checksum, etc.
I first started by changing the `load_and_fsck_one_object()` function to
checksum before loading, but the problem is that we do a traverse of all objects
first. Fixing this is going to require an `OSTREE_REPO_COMMIT_TRAVER_FLAG_FSCK`
or something.
In the meantime at least though, let's add a public API to fsck a single object
which *does* checksum cleanly before parsing the object, and change the `fsck`
command to use it.
We then change the fsck binary to do this while iterating over the refs
and finding the commit object. This way we'll at least get a checksum
first for commit objects, even if not dirtree/dirmeta.
Closes: #1364
Approved by: jlebon
Diffstat (limited to 'tests/test-corruption.sh')
-rwxr-xr-x | tests/test-corruption.sh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test-corruption.sh b/tests/test-corruption.sh index 8e2aba56..52a8189a 100755 --- a/tests/test-corruption.sh +++ b/tests/test-corruption.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2011 Colin Walters <walters@verbum.org> +# Copyright (C) 2011,2017 Colin Walters <walters@verbum.org> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ set -euo pipefail -echo "1..3" +echo "1..4" . $(dirname $0)/libtest.sh @@ -38,6 +38,18 @@ echo "ok chmod" cd ${test_tmpdir} rm repo files -rf setup_test_repository "bare" +rev=$($OSTREE rev-parse test2) +echo -n > repo/objects/${rev:0:2}/${rev:2}.commit +if $OSTREE fsck -q 2>err.txt; then + fatal "fsck unexpectedly succeeded" +fi +assert_file_has_content_literal err.txt "Corrupted commit object; checksum expected" + +echo "ok metadata checksum" + +cd ${test_tmpdir} +rm repo files -rf +setup_test_repository "bare" rm checkout-test2 -rf $OSTREE checkout test2 checkout-test2 cd checkout-test2 |