You are not logged in.

#1 2022-01-16 20:45:27

herOldMan
Member
Registered: 2013-10-11
Posts: 127

[solved] msmtp password has a single quote

Hi,

(password example: Don'tTell)

So far, the only hack I have found uses an expect script, which seems a bit awkward.

Is there a way to escape the single quote in the password when it's provided in .msmtprc? (Bash escape fails.)

Alternatively, is there a way to pipe the password to the command from stdin, e.g., with printf "Don'tTell\n"

(The Gnome Keyring is not an option and .netrc is no longer functional.)

Last edited by herOldMan (2022-01-16 21:59:32)

Offline

#2 2022-01-16 21:04:14

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,002
Website

Re: [solved] msmtp password has a single quote

I strongly recommend that you use passwordeval. This will a) avoid the plaintext storage issue, and b) provide greater flexibility in terms of special characters that would ordinarily require shell escaping contortions.

Do you use a password manager?

Last edited by jasonwryan (2022-01-16 21:04:29)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Online

#3 2022-01-16 21:08:39

herOldMan
Member
Registered: 2013-10-11
Posts: 127

Re: [solved] msmtp password has a single quote

Hi,

No password manager on this system. No DE or DM either.

Offline

#4 2022-01-16 21:11:09

progandy
Member
Registered: 2012-05-17
Posts: 4,901

Re: [solved] msmtp password has a single quote

Just write the password without any escaping?
Or write it in another file and use passwordeval to read it, you could also encrypt/decrypt it that way (not too secure but maybe better than nothing).


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2022-01-16 21:54:16

herOldMan
Member
Registered: 2013-10-11
Posts: 127

Re: [solved] msmtp password has a single quote

Using the password with the single quote in the .msmtprc file results in a bad password error at the smtp server.

My eyes are failing me and I am unable to find an example showing how to use a plaintext file in conjunction with the passwordeval option (anywhere).

Here's what I tried:

I put the password in a file named pw

In my .msmtprc, I added the line:
passwordeval "~/pw"

here's what I get:
...
sh: -c: line 1: unexpected EOF while looking for matching `''
sh: -c: line 2: syntax error: unexpected end of file
msmtp: cannot read output of 'Don'tTell'

Offline

#6 2022-01-16 21:59:04

herOldMan
Member
Registered: 2013-10-11
Posts: 127

Re: [solved] msmtp password has a single quote

Hi,

Stupid me:

passwordeval "cat ~/pw"

Offline

#7 2022-01-16 21:59:23

ayekat
Member
Registered: 2011-01-17
Posts: 1,509
Website

Re: [solved] msmtp password has a single quote

passwordeval takes a command to execute, not a file to read. See the man page.

Typically people invoke their password manager in there, e.g.

passwordeval   "pass show mail/ayekat@mailserver.tld | head -n1"

But if you just want to read a plaintext file, you could just have that be "head -n1 ~/pw".

--edit: Ah, you noticed it. :-)

Last edited by ayekat (2022-01-16 22:01:04)


{,META,RE}PKGBUILDSpacman-hacks (includes makemetapkg and remakepkg) │ dotfiles

Offline

#8 2022-01-16 22:02:46

herOldMan
Member
Registered: 2013-10-11
Posts: 127

Re: [solved] msmtp password has a single quote

Thanks ayekat

Offline

Board footer

Powered by FluxBB