X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=passman;h=547ba5c9da28b1499f208137a48dfb5a358d7ab5;hb=06e9186b81c8dca540d3f8a3353e7a3ceef96110;hp=b436f7cfa538c487445da7699b6e69241981a4b3;hpb=a00bf8097ffdedc0b9332f4da50ce422c448a3f3;p=passman.git diff --git a/passman b/passman index b436f7c..547ba5c 100755 --- a/passman +++ b/passman @@ -1,11 +1,10 @@ #!/bin/sh -e # passman -- simple password manager -# Copyright (C) 2013-2017 Sergey Matveev (stargrave@stargrave.org) +# Copyright (C) 2013-2021 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 -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# the Free Software Foundation; version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,17 +16,35 @@ DB=~/.passmandb -generator() -{ +generator() { gpg --armor --gen-random 1 16 | tr '+/' '-_' | tr -d = } -cliper() -{ +cliper() { xclip -in -selection $1 } +ENTITY="" + +finder() { + cd $DB + result=$(find . -type d -path "*$1*" | while read ent; do + [ -e "$ent/passwd" ] || continue + echo "$ent" | sed 's#^\./##' + done) + if [ $(echo "$result" | wc -l) -ne 1 ]; then + echo "$result" + exit 1 + fi + [ -n "$result" ] || exit 1 + ENTITY=$result + echo "$result" +} + case "$1" in +has) + finder "$2" + ;; gen) generator ;; @@ -42,23 +59,13 @@ add) echo "$passwd" > $DB/$dst/passwd ;; *) - cd $DB - result=$(find . -type d -path "*$1*" | while read ent; do - [ -e "$ent/passwd" ] || continue - echo "$ent" | sed 's#^\./##' - done) - if [ $(echo "$result" | wc -l) -ne 1 ]; then - echo "$result" - exit - fi - [ -n "$result" ] || exit 1 - echo $result - if [ -e "$result"/data ]; then + finder "$1" + if [ -e "$ENTITY"/data ]; then echo -n "Associated data: " - cat "$result"/data + cat "$ENTITY"/data fi - perl -ne 'chop and print' "$result"/passwd | cliper clipboard - echo $(basename "$result") | perl -ne 'chop and print' | cliper primary + perl -ne 'chop and print' "$ENTITY"/passwd | cliper clipboard + echo $(basename "$ENTITY") | perl -ne 'chop and print' | cliper primary sleep 10 echo -n | cliper clipboard ;;