From c5cd2b6a8da9894e155ce8c306cf5b59d8a1b87e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 24 Sep 2020 14:22:03 +0200 Subject: [PATCH] mail: Enable direct pgp decryption When called over systemd, pass will not display a pin-entry field to decrypt the necessary passwords for email synching. This prepares automatic background synching. --- mail/.config/imapfilter/accounts.lua | 4 ++-- mail/.config/imapfilter/config.lua | 10 +++++----- mail/.config/isync/mbsyncrc | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mail/.config/imapfilter/accounts.lua b/mail/.config/imapfilter/accounts.lua index 8b92663..faa2141 100644 --- a/mail/.config/imapfilter/accounts.lua +++ b/mail/.config/imapfilter/accounts.lua @@ -1,7 +1,7 @@ local accounts = {} -local status, gmailuser = pipe_from('pass show misc/aerc-gmail-app-password | grep username | cut -d: -f2') -local status, gmailpass = pipe_from('pass show misc/aerc-gmail-app-password | head -n1') +local status, gmailuser = pipe_from('gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode ask ~/.local/share/pass/misc/aerc-gmail-app-password.gpg | grep username | cut -d: -f2') +local status, gmailpass = pipe_from('gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode ask ~/.local/share/pass/misc/aerc-gmail-app-password.gpg | head -n1') -- Setup an imap account called gmail accounts.gmail = IMAP { server = "imap.gmail.com", diff --git a/mail/.config/imapfilter/config.lua b/mail/.config/imapfilter/config.lua index 80a58e6..410df25 100644 --- a/mail/.config/imapfilter/config.lua +++ b/mail/.config/imapfilter/config.lua @@ -19,6 +19,11 @@ CONTINUOUS=false -- only used in case server does not support IDLE mode UPDATE_TIME=120 +-- implement simple wait function in case server does not support IDLE mode +function sleep(n) + os.execute("sleep " .. tonumber(n)) +end + -- will set filters to be grabbed from XDG-compliant filter directory -- can be overridden with env var IMAPFILTER_FILTERDIR function getConfigDir() @@ -63,11 +68,6 @@ assert(configDir, "No configuration directory found. Ensure " .. os.getenv("HOME accounts = loadfile(configDir .. "/accounts.lua")() assert(accounts, "No accounts configured. Ensure accounts.lua exists and returns a table of accounts.") --- implement simple wait function in case server does not support IDLE mode -function sleep(n) - os.execute("sleep " .. tonumber(n)) -end - -- immediately act on the filters once applyFilters(getFilterDir()) diff --git a/mail/.config/isync/mbsyncrc b/mail/.config/isync/mbsyncrc index 75ed2a6..9429f5d 100644 --- a/mail/.config/isync/mbsyncrc +++ b/mail/.config/isync/mbsyncrc @@ -3,8 +3,8 @@ IMAPAccount gmail # Address to connect to Host imap.gmail.com -UserCmd "pass show misc/aerc-gmail-app-password | grep username | cut -d: -f2" -PassCmd "pass show misc/aerc-gmail-app-password | head -n1" +UserCmd "gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode ask ~/.local/share/pass/misc/aerc-gmail-app-password.gpg | grep username | cut -d: -f2" +PassCmd "gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode ask ~/.local/share/pass/misc/aerc-gmail-app-password.gpg | head -n1" # To store the password in an encrypted file use PassCmd instead of Pass # PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.mailpass.gpg" # @@ -25,7 +25,7 @@ Inbox ~/documents/mail/Inbox # define generous maximum size to store locally MaxSize 50M -Channel gmail-general +Channel gmail Far :gmail-remote: Near :mail-local: # Exclude everything under the internal [Gmail] folder, except the interesting folders