mu-wizard

shell script to easily configure mu4e accounts on Emacs
git clone git://git.ckyln.com/mu-wizard
Log | Files | Refs | LICENSE

commit d56aa06a811ec789c0cc6fffc48f3e8f5ce81ba2
parent 48939cb7f0066fe8edab62a042591488a4f54795
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue,  1 Jun 2021 20:24:02 +0300

muw: handle issues where CA certificate files don't exist. Fixes #10

Diffstat:
Mbin/muw | 25+++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/bin/muw b/bin/muw @@ -434,7 +434,7 @@ msmtp_header() { defaults auth on tls on -tls_trust_file $sslcert +tls_trust_file $cacert logfile $XDG_CACHE_HOME/msmtp/msmtp.log EOF } @@ -513,7 +513,7 @@ Port $iport User $login PassCmd "$password_command" SSLType $ssltype -CertificateFile $sslcert +CertificateFile $cacert MaildirStore $title-local Subfolders Verbatim @@ -575,12 +575,25 @@ EOF } get_information() { - for file in /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt \ + + # Try to find a CA Certificate file. We want to prioritise the '$MUW_CACERT' + # variable here. + if [ "$MUW_CACERT" ]; then + cacert=$MUW_CACERT + else + for file in /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt \ /etc/certificates/cert.pem /etc/ssl/ca-bundle.pem /etc/ssl/cert.pem \ /etc/pki/tls/cacert.pem /usr/share/ca-certificates; do - [ -r "$file" ] || continue - sslcert=$file; break - done + [ -r "$file" ] || continue + cacert=$file; break + done + fi + + # If no certificate file was found, exit and notify the user. + [ -r "$cacert" ] || + die "No proper CA Certificate file could be found. There are numerous ways of" \ + "obtaining it, and those can differ for each distro. You can see the muw(1)"\ + "manual page to learn more." : "${fulladdr:=$(prompt_required Email \ "Insert the email address that you want to configure for mu4e")}"