doy / rbw

unofficial bitwarden cli
https://git.tozt.net/rbw
Other
611 stars 84 forks source link

rbw: permission denied when using it in msmtp "passwordeval" configuration #86

Closed xluthi closed 2 years ago

xluthi commented 2 years ago

I'm using msmtp to send email from my Debian machine via my remote SMTP server that requires authentication. Msmtp allows to have a command launched to get the password, thanks to his passwordeval directive. It works with gpg with specific options (--quiet --no-tty), but it doesn't work with rbw:

$ echo "test" | msmtp -a default xavier@example.org
sh: 1: rbw: Permission denied
msmtp: cannot read output of 'rbw get mail.example.org xavier@example.org'

My passwordeval directive in ~/.msmtprc is trivial: passwordeval "rbw get mail.example.org xavier@example.org".

I suspect an issue with the way rbw is managing stdin, especially because there is a specific warning in msmtp man page about passwordeval:

‘passwordeval [eval]’

Set the password for authentication to the output (stdout) of the command eval. This can be used e.g. to decrypt password files on the fly or to query key rings, and thus to avoid storing cleartext passwords.
Note that the eval command must not mess with standard input (stdin) because that is where msmtp reads the mail from. If in doubt, append < /dev/null to eval.

Do you have any clue to make rbw work seamlessly with msmtp ?

Thanks a lot!

PS: rbw 1.4.3 - works perfectly from the CLI, or with mbsync/isync with PassCmd

xluthi commented 2 years ago

I've found the solution myself: I had to look at msmtp side and not rbw :-)

The issue is coming from an over-restrictive appArmor profile for msmtp on Debian. See https://github.com/marlam/msmtp-mirror/issues/26#issuecomment-659176404.