diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | driver.c | 10 | ||||
-rw-r--r-- | fetchmail.c | 4 | ||||
-rw-r--r-- | fetchmail.h | 4 | ||||
-rw-r--r-- | fetchmail.man | 16 | ||||
-rw-r--r-- | rcfile_l.l | 3 | ||||
-rw-r--r-- | rcfile_y.y | 5 | ||||
-rw-r--r-- | sample.rcfile | 2 |
8 files changed, 40 insertions, 6 deletions
@@ -10,6 +10,8 @@ features -- * Automatic parsing of ~/.netrc for a mailserver password if necessary, thanks to Gordon Matzigkeit. +* Added preconnect option for initializing ssh connections. + * More FAQ material on how and when to use --interface. bugs -- @@ -898,7 +898,15 @@ const struct method *proto; /* protocol method table */ { char buf [POPBUFSIZE+1]; int *msgsizes, len, num, count, new, deletions = 0; - FILE *sockfp; + FILE *sockfp; + /* execute pre-initialization command, if any */ + if (ctl->preconnect[0] && (ok = system(ctl->preconnect))) + { + sprintf(buf, "pre-connection command failed with status %d", ok); + error(0, 0, buf); + ok = PS_SYNTAX; + goto closeUp; + } /* open a socket to the mail server */ if ((sockfp = SockOpen(ctl->servernames->id, diff --git a/fetchmail.c b/fetchmail.c index e21b7b65..7925f38d 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -861,6 +861,10 @@ void dump_params (struct query *ctl) printf(" Messages will be delivered with '%s.'\n", visbuf(ctl->mda)); else printf(" Messages will be SMTP-forwarded to '%s'.\n", visbuf(ctl->smtphost)); + if (ctl->preconnect[0]) + printf(" Server connection will be preinitialized with '%s.'\n", visbuf(ctl->preconnect)); + else if (outlevel == O_VERBOSE) + printf(" No preinitialization command.\n"); if (!ctl->localnames) printf(" No localnames declared for this host.\n"); else diff --git a/fetchmail.h b/fetchmail.h index 7b194c24..bced71ba 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -25,6 +25,7 @@ #define DIGESTLEN 33 /* length of MD5 digest */ #define MDALEN 256 /* length of delivery agent command */ #define IDLEN 128 /* length of UIDL message ID */ +#define CMDLEN 128 /* length of initialization command */ /* exit code values */ #define PS_SUCCESS 0 /* successful receipt of messages */ @@ -74,9 +75,10 @@ struct query /* per-user data */ char remotename [USERNAMELEN+1]; char password [PASSWORDLEN+1]; - char mailbox [FOLDERLEN]; + char mailbox [FOLDERLEN+1]; char smtphost[HOSTLEN+1]; char mda [MDALEN+1]; + char preconnect [CMDLEN+1]; /* per-user control flags */ int keep; diff --git a/fetchmail.man b/fetchmail.man index 03fa6b52..3daff8c6 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -530,6 +530,7 @@ Legal user options are remotefolder (or remote) smtphost (or smtp) mda + preconnect keep flush fetchall @@ -540,9 +541,11 @@ Legal user options are norewrite limit fetchlimit + syslog .PP All options correspond to the obvious command-line arguments except -four: `aka', `is', `to', `password', and `envelope'. +the following: `aka', `is', `to', `password', `envelope', +`preconnect', and `syslog'. .PP The `aka' option is for use with multidrop mailboxes. It allows you to pre-declare a list of DNS aliases for a server. This is an @@ -578,9 +581,16 @@ recipient is the calling user. The \fBpassword\fR option requires a string argument, which is the password to be used with the entry's server. .PP -The \fBaliases\fR option declares names that are recognized as OK for +The \fBaka\fR option declares names that are recognized as OK for local delivery. Your local name is automatically one of these; the -aliases directive can be used to declare others. +aka directive can be used to declare others. +.PP +The `preconnect' keyword allows you to specify a shell command to be +executed just before each time +.I fetchmail +establishes a mailserver connection. This may be useful if you are +attempting to set up secure POP connections with the aid of +.IR ssh (1). .PP Legal protocol identifiers are @@ -25,6 +25,7 @@ fetchlimit { return FETCHLIMIT; } logfile { return LOGFILE; } interface { return INTERFACE; } monitor { return MONITOR; } + defaults { return DEFAULTS; } server { return POLL; } poll { return POLL; } @@ -42,6 +43,8 @@ pass(word)? { return PASSWORD; } remote(folder)? { return FOLDER; } smtp(host)? { return SMTPHOST; } mda { return MDA; } +pre(connect) { return PRECONNECT; } + is { return IS; } here { return HERE; } there { return THERE; } @@ -42,7 +42,7 @@ static void prc_reset(); } %token DEFAULTS POLL SKIP AKA PROTOCOL AUTHENTICATE TIMEOUT KPOP KERBEROS -%token ENVELOPE USERNAME PASSWORD FOLDER SMTPHOST MDA LIMIT +%token ENVELOPE USERNAME PASSWORD FOLDER SMTPHOST MDA PRECONNECT LIMIT %token IS HERE THERE TO MAP WILDCARD %token SET BATCHLIMIT FETCHLIMIT LOGFILE INTERFACE MONITOR %token <proto> PROTO @@ -167,6 +167,7 @@ user_option : TO localnames HERE | FOLDER STRING {strcpy(current.mailbox, $2);} | SMTPHOST STRING {strcpy(current.smtphost, $2);} | MDA STRING {strcpy(current.mda, $2);} + | PRECONNECT STRING {strcpy(current.preconnect, $2);} | KEEP {current.keep = ($1==FLAG_TRUE);} | FLUSH {current.flush = ($1==FLAG_TRUE);} @@ -319,6 +320,7 @@ static void prc_register(void) STR_FORCE(mailbox, FOLDERLEN); STR_FORCE(smtphost, HOSTLEN); STR_FORCE(mda, MDALEN); + STR_FORCE(preconnect, CMDLEN); #undef STR_FORCE #define FLAG_FORCE(fld) if (cmd_opts.fld) current.fld = cmd_opts.fld @@ -349,6 +351,7 @@ void optmerge(struct query *h2, struct query *h1) STR_MERGE(mailbox, FOLDERLEN); STR_MERGE(smtphost, HOSTLEN); STR_MERGE(mda, MDALEN); + STR_MERGE(preconnect, CMDLEN); #undef STR_MERGE #define FLAG_MERGE(fld) if (!h2->fld) h2->fld = h1->fld diff --git a/sample.rcfile b/sample.rcfile index a01180fc..b126b2f0 100644 --- a/sample.rcfile +++ b/sample.rcfile @@ -34,6 +34,8 @@ # password (or pass) -- must be followed by a password string # smtphost (or smtp) -- must be followed by a host name # mda -- must be followed by an MDA command string +# preconnect (or pre) -- must be followed by an initialization command +# # keep # flush # fetchall |