Warn the user before overwriting an existing db with init. - 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 cda319bcb34d3f10945787e0085d13ebb9099d45
(DIR) parent 579387ed5a16560041d32558bd7b3959ce4402ad
(HTM) Author: Christian Kellermann <ckeen@pestilenz.org>
Date: Wed, 20 Apr 2016 22:38:04 +0200
Warn the user before overwriting an existing db with init.
Diffstat:
pee.scm | 24 ++++++++++++++++--------
todo.org | 1 -
2 files changed, 16 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/pee.scm b/pee.scm
@@ -349,14 +349,22 @@
(exit 1))))
(define (do-init db-name content)
- (print "I will ask you twice for the passphrase to encrypt the password store with.")
- (let ((passphrase1 (get-hashed-passphrase))
- (passphrase2 (get-hashed-passphrase)))
- (unless (equal? passphrase1 passphrase2)
- (print "Error: Passphrases do not match.")
- (exit 1))
- (encrypt-file db-name content passphrase1)
- (print "Password store " db-name " initialised.")))
+ (define (really-init)
+ (print "I will ask you twice for the passphrase to encrypt the password store with.")
+ (let ((passphrase1 (get-hashed-passphrase))
+ (passphrase2 (get-hashed-passphrase)))
+ (unless (equal? passphrase1 passphrase2)
+ (print "Error: Passphrases do not match.")
+ (exit 1))
+ (encrypt-file db-name content passphrase1)
+ (print "Password store " db-name " initialised.")))
+ (cond ((and (check-access db-name)
+ (ask-yes-or-no (sprintf "~a does exist, do you want to OVERWRITE ALL THE CONTENTS?" db-name)))
+ (really-init))
+ ((not (check-access db-name))
+ (really-init))
+ (else
+ (print "Nothing done."))))
(define (do-change-passphrase db-name db old-passphrase)
(print "I will ask you twice for the new passphrase.")
(DIR) diff --git a/todo.org b/todo.org
@@ -1,5 +1,4 @@
* TODOs
** Do we need to feed arc4random into tweetnacl for better randomness?
-** initialise-db should not overwrite the file so easily
** Add a version counter to the file, so we can make assumptions about the file format (maybe with a '@ entry?)