aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmail.c
diff options
context:
space:
mode:
Diffstat (limited to 'fetchmail.c')
-rw-r--r--fetchmail.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/fetchmail.c b/fetchmail.c
index 3d0c81b2..faaf52f4 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -510,22 +510,30 @@ int main(int argc, char **argv)
for (ctl = querylist; ctl; ctl = ctl->next)
{
if (ctl->active && !(implicitmode && ctl->server.skip)
- && ctl->server.protocol != P_ETRN
- && ctl->server.protocol != P_IMAP_K4
+ && ctl->server.protocol != P_ETRN
+ && ctl->server.protocol != P_IMAP_K4
#ifdef GSSAPI
- && ctl->server.protocol != P_IMAP_GSS
+ && ctl->server.protocol != P_IMAP_GSS
#endif /* GSSAPI */
- && !ctl->password)
- {
- char* password_prompt = _("Enter password for %s@%s: ");
-
- xalloca(tmpbuf, char *, strlen(password_prompt) +
- strlen(ctl->remotename) +
- strlen(ctl->server.pollname) + 1);
- (void) sprintf(tmpbuf, password_prompt,
- ctl->remotename, ctl->server.pollname);
- ctl->password = xstrdup((char *)getpassword(tmpbuf));
- }
+ && !ctl->password)
+ if (!isatty(0))
+ {
+ fprintf(stderr,
+ _("fetchmail: can't find a password for %s@s.\n"),
+ ctl->remotename, ctl->server.pollname);
+ return(PS_AUTHFAIL);
+ }
+ else
+ {
+ char* password_prompt = _("Enter password for %s@%s: ");
+
+ xalloca(tmpbuf, char *, strlen(password_prompt) +
+ strlen(ctl->remotename) +
+ strlen(ctl->server.pollname) + 1);
+ (void) sprintf(tmpbuf, password_prompt,
+ ctl->remotename, ctl->server.pollname);
+ ctl->password = xstrdup((char *)getpassword(tmpbuf));
+ }
}
/*