]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
'tahoe dump-share': show verify-cap too
authorBrian Warner <warner@lothar.com>
Mon, 7 Jul 2008 21:11:02 +0000 (14:11 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 7 Jul 2008 21:11:02 +0000 (14:11 -0700)
src/allmydata/scripts/debug.py
src/allmydata/test/test_system.py

index 999d51c75c3c9b61bd6c579dbe4e4a8067cb81af..19edc77734da163371f4bed666e2c2ec6d7484d0 100644 (file)
@@ -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
 
 
index e3fac3e7f6f96bb05cca81b408428f5006dac786..aa7ce1595792660e50cb046265b8eec3f020c478 100644 (file)
@@ -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