[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [msmtp-users] Not specifying password in .msptprc breaks sendmail-mode behavior



Hi!

On Thu, 01. May 2008, 23:26:33 +0200, Karol Lewandowski wrote:
> I've recently hit following problem -- if one omits password
> field in .msmtprc and doesn't have .netrc nor keychain then
> msmtp tries to read password from stdin.  Problem is, that
> usually stdin might (and usually does) contain mail itself.
> 
> Here's where fun begins:
>  - if msmtp is run from terminal, getpass() opens /dev/tty
>    and reads password from there,
>  - otherwise password is read from stdin, namely first line
>    of mail message is used as password.
> (At least this is what I've been able to understand from short
> look at the code.)

You're right, msmtp should not read a password from stdin, because it
reads the mail from there.

> IMHO "ideal" would be if msmtp would ask for the password
> after reading mail from stdin, but that's not as simple as I hoped.
> msmtp starts smtp session before reading mail from stdin, which
> is great as it doesn't need to keep entire mail in memory, but
> gives us problem just as decribed.

I don't think it is possible to distinguish between a password and the
mail on stdin.

I changed the code to only use getpass() if we're sure that it can read
from a controlling terminal and not from stdin. If there's no
controlling terminal and no password can be found elsewhere, msmtp
simply reports an authentication failure.

The change is in CVS now. Thanks for the report!

Martin