X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/8501dc39671df3dd7dbbcd4f1788701b80a4511e..183e9cd31b1ac2f14b86c5de6ac2643b8a4364a2:/pwsafe diff --git a/pwsafe b/pwsafe index 896d63a..9de0b31 100644 --- a/pwsafe +++ b/pwsafe @@ -59,8 +59,8 @@ def die(msg): def cmd_create(av): ## Default crypto-primitive selections. - cipher = 'blowfish-cbc' - hash = 'rmd160' + cipher = 'rijndael-cbc' + hash = 'sha256' mac = None ## Parse the options. @@ -147,6 +147,25 @@ def cmd_del(av): try: del pw[tag] except KeyError, exc: die("Password `%s' not found" % exc.args[0]) +def cmd_xfer(av): + + ## Parse the command line. + try: opts, args = getopt(av, 'd:', ['database=']) + except GetoptError: return 1 + dbty = 'flat' + for o, a in opts: + if o in ('-d', '--database'): dbty = a + else: raise 'Barf!' + if len(args) != 1: return 1 + try: dbcls = StorageBackend.byname(dbty) + except KeyError: die("Unknown database backend `%s'" % dbty) + + ## Create the target database. + with StorageBackend.open(file) as db_in: + with dbcls.create(args[0]) as db_out: + for k, v in db_in.iter_meta(): db_out.put_meta(k, v) + for k, v in db_in.iter_passwds(): db_out.put_passwd(k, v) + commands = { 'create': [cmd_create, '[-c CIPHER] [-d DBTYPE] [-h HASH] [-m MAC] [PP-TAG]'], 'find' : [cmd_find, 'LABEL'], @@ -155,7 +174,8 @@ commands = { 'create': [cmd_create, 'changepp' : [cmd_changepp, ''], 'copy' : [cmd_copy, 'DEST-FILE [GLOB-PATTERN]'], 'to-pixie' : [cmd_topixie, '[TAG [PIXIE-TAG]]'], - 'delete' : [cmd_del, 'TAG']} + 'delete' : [cmd_del, 'TAG'], + 'xfer': [cmd_xfer, '[-d DBTYPE] DEST-FILE'] } ###-------------------------------------------------------------------------- ### Command-line handling and dispatch.