From: Brian Warner Date: Mon, 7 Jul 2008 21:11:02 +0000 (-0700) Subject: 'tahoe dump-share': show verify-cap too X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=9b6f23ac0547e725a883d2fd43da167ea821e401;p=tahoe-lafs%2Ftahoe-lafs.git 'tahoe dump-share': show verify-cap too --- diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index 999d51c7..19edc777 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -12,6 +12,7 @@ class DumpOptions(usage.Options): def dump_share(config, out=sys.stdout, err=sys.stderr): from allmydata import uri, storage + from allmydata.util import base32 # check the version, to see if we have a mutable or immutable share print >>out, "share filename: %s" % config['filename'] @@ -61,6 +62,18 @@ def dump_share(config, out=sys.stdout, err=sys.stderr): for k in sorted(leftover): print >>out, "%20s: %s" % (k, unpacked[k]) + # the storage index isn't stored in the share itself, so we depend upon + # knowing the parent directory name to get it + pieces = config['filename'].split(os.sep) + if len(pieces) >= 2 and base32.could_be_base32_encoded(pieces[-2]): + storage_index = base32.a2b(pieces[-2]) + uri_extension_hash = base32.a2b(unpacked["UEB_hash"]) + u = uri.CHKFileVerifierURI(storage_index, uri_extension_hash, + unpacked["needed_shares"], + unpacked["total_shares"], unpacked["size"]) + verify_cap = u.to_string() + print >>out, "%20s: %s" % ("verify-cap", verify_cap) + sizes = {} sizes['data'] = bp._data_size sizes['validation'] = (offsets['uri_extension'] - @@ -145,7 +158,8 @@ def dump_mutable_share(config, out, err): def dump_SDMF_share(offset, length, config, out, err): from allmydata.mutable.layout import unpack_share from allmydata.mutable.common import NeedMoreDataError - from allmydata.util import base32 + from allmydata.util import base32, hashutil + from allmydata.uri import SSKVerifierURI f = open(config['filename'], "rb") f.seek(offset) @@ -183,6 +197,16 @@ def dump_SDMF_share(offset, length, config, out, err): print >>out, " share_hash_chain: %s" % share_hash_ids print >>out, " block_hash_tree: %d nodes" % len(block_hash_tree) + # the storage index isn't stored in the share itself, so we depend upon + # knowing the parent directory name to get it + pieces = config['filename'].split(os.sep) + if len(pieces) >= 2 and base32.could_be_base32_encoded(pieces[-2]): + storage_index = base32.a2b(pieces[-2]) + fingerprint = hashutil.ssk_pubkey_fingerprint_hash(pubkey) + u = SSKVerifierURI(storage_index, fingerprint) + verify_cap = u.to_string() + print >>out, " verify-cap:", verify_cap + print >>out diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index e3fac3e7..aa7ce159 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -11,7 +11,7 @@ import allmydata from allmydata import client, uri, download, upload, storage, offloaded from allmydata.introducer.server import IntroducerNode from allmydata.util import deferredutil, fileutil, idlib, mathutil, testutil -from allmydata.util import log +from allmydata.util import log, base32 from allmydata.scripts import runner, cli from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI from allmydata.mutable.common import NotMutableError @@ -677,6 +677,9 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, # now self.failUnless(" share_hash_chain: " in output) self.failUnless(" block_hash_tree: 1 nodes\n" in output) + expected = (" verify-cap: URI:SSK-Verifier:%s:" % + base32.b2a(storage_index)) + self.failUnless(expected in output) except unittest.FailTest: print print "dump-share output was:" @@ -1458,6 +1461,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, "crypttext_hash", "crypttext_root_hash", "share_root_hash", "UEB_hash"): self.failUnless("%s: " % key in output, key) + self.failUnless(" verify-cap: URI:CHK-Verifier:" in output) # now use its storage index to find the other shares using the # 'find-shares' tool