Match the exact account name in password retrieval - pee - Pee a password manager;Pee - because you have to...
(HTM) git clone git://vernunftzentrum.de/pee.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit a485baf0ea2485bcddd5f60bc067c3f3aa4c7179
(DIR) parent 7777da6a41c52ab262aac89c4fa34a6ee9269b4b
(HTM) Author: Christian Kellermann <ckeen@pestilenz.org>
Date: Tue, 12 Jan 2016 12:57:05 +0100
Match the exact account name in password retrieval
This also makes it possible to remove the search-entry and get-*
procedures which have not been in use besides get-password.
Diffstat:
pee.scm | 32 +++++--------------------------
1 file changed, 5 insertions(+), 27 deletions(-)
---
(DIR) diff --git a/pee.scm b/pee.scm
@@ -136,28 +136,6 @@
(define (db-keys alist) (map car alist))
-(define (search-entry db entry)
- (let* ((regex (string->irregex (string-append ".*" entry ".*") 'i 'utf8))
- (result
- (find (lambda (k) (irregex-match regex k))
- (db-keys db))))
- (and result
- (not (null? result))
- (cons result (alist-ref result db equal?)))))
-
-(define (get-result db entry op)
- (let ((entry (search-entry db entry)))
- (and entry (> (length entry) 1) (op entry))))
-
-(define (get-user db entry)
- (get-result db entry second))
-
-(define (get-password db entry)
- (get-result db entry third))
-
-(define (get-comment db entry)
- (get-result db entry fourth))
-
(define (update-db db key #!key user password comment)
(let ((entry (or (alist-ref key db equal?) (make-list 3 ""))))
(alist-update key
@@ -306,11 +284,11 @@
accounts))))
(define (do-password db e)
- (let ((p (get-password db e)))
- (if p (print p)
- (begin
- (print "Error: password for " e " not found.")
- (exit 1)))))
+ (cond ((alist-ref e db equal?) =>
+ (lambda (e) (print (second e))))
+ (else
+ (print "Error: password for " e " not found.")
+ (exit 1))))
(define (do-init db-name content)
(print "I will ask you twice for the passphrase to encrypt the password store with.")