providing imap_pass but not from ~/.muttrc
Cameron Simpson
cs at cskk.id.au
Thu Jun 13 21:52:02 UTC 2019
On 13Jun2019 14:26, Larry Rosenman <ler at lerctr.org> wrote:
>I do the following trick:
>
>source "gpg -q --textmode -d ~/.neomutt/passwords.gpg |"
>
>where the passwords.gpg file sets my_ vars for all my
>passwords.
Doesn't that require interaction on each mutt startup? I appreciate that
this has the password nicely encrypted when idle and doesn't display
them on the command line or in environment variables.
I've got various mail credentials in my .fetchmailrc (I now use getmail,
but whatever), so I've got scripts to fetch them from it. Should port it
to the getmail config some time.
So, the muttrc config line which presages accessing my phone IMAP
account:
source 'cs-mutt-imap-settings cs-iphone-cc'
cs-mutt-imap-settings is this script:
#!/bin/sh
#
# Read clause form .fetchmailrc, recite mutt IMAP settings.
# - Cameron Simpson <cs at cskk.id.au> 26sep2015
#
set -ue
clause=$1
shift
fetchmailclause "$clause" \
| awk '$1 == "user" { user=$2 }
$1 == "pass" { pass=$2 }
$1 == "via" { via=$2 }
END { print "set imap_user='\''" user "'\''"
print "set imap_pass='\''" pass "'\''"
print "set my_imap_host='\''" via "'\''"
}
'
and fetchmailclause is this script:
#!/bin/sh
#
# Pull out a single clause from a .fetchmailrc file.
# The parsing's a little simplistic but it works fairly well.
# - Cameron Simpson <cs at cskk.id.au> 09sep2003
#
rc=$HOME/.fetchmailrc
start=skip # vs poll
cmd=$0
usage="Usage: $cmd [-f fetchmailrc] [clause]"
badopts=
[ "x$1" = x-f ] && { rc=$2; shift; shift; }
[ $# = 0 ] && exec awk '$1 == "spoll" || $1 == "skip" { print $2 }' "$rc"
clause=$1; shift
[ $# = 0 ] || { echo "$cmd: extra arguments after clause: $*" >&2;
badopts=1; }
[ $badopts ] && { echo "$usage" >&2; exit 2; }
exec sed -ne '
y/ / /
s/$/ /
'" /^ *skip *$clause /b start
/^ *poll *$clause /b start
d
:start
n
y/ / /
s/ */ /g
s/^ //
s/ $//
/^#/b start
/^$/b start
/^skip /d
/^poll /d
p
b start" "$rc"
So if the OP already has the credentials sitting around elsewhere they
could automate getting them.
This approach does have the downside that credentials are still in files
in the clear though.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Mutt-users
mailing list