Add age check to options - 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 4b2b2cd52f72819a07189666f4d7a99ce694d989
(DIR) parent 810c7d5e73663f7fa6094b2c446386665342693c
(HTM) Author: Christian Kellermann <ckeen@pestilenz.org>
Date: Tue, 28 Jun 2016 10:26:00 +0200
Add age check to options
With the --check-age option you can now check which passwords should be
changed, because their modification date is older than DAYS.
Lists the old entries.
Diffstat:
pee.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/pee.scm b/pee.scm
@@ -278,6 +278,11 @@
(required #f)
(value (required FILE)
(predicate ,check-access)))
+ (check-age
+ "Checks the age of the passwords to remind you of changing it"
+ (required #f)
+ (value (required DAYS)
+ (predicate ,(lambda (o) (number? (string->number o))))))
(version
"Print program version"
(required #f)
@@ -432,6 +437,22 @@
db-theirs)
passphrase)))))
+(define (do-age-check db days)
+ (define (expires-in-seconds entry)
+ (+ (fifth entry)
+ (* 60 60 24 days)))
+ (let* ((now (current-seconds))
+ (old-passwords
+ (filter
+ (lambda (p)
+ (< (expires-in-seconds p) now))
+ db)))
+ (if (pair? old-passwords)
+ (begin
+ (print "These passwords are older than " days " days.")
+ (do-list old-passwords 'all))
+ (print "Your passwords are younger than " days " days."))))
+
(define (main args)
(when (null? args)
(banner) (print (usage options)) (exit 1))
@@ -476,6 +497,7 @@
((alist-ref 'update opts) => (lambda (e) (do-update db-name db passphrase e)))
((alist-ref 'password opts) => (lambda (e) (do-password db e)))
((alist-ref 'merge opts) => (lambda (theirs) (do-merge db-name db passphrase theirs)))
+ ((alist-ref 'check-age opts) => (lambda (days) (do-age-check db (string->number days))))
(else (banner) (print "Error: Don't know what to do") (print (usage options)) (exit 1))))))
(exit 0)))
)