diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2010-12-18 16:07:57 +0100 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2016-07-06 10:03:46 +0200 |
commit | 36c5075506895b66e783b76355013de66823fb3d (patch) | |
tree | 9296bc7cad0bd7fecaa90b1a0ce61bd85675c60f | |
parent | 1ae9d7bf1499cb005a52030ab4ed51a37ec81b02 (diff) | |
download | fetchmail-36c5075506895b66e783b76355013de66823fb3d.tar.gz fetchmail-36c5075506895b66e783b76355013de66823fb3d.tar.bz2 fetchmail-36c5075506895b66e783b76355013de66823fb3d.zip |
Accept more options with a running daemon.
(Cherry-picked from master's 1a92b2909610096a11d26f7a7317d32819354be3.)
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | fetchmail.c | 20 | ||||
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | options.c | 18 |
4 files changed, 35 insertions, 10 deletions
@@ -98,6 +98,8 @@ fetchmail-6.4.0 (not yet released): * Fetchmail now detects if the server hangs up prematurely during SSL_connect() and reports this condition as such, and not just as SSL connection failure. (OpenSSL 1.0.2 reported incompatible with pop3.live.com by Jerry Seibert). +* A foreground fetchmail can now accept a few more options while another copy is + running in the background. ## FIXES * Fix a typo in the FAQ. Submitted by David Lawyer, Debian Bug#706776. @@ -134,10 +136,11 @@ fetchmail-6.4.0 (not yet released): messages. This will not be fixed, because the maintainer has no Kerberos 5 server to test against. Use GSSAPI. +-------------------------------------------------------------------------------- fetchmail-6.3.26 (released 2013-04-23, 26180 LoC): - CRITICAL BUG FIX for setups using "mimedecode": +# CRITICAL BUG FIX for setups using "mimedecode": * The mimedecode feature failed to ship the last line of the body if it was encoded as quoted-printable and had a MIME soft line break in the very last line. Reported by Lars Hecking in June 2011. diff --git a/fetchmail.c b/fetchmail.c index 22d492ae..8b0a5c3d 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -159,6 +159,8 @@ int main(int argc, char **argv) { int bkgd = FALSE; int implicitmode = FALSE; + flag safewithbg = FALSE; /** if parsed options are compatible with a + fetchmail copy running in the background */ struct query *ctl; netrc_entry *netrc_list; char *netrc_file, *tmpbuf; @@ -202,7 +204,7 @@ int main(int argc, char **argv) #define IDFILE_NAME ".fetchids" run.idfile = prependdir (IDFILE_NAME, fmhome); - + outlevel = O_NORMAL; /* @@ -226,7 +228,7 @@ int main(int argc, char **argv) { int i; - i = parsecmdline(argc, argv, &cmd_run, &cmd_opts); + i = parsecmdline(argc, argv, &cmd_run, &cmd_opts, &safewithbg); if (i < 0) exit(PS_SYNTAX); @@ -541,17 +543,23 @@ int main(int argc, char **argv) else if (getpid() == pid) /* this test enables re-execing on a changed rcfile */ fm_lock_assert(); - else if (argc > 1) + else if (argc > 1 && !safewithbg) { fprintf(stderr, GT_("fetchmail: can't accept options while a background fetchmail is running.\n")); + { + int i; + fprintf(stderr, "argc = %d, arg list:\n", argc); + for (i = 1; i < argc; i++) fprintf(stderr, "arg %d = \"%s\"\n", i, argv[i]); + } return(PS_EXCLUDE); } else if (kill(pid, SIGUSR1) == 0) { - fprintf(stderr, - GT_("fetchmail: background fetchmail at %ld awakened.\n"), - (long)pid); + if (outlevel > O_SILENT) + fprintf(stderr, + GT_("fetchmail: background fetchmail at %ld awakened.\n"), + (long)pid); return(0); } else diff --git a/fetchmail.h b/fetchmail.h index 52a1d4b9..f14d51d4 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -679,7 +679,7 @@ int do_otp(int sock, const char *command, struct query *ctl); extern char currentwd[1024], rcfiledir[1024]; struct query *hostalloc(struct query *); -int parsecmdline (int, char **, struct runctl *, struct query *); +int parsecmdline (int, char **, struct runctl *, struct query *, flag *); char *prependdir (const char *, const char *); char *MD5Digest (unsigned const char *); void hmac_md5 (const unsigned char *, size_t, const unsigned char *, size_t, unsigned char *, size_t); @@ -233,7 +233,10 @@ static int xatoi(char *s, int *errflagptr) int parsecmdline (int argc /** argument count */, char **argv /** argument strings */, struct runctl *rctl /** global run controls to modify */, - struct query *ctl /** option record to initialize */) + struct query *ctl /** option record to initialize */, + flag *safewithbg /** set to whether options are + compatible with another copy + running in the background */) { /* * return value: if positive, argv index of last parsed option + 1 @@ -248,9 +251,12 @@ int parsecmdline (int argc /** argument count */, int errflag = 0; /* TRUE when a syntax error is detected */ int helpflag = 0; /* TRUE when option help was explicitly requested */ int option_index; + int option_safe; /* to track if option currently parsed is safe + with a background copy */ char *buf, *cp; rctl->poll_interval = -1; + *safewithbg = TRUE; memset(ctl, '\0', sizeof(struct query)); /* start clean */ ctl->smtp_socket = -1; @@ -259,21 +265,26 @@ int parsecmdline (int argc /** argument count */, (c = getopt_long(argc,argv,shortoptions, longoptions, &option_index)) != -1) { + option_safe = FALSE; + switch (c) { case 'V': versioninfo = TRUE; + option_safe = TRUE; break; case 'c': check_only = TRUE; break; case 's': outlevel = O_SILENT; + option_safe = 1; break; case 'v': if (outlevel >= O_VERBOSE) outlevel = O_DEBUG; else outlevel = O_VERBOSE; + option_safe = TRUE; break; case 'd': rctl->poll_interval = xatoi(optarg, &errflag); @@ -600,6 +611,7 @@ int parsecmdline (int argc /** argument count */, case LA_CONFIGDUMP: configdump = TRUE; + option_safe = TRUE; break; case LA_SYSLOG: @@ -615,9 +627,11 @@ int parsecmdline (int argc /** argument count */, break; case '?': + helpflag = 1; default: - helpflag++; + break; } + *safewithbg &= option_safe; } if (errflag || ocount > 1 || helpflag) { |