diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2002-09-04 14:20:29 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2002-09-04 14:20:29 +0000 |
commit | 1a2f7c37e7e368e749caafbb950c605cbd6dc822 (patch) | |
tree | 36abd90ebf1e9d29b6f46d013adfdff37b0ace0f /rcfile_y.y | |
parent | 908b92d7ff4ad571963b71cf16518e7493571770 (diff) | |
download | fetchmail-1a2f7c37e7e368e749caafbb950c605cbd6dc822.tar.gz fetchmail-1a2f7c37e7e368e749caafbb950c605cbd6dc822.tar.bz2 fetchmail-1a2f7c37e7e368e749caafbb950c605cbd6dc822.zip |
Sunil Shetye's re-exec patch.
svn path=/trunk/; revision=3696
Diffstat (limited to 'rcfile_y.y')
-rw-r--r-- | rcfile_y.y | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -47,6 +47,9 @@ static void record_current(void); static void user_reset(void); static void reset_server(const char *name, int skip); +/* these should be of size PATH_MAX */ +char currentwd[1024] = "", rcfiledir[1024] = ""; + /* using Bison, this arranges that yydebug messages will show actual tokens */ extern char * yytext; #define YYPRINT(fp, type, val) fprintf(fp, " = \"%s\"", yytext) @@ -90,8 +93,8 @@ statement_list : statement optmap : MAP | /* EMPTY */; /* future global options should also have the form SET <name> optmap <value> */ -statement : SET LOGFILE optmap STRING {run.logfile = xstrdup($4);} - | SET IDFILE optmap STRING {run.idfile = xstrdup($4);} +statement : SET LOGFILE optmap STRING {run.logfile = prependdir ($4, rcfiledir);} + | SET IDFILE optmap STRING {run.idfile = prependdir ($4, rcfiledir);} | SET DAEMON optmap NUMBER {run.poll_interval = $4;} | SET POSTMASTER optmap STRING {run.postmaster = xstrdup($4);} | SET BOUNCEMAIL {run.bouncemail = TRUE;} @@ -323,7 +326,7 @@ user_option : TO localnames HERE | SMTPNAME STRING {current.smtpname = xstrdup($2);} | SPAMRESPONSE num_list | MDA STRING {current.mda = xstrdup($2);} - | BSMTP STRING {current.bsmtp = xstrdup($2);} + | BSMTP STRING {current.bsmtp = prependdir ($2, rcfiledir);} | LMTP {current.listener = LMTP_MODE;} | PRECONNECT STRING {current.preconnect = xstrdup($2);} | POSTCONNECT STRING {current.postconnect = xstrdup($2);} @@ -347,8 +350,8 @@ user_option : TO localnames HERE yyerror(GT_("SSL is not enabled")); #endif } - | SSLKEY STRING {current.sslkey = xstrdup($2);} - | SSLCERT STRING {current.sslcert = xstrdup($2);} + | SSLKEY STRING {current.sslkey = prependdir ($2, rcfiledir);} + | SSLCERT STRING {current.sslcert = prependdir ($2, rcfiledir);} | SSLPROTO STRING {current.sslproto = xstrdup($2);} | SSLCERTCK {current.sslcertck = FLAG_TRUE;} | SSLCERTPATH STRING {current.sslcertpath = xstrdup($2);} @@ -570,6 +573,22 @@ static void record_current(void) trailer = TRUE; } +char *prependdir (const char *file, const char *dir) +/* if a filename is relative to dir, convert it to an absolute path */ +{ + char *newfile; + if (!file[0] || /* null path */ + file[0] == '/' || /* absolute path */ + !dir[0]) /* we don't HAVE_GETCWD */ + return xstrdup (file); + newfile = xmalloc (strlen (dir) + 1 + strlen (file) + 1); + if (dir[strlen(dir) - 1] != '/') + sprintf (newfile, "%s/%s", dir, file); + else + sprintf (newfile, "%s%s", dir, file); + return newfile; +} + /* easier to do this than cope with variations in where the library lives */ int yywrap(void) {return 1;} |