config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 60aab8b08883a2a1af7d4a079f879759ffa60d69
parent 1e9a07d6cf1a5e1833f0bf59858f7cb902a142f5
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Sun, 14 Feb 2021 23:54:23 -0800

Add spm(1) fork

Diffstat:
Amodules/scripts/.local/bin/tspm | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+), 0 deletions(-)

diff --git a/modules/scripts/.local/bin/tspm b/modules/scripts/.local/bin/tspm @@ -0,0 +1,94 @@ +#!/bin/sh -e +# Copyright 2013-2016 Sören Tempel +# Copyright 2016, 2017 Klemens Nanni <kl3@posteo.org> +# Copyright 2021 Jacob R. Edwards +# +# tspm -- truely simple password manager +# +# A clean and easy to understand fork of spm(1) with only features +# I want. Also, the name is a lie, this still uses gpg2(2) and is +# overly complex. +# +# 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/>. + +IFS=' +' + +cd "${PASSWORD_STORE_DIR:-${HOME}/.spm}" +umask u=rwx,go= + +err() { + printf '%s: %s\n' `basename $0` $1 1>&2 + exit 1 +} + +gpg() { + if test -z "$PASSWORD_STORE_KEY"; then + gpg2 -q --yes --batch --default-recipient-self $* + else + gpg2 -q --yes --batch -r "$PASSWORD_STORE_KEY" $* + fi +} + +getpass() { + test -t 0 && { + stty -echo + printf '%s' $1 + } + read -r $2 + test -t 0 && { + stty echo + printf '\n' + } + test -n $2 +} + +add() { + for entry in $* + do + test -e $entry && err "$entry: File exists" + getpass "$entry: " pw || err "$entry: Unable to get passphrase" + mkdir -p "$(dirname $entry)" && + echo $pw | gpg -eo $entry + done +} + +del() { + rm -ri $* +} + +find() { + command find . -type f -or -type l | cut -d/ -f2- | egrep -i ${*:-.} +} + +show() { + for entry in `find $*` + do + gpg -d $entry + done +} + +case $1 in +(a|add) + shift; add $*;; +(d|del) + shift; del $*;; +(f|find) + shift; find $*;; +(s|show) + shift; show $*;; +(*) + printf 'usage: %s add|del|find|show [entry...]\n' `basename $0` 1>&2 + exit 1 +esac