]> Sergey Matveev's repositories - passman.git/commitdiff
Initial revision
authorSergey Matveev <stargrave@stargrave.org>
Thu, 29 Oct 2015 08:37:12 +0000 (11:37 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 29 Oct 2015 08:37:12 +0000 (11:37 +0300)
passman [new file with mode: 0755]

diff --git a/passman b/passman
new file mode 100755 (executable)
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 <http://www.gnu.org/licenses/>.
+
+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