Merge xsekrit into credentials

This commit is contained in:
Lucas 2019-12-28 00:12:31 +00:00
parent 83d15c417d
commit 01c6a6d22d
3 changed files with 28 additions and 31 deletions

View File

@ -16,7 +16,7 @@ PREFIX = $(HOME)
MANPREFIX = $(PREFIX)/local MANPREFIX = $(PREFIX)/local
BIN = ZZZ browser credentials fetch flac2ogg imgresize invidious \ BIN = ZZZ browser credentials fetch flac2ogg imgresize invidious \
riot-web-ui rfcopen screenshot sekrit tor-browser \ riot-web-ui rfcopen screenshot sekrit tor-browser \
w3m-copy-link xsekrit w3m-copy-link
MAN1 = sekrit.1 MAN1 = sekrit.1
all: $(BIN) all: $(BIN)

View File

@ -12,7 +12,11 @@
usage() usage()
{ {
printf "Usage: %s [-2pu] service\n" "${0##*/}" >&2 cat - <<. >&2
Usage:
${0##*/} [-2pu] service
${0##*/} -r key
.
exit 1 exit 1
} }
@ -86,15 +90,28 @@ get_service()
[ $sfa = yes ] && get_2fa "$service" [ $sfa = yes ] && get_2fa "$service"
} }
get_raw()
{
key=$1
sekrit has "$key" || err "Unknown key \"$key\"."
printf "%s" "$key"
sekrit get "$key" | clip && printf "\n"
}
sfa=no sfa=no
pass=no pass=no
raw=no
user=no user=no
while getopts 2pu flag; do while getopts 2pru flag; do
case $flag in case $flag in
2) sfa=check 2) sfa=check
;; ;;
p) pass=check p) pass=check
;; ;;
r) raw=yes
;;
u) user=check u) user=check
;; ;;
*) usage *) usage
@ -106,4 +123,11 @@ shift $(($OPTIND - 1))
[ $# -eq 1 ] && [ -n "$1" ] || usage [ $# -eq 1 ] && [ -n "$1" ] || usage
key=$1 key=$1
get_service "$key" $user $pass $sfa if [ $raw = yes ]; then
if [ $sfa != no ] || [ $pass != no ] || [ $user != no ]; then
err "-r is mutually exclusive with -2pu."
fi
get_raw "$key"
else
get_service "$key" $user $pass $sfa
fi

View File

@ -1,27 +0,0 @@
#!/bin/sh
# xsekrit
# Written in 2019 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty. You should have received a copy of the CC0 Public Domain
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
usage()
{
printf "Usage: %s key\n" "${0##*/}" >&2
exit 1
}
err()
{
printf "%s: %s\n" "${0##*/}" "$*" >&2
exit 1
}
[ $# -eq 1 ] && [ -n "$1" ] || usage
sekrit has "$1" || err "Unknown key \"$1\"."
sekrit get "$1" | xclip -q -r -l 1 -sel clip 2>/dev/null