From b83180266fd35b30400ad26f34122ccb5e76a2ac Mon Sep 17 00:00:00 2001 From: kkoyung Date: Mon, 22 May 2023 19:33:32 +0800 Subject: [PATCH 1/6] Added option to provide self-signed certificate --- bin/mw | 11 +++++++++-- mw.1 | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/mw b/bin/mw index 81c75d9..5ed4377 100755 --- a/bin/mw +++ b/bin/mw @@ -214,7 +214,8 @@ getboxes() { if [ -n "${force+x}" ]; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" + [ ! -z "$sslcertself" ] && addarg="-k" + info="$(curl "$addarg" --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && errorexit mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi @@ -294,6 +295,7 @@ Options allowed with -a: -X Delete an account's local email too when deleting. -o Configure address, but keep mail online. -f Assume typical English mailboxes without attempting log-on. + -c Path to self-signed TLS certificate. NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. @@ -326,7 +328,7 @@ reorder() { ' "$tempfile" >>"$muttrc" } -while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:" o; do case "${o}" in +while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:c:" o; do case "${o}" in l) setact list ;; r) setact reorder1 ;; d) setact delete ;; @@ -393,6 +395,11 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:" o; do case "${o}" in setact add password="$OPTARG" ;; + c) + setact add + sslcertself="$OPTARG" + sslcert="$OPTARG" + ;; X) setact delete purge=True diff --git a/mw.1 b/mw.1 index 4a136ee..0e0f6ec 100644 --- a/mw.1 +++ b/mw.1 @@ -70,8 +70,12 @@ SMTP server port (assumed to be 465 if not specified) .TP .B -x Account password. You will be prompted for the password interactively if this option is not given. +.TP .B -P Pass Prefix. The password will be stored using pass at +.TP +.B -c certificate +Self-signed TLS certificate .SH OTHER OPTIONS .TP .B -f From 302ae135b292d049bcc6d8801d0d40114c630bab Mon Sep 17 00:00:00 2001 From: kkoyung Date: Tue, 23 May 2023 11:12:41 +0800 Subject: [PATCH 2/6] Refactor curl extra argument --- bin/mw | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/mw b/bin/mw index 5ed4377..3e0fbf3 100755 --- a/bin/mw +++ b/bin/mw @@ -214,8 +214,7 @@ getboxes() { if [ -n "${force+x}" ]; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else - [ ! -z "$sslcertself" ] && addarg="-k" - info="$(curl "$addarg" --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" + info="$(curl "$curlarg" --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && errorexit mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi @@ -397,8 +396,8 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:c:" o; do case "${o}" in ;; c) setact add - sslcertself="$OPTARG" sslcert="$OPTARG" + curlarg="$curlarg -k" ;; X) setact delete From 221ef0c4c167693079b80f3f857061c8ad36bee1 Mon Sep 17 00:00:00 2001 From: kkoyung Date: Tue, 23 May 2023 11:15:44 +0800 Subject: [PATCH 3/6] Updated man page --- mw.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mw.1 b/mw.1 index 0e0f6ec..22ebd7a 100644 --- a/mw.1 +++ b/mw.1 @@ -74,8 +74,8 @@ Account password. You will be prompted for the password interactively if this op .B -P Pass Prefix. The password will be stored using pass at .TP -.B -c certificate -Self-signed TLS certificate +.B -c path +Path to self-signed TLS certificate .SH OTHER OPTIONS .TP .B -f From 2b9770ee527fbdf4129e45defef31677f0b551fd Mon Sep 17 00:00:00 2001 From: kkoyung Date: Tue, 23 May 2023 11:18:47 +0800 Subject: [PATCH 4/6] Fixed indention --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mw b/bin/mw index 3e0fbf3..bf87d48 100755 --- a/bin/mw +++ b/bin/mw @@ -397,7 +397,7 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:c:" o; do case "${o}" in c) setact add sslcert="$OPTARG" - curlarg="$curlarg -k" + curlarg="$curlarg -k" ;; X) setact delete From 8a4c7ca9ae67c53c63ebcbbc25c0ecaa6d759044 Mon Sep 17 00:00:00 2001 From: kkoyung Date: Mon, 25 Dec 2023 21:04:53 +0800 Subject: [PATCH 5/6] Fixed "URL rejected: Malformed input to a URL function" issue --- bin/mw | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/mw b/bin/mw index bf87d48..9f44239 100755 --- a/bin/mw +++ b/bin/mw @@ -214,7 +214,9 @@ getboxes() { if [ -n "${force+x}" ]; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else - info="$(curl "$curlarg" --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" + [ -n "$sslcert" ] \ + && info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" \ + || info="$(curl -k --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && errorexit mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi @@ -397,7 +399,6 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:c:" o; do case "${o}" in c) setact add sslcert="$OPTARG" - curlarg="$curlarg -k" ;; X) setact delete From 96c4e85746901bb8a3aac99d4b97107d5c9bad4f Mon Sep 17 00:00:00 2001 From: Kingsley Yung Date: Mon, 25 Dec 2023 21:13:16 +0800 Subject: [PATCH 6/6] Fixed indentation --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/mw b/bin/mw index 94e3ea8..3effeea 100755 --- a/bin/mw +++ b/bin/mw @@ -209,8 +209,8 @@ getboxes() { mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else [ -n "$sslcert" ] \ - && info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" \ - || info="$(curl -k --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" + && info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" \ + || info="$(curl -k --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && errorexit mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi