Fix bug in get-or-generate.

This commit is contained in:
Manuel Amador (Rudd-O) 2017-05-14 15:19:34 +00:00
parent d7fcf965a2
commit e2280ad7b8
3 changed files with 21 additions and 28 deletions

View File

@ -28,11 +28,9 @@ $key" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassRead
elif [ "$1" == "get-or-generate" ] ; then elif [ "$1" == "get-or-generate" ] ; then
cmd=$(echo "$1" | base64 -w 0) cmd=$(echo "$1" | base64 -w 0)
key=$(echo "$2" | base64 -w 0) key=$(echo "$2" | base64 -w 0)
autogen=$(echo 1 | base64 -w 0)
nosymbols=$(echo "$3" | base64 -w 0) nosymbols=$(echo "$3" | base64 -w 0)
echo "$cmd echo "$cmd
$key $key
$autogen
$nosymbols" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage $nosymbols" | /usr/lib/qubes/qrexec-client-vm "$QUBES_PASS_DOMAIN" ruddo.PassManage
elif [ "$1" == "rm" ] ; then elif [ "$1" == "rm" ] ; then

View File

@ -37,34 +37,29 @@ EOF
elif [ "$cmd" == "get-or-generate" ] ; then elif [ "$cmd" == "get-or-generate" ] ; then
read -n 4096 entry read -n 4096 entry
read -n 4096 autogen
read -n 4096 nosymbols read -n 4096 nosymbols
entry=$(echo "$entry" | base64 -d) entry=$(echo "$entry" | base64 -d)
nosymbols=$(echo "nosymbols" | base64 -d) nosymbols=$(echo "$nosymbols" | base64 -d)
if [ "$autogen" == "1" ] ; then ret=0 ; out=$(pass -- "$entry" 2>&1) || ret=$?
ret=0 ; out=$(pass -- "$entry" 2>&1) || ret=$? if [ "$ret" == "1" ] && echo "$out" | grep -q "not in the password store" ; then
if [ "$ret" == "1" ] && echo "$out" | grep -q "not in the password store" ; then logger -t ruddo.PassManage "creating password entry $entry"
logger -t ruddo.PassManage "creating password entry $entry" ret=0
ret=0 if [ "$nosymbols" != "" ] ; then
if [ "$nosymbols" != "" ] ; then out=$(pass generate -n "$nosymbols" -- "$entry" 32) || ret=$?
out=$(pass generate -n "$nosymbols" -- "$entry" 32) || ret=$? else
else out=$(pass generate -- "$entry" 32) || ret=$?
out=$(pass generate -- "$entry" 32) || ret=$? fi
fi if [ "$ret" == "1" ] ; then
if [ "$ret" == "1" ] ; then echo "Password generation failed: $out"
echo "Password generation failed: $out" exit "$ret"
exit "$ret" fi
fi elif [ "$ret" != "0" ] ; then
elif [ "$ret" != "0" ] ; then echo "$out" >&2
echo "$out" >&2 exit "$ret"
exit "$ret"
fi
logger -t ruddo.PassManage "requested password entry $entry"
exec pass -- "$entry"
else
exit 23
fi fi
logger -t ruddo.PassManage "requested password entry $entry"
exec pass -- "$entry"
elif [ "$cmd" == "insert" ] ; then elif [ "$cmd" == "insert" ] ; then

View File

@ -3,7 +3,7 @@
%define mybuildnumber %{?build_number}%{?!build_number:1} %define mybuildnumber %{?build_number}%{?!build_number:1}
Name: qubes-pass Name: qubes-pass
Version: 0.0.8 Version: 0.0.9
Release: %{mybuildnumber}%{?dist} Release: %{mybuildnumber}%{?dist}
Summary: Inter-VM pass password management for Qubes OS AppVMs and StandaloneVMs Summary: Inter-VM pass password management for Qubes OS AppVMs and StandaloneVMs
BuildArch: noarch BuildArch: noarch