diff options
author | drebs <drebs@leap.se> | 2013-11-21 10:00:35 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-11-21 11:57:14 -0200 |
commit | 69fd3a11a3821468e737b8fb0e3e77abef0a4b8a (patch) | |
tree | 3ace11d4b4276c86856f3e9b96080410f366ca9b /scripts/server-side-db.py | |
parent | eb07702bc4c1d51e0307b655b14bc1a3835488b2 (diff) |
Add scripts for debugging client and server side databases.
Diffstat (limited to 'scripts/server-side-db.py')
-rw-r--r-- | scripts/server-side-db.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/server-side-db.py b/scripts/server-side-db.py new file mode 100644 index 00000000..01a9aaac --- /dev/null +++ b/scripts/server-side-db.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +# This script gives server-side access to one Soledad user database by using +# the configuration stored in /etc/leap/soledad-server.conf. + +import sys +from ConfigParser import ConfigParser + +from leap.soledad.common.couch import CouchDatabase + +if len(sys.argv) != 2: + print 'Usage: %s <uuid>' % sys.argv[0] + exit(1) + +uuid = sys.argv[1] + +# get couch url +cp = ConfigParser() +cp.read('/etc/leap/soledad-server.conf') +url = cp.get('soledad-server', 'couch_url') + +# access user db +dbname = 'user-%s' % uuid +db = CouchDatabase(url, dbname) + +# get replica info +replica_uid = db._replica_uid +gen, docs = db.get_all_docs() +print "dbname: %s" % dbname +print "replica_uid: %s" % replica_uid +print "generation: %d" % gen + +# get relevant docs +schemes = map(lambda d: d.content['_enc_scheme'], docs) +pubenc = filter(lambda d: d.content['_enc_scheme'] == 'pubkey', docs) + +print "total number of docs: %d" % len(docs) +print "pubkey encrypted docs: %d" % len(pubenc) |