summaryrefslogtreecommitdiff
path: root/scripts/server-side-db.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-12-06 15:43:23 -0300
committerTomás Touceda <chiiph@leap.se>2013-12-06 15:43:23 -0300
commitdeb78a5f3502ece98ec3e0b70f93025c4a1b3da5 (patch)
treeabb188c846482e60a1961864b70c17cbf760f6a8 /scripts/server-side-db.py
parent0ade4a7e3a323df631c9772e4db5173a20979d46 (diff)
parent5f2a29120ba2d22d7d2406628ce2f6735b60d09c (diff)
Merge branch 'release-0.4.4'0.4.4
Diffstat (limited to 'scripts/server-side-db.py')
-rw-r--r--scripts/server-side-db.py38
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)