jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit c9b3531e83455ab729a223f6a2510e21b4102dbe
parent 16b9f5fedf4b48aac7121333e1dafda715ae1d76
Author: Jaromil <jaromil@dyne.org>
Date:   Mon,  4 Jun 2012 16:08:15 +0200

should function without gnome-keyring (to be tested)

Diffstat:
Msrc/jaro | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 62 insertions(+), 24 deletions(-)

diff --git a/src/jaro b/src/jaro @@ -153,6 +153,16 @@ ${=mkdir} "$WORKDIR/certs" PROCMAILDIR=$WORKDIR/.procmail MUTTDIR=$WORKDIR/.mutt + +# use gnome-keyring for passwords on GNU systems +GNOMEKEY=0 +pidof gnome-keyring-daemon > /dev/null +{ test $? = 0 } && { + which jaro-gnome-keyring > /dev/null + { test $? = 0 } && { GNOMEKEY=1 } +} + + cleanexit() { func "Clean exit procedures" for f in `ls $TMPDIR/ | grep -v '.lock$'`; do @@ -272,17 +282,29 @@ ask_password() { ;; ##################################### GNU) - func "Looking for password in keyring: $1 @ $2" - echo "protocol=${type}\npath=jaromail/${email}\nusername=${login}\nhost=${host}\n\n" | $WORKDIR/bin/jaro-gnome-keyring check - if [ $? != 0 ]; then # its a new password - new_password - { test $? = 0 } && { - error "Password input aborted." - return 1 } - else # password found into gnome keyring - act "Using saved password for $1 @ $2" - password=`echo "protocol=${type}\npath=jaromail/${email}\nusername=${login}\nhost=${host}\n\n" | $WORKDIR/bin/jaro-gnome-keyring get` - fi + func "Looking for password in keyring: $name" + ################### + # USE GNOME KEYRING + { test $GNOMEKEY = 1 } && { + echo "protocol=${type}\npath=jaromail/${email}\nusername=${login}\nhost=${host}\n\n" \ + | $WORKDIR/bin/jaro-gnome-keyring check + if [ $? != 0 ]; then # its a new password + new_password + { test $? = 0 } && { + error "Password input aborted." + return 1 } + else # password found into gnome keyring + act "Using saved password for $1 @ $2" + password=`echo "protocol=${type}\npath=jaromail/${email}\nusername=${login}\nhost=${host}\n\n" | $WORKDIR/bin/jaro-gnome-keyring get` + fi + return 0 + } + #################### + # USE PINENTRY ALONE + new_password + { test $? = 0 } && { + error "Password input aborted." + return 1 } return 0 ;; *) @@ -320,31 +342,47 @@ new_password() { fi ;; GNU) - if [ "$password" != "" ]; then - cat <<EOF | $WORKDIR/bin/jaro-gnome-keyring store + if [ "$password" != "" ]; then # password was written + + # USE GNOME KEYRING + { test $GNOMEKEY = 1 } && { + + cat <<EOF | $WORKDIR/bin/jaro-gnome-keyring store protocol=${type} path=jaromail/${email} username=${login} host=${host} password=${password} EOF - { test $? != 0 } && { - unset password - error "Error saving password in Gnome keyring" - return 1 } + { test $? != 0 } && { + unset password + error "Error saving password in Gnome keyring" + return 1 } + return 0 + } + return 0 - else - cat <<EOF | $WORKDIR/bin/jaro-gnome-keyring erase + + else # password is blank or aborted + + # USE GNOME KEYRING + { test $GNOMEKEY = 1 } && { + + cat <<EOF | $WORKDIR/bin/jaro-gnome-keyring erase protocol=${type} path=jaromail/${email} username=${login} host=${host} EOF - { test $? != 0 } && { - error "Error accessing password in Gnome keyring" - return 1 } - act "No new password given, old password erased." - return 0 + { test $? != 0 } && { + error "Error accessing password in Gnome keyring" + return 1 } + act "No new password given, old password erased." + return 0 + } + + return 1 + fi ;; *)