Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Use sublists in PWman to match groups in Lastpass.
I hadn't realised PWman supports sublists (groups), therefore can match - Now reads in CSV file to hashtable. Since CSV file is not ordered by |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
05989bbd9bbe37fdf42df917146eb1c7 |
User & Date: | atomicules@lavabit.com 2012-12-10 09:47:33 |
2012-12-10
| ||
10:02 | Remove spurious spaces check-in: adf34078f1 user: atomicules@lavabit.com tags: master, trunk | |
09:47 |
Use sublists in PWman to match groups in Lastpass.
I hadn't realised PWman supports sublists (groups), therefore can match - Now reads in CSV file to hashtable. Since CSV file is not ordered by | |
09:40 | Capitalise name. check-in: 35b06b14a8 user: atomicules@lavabit.com tags: master, trunk | |
Changes to lastpass2pwman.lisp.
︙ | ︙ | |||
8 9 10 11 12 13 14 | (ql:quickload "xmls") ;Note to self: Start with 2nd *posix-argv* as first is always /path/to/sbcl, etc. ;gpgid to encrypt file with (defparameter gpgid (second *posix-argv*)) ;Check for supplied filename, otherwise assume called lastpass.csv (defparameter infile (if (null (third *posix-argv*)) "lastpass.csv" (third *posix-argv*))) | | > > > > > > > | > | > > > > > > | | | | | | | | > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | (ql:quickload "xmls") ;Note to self: Start with 2nd *posix-argv* as first is always /path/to/sbcl, etc. ;gpgid to encrypt file with (defparameter gpgid (second *posix-argv*)) ;Check for supplied filename, otherwise assume called lastpass.csv (defparameter infile (if (null (third *posix-argv*)) "lastpass.csv" (third *posix-argv*))) ;read the lastpass file and build up hash for each group, then write lists at the end. (defparameter *lastpass* (make-hash-table)) (csv-parser:map-csv-file infile (lambda (ln) (if (gethash (read-from-string (substitute #\- #\Space (sixth ln))) *lastpass*) ;Group ;Note, without (intern (string-upcase or (read-from-string keys aren't set properly and something bizarre happens. (setf (gethash (read-from-string (substitute #\- #\Space (sixth ln))) *lastpass*) (append (gethash (read-from-string (substitute #\- #\Space (sixth ln))) *lastpass*) (list ln))) ;append key (setf (gethash (read-from-string (substitute #\- #\Space (sixth ln))) *lastpass*) (list ln)))) :skip-lines 1) ;create key (with-open-file (stream "pwman.txt" :direction :output :if-exists :supersede) (format stream "<?xml version=\"1.0\"?><PWMan_PasswordList version=\"3\"><PwList name=\"Main\">") ;For each key in hash (with-hash-table-iterator (group *lastpass*) (loop (multiple-value-bind (returned? key value) (group) (if returned? (progn (format stream "<PwList name=\"~a\">" key) ;Then loop through each entry in value (loop for entry in value do (format stream "<PwItem><name>~a</name><host>~a</host><user>~a</user><passwd>~a</passwd><launch></launch></PwItem>" (xmls:toxml (fifth entry)) (xmls:toxml (first entry)) (xmls:toxml (second entry)) (if (null (third entry)) ;Secure Notes have no password (xmls:toxml (fourth entry)) ;Use extra field if Secure Note (xmls:toxml (third entry))))) (format stream "</PwList>")) (return))))) (format stream "</PwList></PWMan_PasswordList>")) ;Move original file to backup (rename-file (concatenate 'string (sb-unix::posix-getenv "HOME") "/.pwman.db") (concatenate 'string (sb-unix::posix-getenv "HOME") "/.pwman.db.bak")) ;gpg encrpyt the file (let ((proc (sb-ext:run-program "gpg" (list "-r" gpgid "-o" (concatenate 'string (sb-unix::posix-getenv "HOME") "/.pwman.db") "-e" "pwman.txt") :search :environment))) (if (= 0 (sb-ext:process-exit-code proc)) ;If that was successful, then delete the un-encrypted files |
︙ | ︙ |