diff options
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fetchmail.c b/fetchmail.c index f037d400..66f5043b 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -395,14 +395,25 @@ int main (int argc, char **argv) ctl->password = ctl->remotename; else { - /* look up the host and account in the .netrc file. */ - netrc_entry *p = search_netrc(netrc_list,ctl->server.pollname); + netrc_entry *p; + + /* look up the pollname and account in the .netrc file. */ + p = search_netrc(netrc_list, ctl->server.pollname); while (p && strcmp(p->account, ctl->remotename)) p = search_netrc(p->next, ctl->remotename); - /* if we find a matching entry with a password, use it */ if (p && p->password) ctl->password = xstrdup(p->password); + + /* otherwise try with "via" name if there is one */ + else if (ctl->server.via) + { + p = search_netrc(netrc_list, ctl->server.via); + while (p && strcmp(p->account, ctl->remotename)) + p = search_netrc(p->next, ctl->remotename); + if (p && p->password) + ctl->password = xstrdup(p->password); + } } if (ctl->server.protocol != P_ETRN && ctl->server.protocol != P_IMAP_K4 |