mirror of
https://github.com/gaschz/qubes-pass.git
synced 2025-06-07 01:38:31 +02:00
Fix bugs in option processing and add cp/mv/rm support.
This commit is contained in:
parent
01882f5499
commit
b901fc5c0d
@ -32,7 +32,24 @@ elif [ "$1" == "get-or-generate" ] ; then
|
|||||||
nosymbols=$(echo "$3" | base64 -w 0)
|
nosymbols=$(echo "$3" | base64 -w 0)
|
||||||
echo "$cmd
|
echo "$cmd
|
||||||
$key
|
$key
|
||||||
$autogen" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage
|
$autogen
|
||||||
|
$nosymbols" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage
|
||||||
|
|
||||||
|
elif [ "$1" == "rm" ] ; then
|
||||||
|
cmd=$(echo "$1" | base64 -w 0)
|
||||||
|
key=$(echo "$2" | base64 -w 0)
|
||||||
|
echo "$cmd
|
||||||
|
$key" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage
|
||||||
|
|
||||||
|
elif [ "$1" == "mv" -o "$1" == "cp" ] ; then
|
||||||
|
cmd=$(echo "$1" | base64 -w 0)
|
||||||
|
key=$(echo "$2" | base64 -w 0)
|
||||||
|
newkey=$(echo "$3" | base64 -w 0)
|
||||||
|
force=$(echo "$4" | base64 -w 0)
|
||||||
|
echo "$cmd
|
||||||
|
$key
|
||||||
|
$newkey
|
||||||
|
$force" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage
|
||||||
|
|
||||||
elif [ "$1" == "insert" ] ; then
|
elif [ "$1" == "insert" ] ; then
|
||||||
|
|
||||||
|
68
bin/qvm-pass
68
bin/qvm-pass
@ -1,11 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TEMP=`getopt -o ?d:n:mfe -- "$@"`
|
|
||||||
force=0
|
|
||||||
multiline=0
|
|
||||||
echo=0
|
|
||||||
nosymbols=
|
|
||||||
eval set -- "$TEMP"
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@ -31,11 +25,23 @@ usage() {
|
|||||||
echo " during password generation."
|
echo " during password generation."
|
||||||
echo " insert [--echo,-e | --multiline,-m] [--force,-f] <key>"
|
echo " insert [--echo,-e | --multiline,-m] [--force,-f] <key>"
|
||||||
echo " Creates a key in the pass store."
|
echo " Creates a key in the pass store."
|
||||||
exit 0
|
echo " rm <key>"
|
||||||
|
echo " Removes a key from the pass store."
|
||||||
|
echo " cp [-f] <key> <newkey>"
|
||||||
|
echo " Copies a key to another key in the pass store,"
|
||||||
|
echo " optionally forcefully."
|
||||||
|
echo " mv [-f] <key> <newkey>"
|
||||||
|
echo " Moves a key to another key in the pass store,"
|
||||||
|
echo " optionally forcefully."
|
||||||
}
|
}
|
||||||
|
|
||||||
while true ; do
|
force=0
|
||||||
case "$1" in
|
multiline=0
|
||||||
|
echo=0
|
||||||
|
nosymbols=
|
||||||
|
|
||||||
|
while getopts :d:n:mfe? opt ; do
|
||||||
|
case "$opt" in
|
||||||
-d)
|
-d)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
"") shift 2 ;;
|
"") shift 2 ;;
|
||||||
@ -49,10 +55,15 @@ while true ; do
|
|||||||
force=1 ; shift ;;
|
force=1 ; shift ;;
|
||||||
-e)
|
-e)
|
||||||
echo=1 ; shift ;;
|
echo=1 ; shift ;;
|
||||||
"-?")
|
":")
|
||||||
usage ;;
|
echo "incorrect usage; run with -? for more information" ; exit 64 ;;
|
||||||
--) shift ; break ;;
|
"?")
|
||||||
*) echo "error processing options; run with -? for more information" ; exit 64 ;;
|
if [ "$OPTARG" != "?" ] ; then
|
||||||
|
usage ; exit 64 ;
|
||||||
|
else
|
||||||
|
usage ; exit 0 ;
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -65,7 +76,7 @@ case "$1" in
|
|||||||
echo "the $1 subcommand requires a key; run with -? for more information" >&2 ; exit 64
|
echo "the $1 subcommand requires a key; run with -? for more information" >&2 ; exit 64
|
||||||
fi
|
fi
|
||||||
if [ -n "$3" ] ; then
|
if [ -n "$3" ] ; then
|
||||||
echo "the $1 subcommand only accepts one argument; run with -? for more information" >&2 ; exit 64
|
echo "the $1 subcommand only accepts one argument; run with -? for more information" >&2 ; exit 64
|
||||||
fi
|
fi
|
||||||
exec qubes-pass-client "$1" "$2" "$nosymbols"
|
exec qubes-pass-client "$1" "$2" "$nosymbols"
|
||||||
;;
|
;;
|
||||||
@ -74,10 +85,37 @@ case "$1" in
|
|||||||
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
||||||
fi
|
fi
|
||||||
if [ -n "$2" ] ; then
|
if [ -n "$2" ] ; then
|
||||||
echo "the $1 subcommand does not accept any arguments; run with -? for more information" >&2 ; exit 64
|
echo "the $1 subcommand does not accept any arguments; run with -? for more information" >&2 ; exit 64
|
||||||
fi
|
fi
|
||||||
exec qubes-pass-client "$1"
|
exec qubes-pass-client "$1"
|
||||||
;;
|
;;
|
||||||
|
rm)
|
||||||
|
if [ "$force$multiline$echo$nosymbols" != "000" ] ; then
|
||||||
|
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
if [ -z "$2" ] ; then
|
||||||
|
echo "the $1 subcommand requires a key; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
exec qubes-pass-client "$1" "$2"
|
||||||
|
;;
|
||||||
|
mv)
|
||||||
|
if [ "$multiline$echo$nosymbols" != "000" ] ; then
|
||||||
|
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
if [ -z "$2" -o -z "$3" ] ; then
|
||||||
|
echo "the $1 subcommand requires two keys; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
exec qubes-pass-client "$1" "$2" "$3" "$force"
|
||||||
|
;;
|
||||||
|
cp)
|
||||||
|
if [ "$multiline$echo$nosymbols" != "000" ] ; then
|
||||||
|
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
if [ -z "$2" -o -z "$3" ] ; then
|
||||||
|
echo "the $1 subcommand requires two keys; run with -? for more information" >&2 ; exit 64
|
||||||
|
fi
|
||||||
|
exec qubes-pass-client "$1" "$2" "$3" "$force"
|
||||||
|
;;
|
||||||
insert)
|
insert)
|
||||||
if [ "$nosymbols" != "" ] ; then
|
if [ "$nosymbols" != "" ] ; then
|
||||||
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
echo "the $1 subcommand does not accept that option; run with -? for more information" >&2 ; exit 64
|
||||||
|
@ -83,4 +83,31 @@ elif [ "$cmd" == "insert" ] ; then
|
|||||||
echo "$contents" | pass insert -e --force -- "$entry"
|
echo "$contents" | pass insert -e --force -- "$entry"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
elif [ "$cmd" == "rm" ] ; then
|
||||||
|
|
||||||
|
read -n 4096 entry
|
||||||
|
entry=$(echo "$entry" | base64 -d)
|
||||||
|
|
||||||
|
logger -t ruddo.PassManage "removing password entry $entry"
|
||||||
|
|
||||||
|
pass rm -- "$entry"
|
||||||
|
|
||||||
|
elif [ "$cmd" == "mv" -o "$cmd" == "cp" ] ; then
|
||||||
|
|
||||||
|
read -n 4096 entry
|
||||||
|
entry=$(echo "$entry" | base64 -d)
|
||||||
|
read -n 4096 newentry
|
||||||
|
newentry=$(echo "$newentry" | base64 -d)
|
||||||
|
read -n 4096 force
|
||||||
|
force=$(echo "$force" | base64 -d)
|
||||||
|
if [ "$force" == "1" ] ; then
|
||||||
|
force=-f
|
||||||
|
else
|
||||||
|
force=
|
||||||
|
fi
|
||||||
|
|
||||||
|
logger -t ruddo.PassManage "$cmd password entry $entry to $entry"
|
||||||
|
|
||||||
|
pass "$cmd" $f -- "$entry" "$newentry"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user