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 eeba4d9579a93e077db30d81df1c6cf782b282eb
parent 932cefafefbd34efcb4e73fb8cac7c58dbc26111
Author: Jaromil <jaromil@dyne.org>
Date:   Sun, 13 Mar 2016 19:57:50 +0100

Merge pull request #21 from parazyd/master

another keyring, build fixes
Diffstat:
M.gitignore | 2+-
Mbuild/build-gnu.sh | 13+------------
Msrc/jaro | 31++++++++++++++++++-------------
Msrc/zlibs/accounts | 4++--
Msrc/zlibs/email | 2+-
Msrc/zlibs/filters | 6+++++-
Msrc/zlibs/imap | 2+-
Msrc/zlibs/keyring | 22++++++++++++++++------
8 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -6,7 +6,7 @@ dotlock fetchaddr fetchdate -pgpewrap +gpgewrap src/mairix/Makefile src/mairix/config.log src/mairix/mairix diff --git a/build/build-gnu.sh b/build/build-gnu.sh @@ -34,7 +34,7 @@ debian_req() { debian) deps=(fetchmail msmtp mutt pinentry-curses) deps+=(wipe notmuch sqlite3 alot abook elinks) - deps+=(gcc make libglib2.0-dev libgnome-keyring-dev) + deps+=(gcc make libglib2.0-dev) print "Building on Debian" print "Checking software to install" @@ -127,17 +127,6 @@ debian_req() { } -{ test "$target" = "gnome-keyring" } || { - test "$target" = "all" } && { - print -n "Compiling gnome-keyring... " - pushd src/gnome-keyring - ${=cc} jaro-gnome-keyring.c -o jaro-gnome-keyring \ - `pkg-config --cflags --libs glib-2.0 gnome-keyring-1` - popd - cp src/gnome-keyring/jaro-gnome-keyring build/gnu/ - print OK -} - # build mixmaster only if specified { test "$target" = "mixmaster" } && { print "Compiling Mixmaster (anonymous remailer)" diff --git a/src/jaro b/src/jaro @@ -22,8 +22,8 @@ # this source code; if not, write to: # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -VERSION=4.0 -DATE=Nov/2015 +VERSION=4.1 +DATE=Mar/2016 JAROMAILEXEC=$0 # default permission on files @@ -76,13 +76,13 @@ source $WORKDIR/zlibs/zuper # simplifying modes of operation: GNU or MAC case $(uname -o) in GNU/Linux) OS=GNU - notice "Jaro Mail v$VERSION running on GNU/Linux" ;; + notice "Jaro Mail v${VERSION} running on GNU/Linux" ;; Darwin) OS=MAC - notice "Jaro Mail v$VERSION running on Mac/OSX" ;; + notice "Jaro Mail v${VERSION} running on Mac/OSX" ;; Cygwin) OS=WIN - notice "Jaro Mail v$VERSION runing on MS/Win" ;; + notice "Jaro Mail v${VERSION} runing on MS/Win" ;; *) OS=GNU # default error "Running on an unknown operating system, assuming GNU" ;; @@ -98,7 +98,8 @@ DRYRUN=${DRYRUN:-0} CALLMUTT=${CALLMUTT:-1} # use gnome-keyring for passwords on GNU systems -vars+=(GNOMEKEY SECRET_TOOL) +vars+=(PASS GNOMEKEY SECRET_TOOL) +PASS=${PASS:-0} GNOMEKEY=${GNOMEKEY:-0} SECRET_TOOL=${SECRET_TOOL:-0} @@ -250,7 +251,7 @@ hostname=$(hostname) # gather the current hostname { test -d "$ACCOUNTS" } || { ${=mkdir} "$ACCOUNTS" } # make sure we have a local keyring in case system-wide not found - { test -r "$KEYRING" } || { create_keyring "$KEYRING" } + # { test -r "$KEYRING" } || { create_keyring "$KEYRING" } # make sure we have an addressbook [[ -r "$ADDRESSBOOK" ]] || { create_addressbook "$ADDRESSBOOK" } @@ -353,8 +354,12 @@ check_bin() { func "Notmuch binary: `command -v notmuch`" func "Alot binary: `command -v alot`" + # check for pass, else fallback + if isfound pass; then + export PASSWORD_STORE_DIR=$JAROMAILDIR/.pass + PASS=1 # check if secret-tool is present else fallback to gnome-keyring - if isfound secret-tool; then + elif isfound secret-tool; then SECRET_TOOL=1 else ps ax | grep '[g]nome-keyring-daemon' > /dev/null @@ -467,14 +472,14 @@ typeset -A subcommands_opts main() { ### Options configuration - #Hi, dear developer! Are you trying to add a new subcommand, or to add some options? - #Well, keep in mind that: + # Hi, dear developer! Are you trying to add a new subcommand, or to add some options? + # Well, keep in mind that: # 1. An option CAN'T have differente meanings/behaviour in different subcommands. # For example, "-s" means "size" and accept an argument. If you are tempted to add # an option "-s" (that means, for example "silent", and doesn't accept an argument) -# DON'T DO IT! - # There are two reasons for that: - # I. usability; user expect that "-s" is "size + # DON'T DO IT! + # There are two reasons for that: + # I. usability; user expect that "-s" is "size # II. Option parsing WILL EXPLODE if you do this kind of bad things # (it will say "option defined more than once, and he's right) main_opts=(a: -account=a l: -list=l q -quiet=q D -debug=D h -help=h v -version=v n -dry-run=n f -force=f) diff --git a/src/zlibs/accounts b/src/zlibs/accounts @@ -87,8 +87,8 @@ read_account() { { test -z $email } && { email="$login" } # so if one is specified, deduce the other { test -z $transport } && { transport=TLS1 } { test -z $certfile } && { certfile="" } - { test -z $imap_port } && { imap_port=143 } - { test -z $smtp_port } && { smtp_port=25 } + { test -z $imap_port } && { imap_port=993 } + { test -z $smtp_port } && { smtp_port=587 } { test -z $auth } && { auth=plain } { test -z $cert } && { cert=ignore } diff --git a/src/zlibs/email b/src/zlibs/email @@ -62,7 +62,7 @@ queue() { # pre-processing of the email headers awk ' -/User-Agent:/ { print "User-Agent: Jaro Mail <http://jaromail.dyne.org>"; next } +/User-Agent:/ { print "User-Agent: Jaro Mail <https://www.dyne.org/software/jaromail>"; next } { print $0 } ' > "$tmpqueue" [[ $? = 0 ]] || { error "Error queing email from stdin into outbox"; return 1 } diff --git a/src/zlibs/filters b/src/zlibs/filters @@ -54,6 +54,10 @@ init_inbox() { maildirmake "$MAILDIRS/remember" maildirmake "$MAILDIRS/outbox" + if [[ $PASS = 1 ]]; then + GPGID=${$(awk '/default-key/ { print $2 }' $HOME/.gnupg/gpg.conf)} + pass init ${GPGID} + fi ${=mkdir} "$MAILDIRS/cache" ${=mkdir} "$MAILDIRS/logs" ${=mkdir} "$MAILDIRS/tmp" @@ -223,7 +227,7 @@ filter_maildir() { return 1 } - notice "Filtering maildir: $mdinput ($numm mails}" + notice "Filtering maildir: $mdinput ($numm mails)" c=0 for m in ${(f)mails}; do diff --git a/src/zlibs/imap b/src/zlibs/imap @@ -32,7 +32,7 @@ run_imap_query() { nc ${imap} ${imap_port} -q 10 2>&1 elif [ "$_trans" = "tls" ]; then func "running tls imap query via openssl, encrypted" - openssl s_client -quiet -connect ${imap}:${imap_port} 2>&1 + openssl s_client -crlf -quiet -connect ${imap}:${imap_port} 2>&1 elif [ "$_trans" = "ssl" ]; then func "running ssl imap query via openssl, encrypted" openssl s_client -starttls imap -quiet -connect ${imap}:${imap_port} 2>&1 diff --git a/src/zlibs/keyring b/src/zlibs/keyring @@ -62,17 +62,17 @@ ask_password() { ;; ##################################### GNU) - - if [[ $SECRET_TOOL = 1 ]]; then - + if [[ $PASS = 1 ]]; then + act "looking for password in password-store" + password=`pass show ${login}` + [[ $? = 0 ]] && act "password found in password-store" + elif [[ $SECRET_TOOL = 1 ]]; then act "looking for password in secret-tool" password=`secret-tool lookup protocol email username "$login" host "$host"` [[ $? = 0 ]] && act "saved password found in keyring" - elif [ "$GNOMEKEY" = "1" ]; then act "looking for password in Gnome keyring" func "path: jaromail/${login}/${host}" - print "protocol=email\npath=jaromail/${login}/${host}\nusername=${login}\nhost=${host}\n\n" \ | "$WORKDIR/bin/jaro-gnome-keyring" check [[ $? = 0 ]] && { @@ -130,8 +130,18 @@ new_password() { ;; GNU) + # USE PASS + if [[ $PASS = 1 ]]; then + act "using pass for password-store" + print "$password\n" | pass insert -e ${login} + if [[ $? = 0 ]]; then + notice "New password saved in password-store" + else + error "Error saving password in password-store" + fi + # USE GNOME KEYRING - if [[ $SECRET_TOOL = 1 ]]; then + elif [[ $SECRET_TOOL = 1 ]]; then act "using secret-tool password storage" print -n - $password \ | secret-tool store --label "jaromail stored password" \