Browse Source

Merge pull request #858 from lokesh1197/master

pass: add feature to optionally add a prefix
pull/863/head
Luke Smith 2 years ago
committed by GitHub
parent
commit
fdaae49e21
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 13 deletions
  1. +16
    -13
      bin/mw
  2. +2
    -0
      mw.1

+ 16
- 13
bin/mw View File

@@ -43,7 +43,7 @@ host $smtp
port ${sport:-465} port ${sport:-465}
from $fulladdr from $fulladdr
user $login user $login
passwordeval \"pass $fulladdr\"
passwordeval \"pass $passprefix$fulladdr\"
auth ${auth:-on} auth ${auth:-on}
tls on tls on
tls_trust_file $sslcert tls_trust_file $sslcert
@@ -58,7 +58,7 @@ IMAPStore $fulladdr-remote
Host $imap Host $imap
Port ${iport:-993} Port ${iport:-993}
User $login User $login
PassCmd \"pass $fulladdr\"
PassCmd \"pass $passprefix$fulladdr\"
AuthMechs LOGIN AuthMechs LOGIN
SSLType ${imapssl:-IMAPS} SSLType ${imapssl:-IMAPS}
CertificateFile $sslcert CertificateFile $sslcert
@@ -87,7 +87,7 @@ tls on
user $login user $login
host $imap host $imap
delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX}
passwordeval pass $fulladdr
passwordeval pass $passprefix$fulladdr
" >> "$mpoprc" ;} " >> "$mpoprc" ;}


prepmutt() { echo "# vim: filetype=neomuttrc prepmutt() { echo "# vim: filetype=neomuttrc
@@ -128,7 +128,7 @@ getprofiles() { \
case "$type" in case "$type" in
online) folder="imaps://$login@$imap:${iport:-993}" online) folder="imaps://$login@$imap:${iport:-993}"
extra="set imap_user = \"$login\" extra="set imap_user = \"$login\"
set imap_pass = \"\`pass $fulladdr\`\"
set imap_pass = \"\`pass $passprefix$fulladdr\`\"
set ssl_starttls = yes set ssl_starttls = yes
set ssl_force_tls = yes" set ssl_force_tls = yes"
;; ;;
@@ -176,7 +176,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then
sed -ibu "/\([0-9]-\)\?$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu sed -ibu "/\([0-9]-\)\?$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu
pass rm -f "$fulladdr" >/dev/null 2>&1
pass rm -f "$passprefix$fulladdr" >/dev/null 2>&1
[ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}"


for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do
@@ -200,6 +200,7 @@ askinfo() { \
read -r smtp read -r smtp
[ "$sport" = 587 ] && tlsline="# tls_starttls" [ "$sport" = 587 ] && tlsline="# tls_starttls"
[ -z "$realname" ] && realname="${fulladdr%%@*}" [ -z "$realname" ] && realname="${fulladdr%%@*}"
[ -z "$passprefix" ] && passprefix=""
hostname="${fulladdr#*@}" hostname="${fulladdr#*@}"
login="${login:-$fulladdr}" login="${login:-$fulladdr}"
if [ -n "${password+x}" ]; then if [ -n "${password+x}" ]; then
@@ -209,17 +210,17 @@ askinfo() { \
fi fi
} }


createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr"
"$GPG" -qe $(printf -- " -r %s" $(cat "$PASSWORD_STORE_DIR/.gpg-id")) "$PASSWORD_STORE_DIR/$fulladdr"
rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;}
createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$passprefix$fulladdr"
"$GPG" -qe $(printf -- " -r %s" $(cat "$PASSWORD_STORE_DIR/.gpg-id")) "$PASSWORD_STORE_DIR/$passprefix$fulladdr"
rm -f "$PASSWORD_STORE_DIR/$passprefix$fulladdr" ;}


getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1
pass insert -f "$fulladdr" && break; done ;}
getpass() { while : ; do pass rm -f "$passprefix$fulladdr" >/dev/null 2>&1
pass insert -f "$passprefix$fulladdr" && break; done ;}


getboxes() { if [ -n "${force+x}" ] ; then getboxes() { if [ -n "${force+x}" ] ; then
mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")"
else else
info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$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}")"
[ -z "$info" ] && echo "Log-on not successful." && return 1 [ -z "$info" ] && echo "Log-on not successful." && return 1
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')"
fi fi
@@ -297,6 +298,7 @@ Options allowed with -a:
-s SMTP server address -s SMTP server address
-S SMTP server port -S SMTP server port
-x Password for account (recommended to be in double quotes) -x Password for account (recommended to be in double quotes)
-P Pass Prefix (prefix of the file where password is stored)
-p Add for a POP server instead of IMAP. -p Add for a POP server instead of IMAP.
-X Delete an account's local email too when deleting. -X Delete an account's local email too when deleting.
-o Configure address, but keep mail online. -o Configure address, but keep mail online.
@@ -305,7 +307,7 @@ Options allowed with -a:
NOTE: Once at least one account is added, you can run NOTE: Once at least one account is added, you can run
\`mbsync -a\` to begin downloading mail. \`mbsync -a\` to begin downloading mail.


To change an account's password, run \`pass edit your@email.com\`.
To change an account's password, run \`pass edit '$passprefix'your@email.com\`.
EOF EOF
} }


@@ -332,7 +334,7 @@ reorder() {
' "$tempfile" >> "$muttrc" ' "$tempfile" >> "$muttrc"
} }


while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:" o; do case "${o}" in
l) setact list || exit 1 ;; l) setact list || exit 1 ;;
r) setact reorder || exit 1 ;; r) setact reorder || exit 1 ;;
d) setact delete || exit 1 ;; d) setact delete || exit 1 ;;
@@ -346,6 +348,7 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
S) setact add || exit 1 ; sport="$OPTARG" ;; S) setact add || exit 1 ; sport="$OPTARG" ;;
u) setact add || exit 1 ; login="$OPTARG" ;; u) setact add || exit 1 ; login="$OPTARG" ;;
n) setact add || exit 1 ; realname="$OPTARG" ;; n) setact add || exit 1 ; realname="$OPTARG" ;;
P) setact add || exit 1 ; passprefix="$OPTARG" ;;
m) setact add || exit 1 ; maxmes="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;;
o) setact add || exit 1 ; type="online" ;; o) setact add || exit 1 ; type="online" ;;
p) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;; p) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;;


+ 2
- 0
mw.1 View File

@@ -70,6 +70,8 @@ SMTP server port (assumed to be 465 if not specified)
.TP .TP
.B -x .B -x
Account password. You will be prompted for the password interactively if this option is not given. Account password. You will be prompted for the password interactively if this option is not given.
.B -P
Pass Prefix. The password will be stored using pass at <passprefix><email>
.SH OTHER OPTIONS .SH OTHER OPTIONS
.TP .TP
.B -f .B -f


Loading…
Cancel
Save