From 77237f1401b4c9f6325ef6c707fc3567393ed7c6 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 29 Oct 2015 11:37:12 +0300 Subject: [PATCH] Initial revision --- passman | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 passman diff --git a/passman b/passman new file mode 100755 index 0000000..3153793 --- /dev/null +++ b/passman @@ -0,0 +1,63 @@ +#!/bin/sh -e +# passman -- simple password manager +# Copyright (C) 2013-2015 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +DB=~/.passmandb + +generator() +{ + dd if=/dev/urandom bs=16 count=1 2>/dev/null | base64 | tr '+/' '-_' | tr -d = +} + +cliper() +{ + xclip -in -selection $1 +} + +case "$1" in +gen) + generator + ;; +add) + dst="$2" + passwd="$3" + [ -n "$dst" ] + [ -n "$passwd" ] || passwd=$(generator) + echo Adding password for $dst + mkdir -p $DB/$dst + 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 + echo $result + if [ -e "$result"/data ]; then + echo -n "Associated data: " + cat "$result"/data + fi + perl -ne 'chop and print' "$result"/passwd | cliper clipboard + echo $(basename "$result") | perl -ne 'chop and print' | cliper primary + sleep 10 + echo -n | cliper clipboard + ;; +esac -- 2.44.0