X-Git-Url: http://www.git.stargrave.org/?p=passman.git;a=blobdiff_plain;f=passman;h=547ba5c9da28b1499f208137a48dfb5a358d7ab5;hp=9d6e4e774e7b3c73f5a2648a27374841395c7044;hb=HEAD;hpb=0c5eda9e55cc84d810601a40eeb6d829d85e1553
diff --git a/passman b/passman
index 9d6e4e7..7a0ad40 100755
--- a/passman
+++ b/passman
@@ -1,6 +1,6 @@
#!/bin/sh -e
# passman -- simple password manager
-# Copyright (C) 2013-2020 Sergey Matveev (stargrave@stargrave.org)
+# Copyright (C) 2013-2024 Sergey Matveev (stargrave@stargrave.org)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,31 +14,48 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-DB=~/.passmandb
+DB=${PASSMANDB:-$HOME/.passmandb}
+
+dec() {
+ if [ -s $DB ] ; then
+ age -d $DB | zstd -d
+ else
+ cat < $tmp
+ [ $(recsel -c $tmp) -eq 1 ] || {
+ recsel -C -P Name $tmp
exit 1
- fi
- [ -n "$result" ] || exit 1
- ENTITY=$result
- echo "$result"
+ }
+}
+
+commit() {
+ enc < $tmp > ${DB}.tmp
+ fsync ${DB}.tmp
+ mv ${DB}.tmp $DB
}
case "$1" in
@@ -53,19 +70,23 @@ add)
passwd="$3"
[ -n "$dst" ]
[ -n "$passwd" ] || passwd=$(generator)
- echo Adding password for $dst
- mkdir -p $DB/$dst
- umask 077
- echo "$passwd" > $DB/$dst/passwd
+ echo ${dst}...
+ dec | recins -t Credential -f Name -v "$dst" -f Passwd -v "$passwd" > $tmp
+ commit
+ ;;
+mod)
+ dec > $tmp
+ $EDITOR $tmp
+ commit
;;
*)
finder "$1"
- if [ -e "$ENTITY"/data ]; then
- echo -n "Associated data: "
- cat "$ENTITY"/data
- fi
- perl -ne 'chop and print' "$ENTITY"/passwd | cliper clipboard
- echo $(basename "$ENTITY") | perl -ne 'chop and print' | cliper primary
+ name=$(recsel -P Name $tmp)
+ echo $name >&2
+ data=$(recsel -P Data $tmp)
+ [ -z "$data" ] || echo "Associated data: $data"
+ echo -n $(recsel -P Passwd $tmp) | cliper clipboard
+ echo -n ${name##*/} | cliper primary
sleep 10
echo -n | cliper clipboard
;;