aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--checkalias.c4
-rw-r--r--env.c2
-rw-r--r--imap.c39
-rw-r--r--pop3.c37
-rw-r--r--transact.c18
6 files changed, 66 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index d7163157..8903fddb 100644
--- a/NEWS
+++ b/NEWS
@@ -234,6 +234,8 @@ fetchmail 6.3.0 (not yet released officially):
saved run control file. Matthias Andree
* Properly shut down SSL connections. Berlios Patch #647 by Arkadiusz
Miƛkiewicz. (MA)
+* Global variable cleanup, to fix daemon mode reinitialization problems. Patch
+ by Sunil Shetye. (MA)
# INTERNAL CHANGES
* Switched to automake. Matthias Andree.
diff --git a/checkalias.c b/checkalias.c
index 687b5478..fd00502f 100644
--- a/checkalias.c
+++ b/checkalias.c
@@ -30,7 +30,7 @@ typedef unsigned char address_t[sizeof (struct in_addr)];
static int getaddresses(struct addrinfo **result, const char *name)
{
- struct addrinfo hints, *res;
+ struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype=SOCK_STREAM;
@@ -57,8 +57,6 @@ static int is_ip_alias(const char *name1,const char *name2)
*/
{
int rc = FALSE;
- struct hostent *hp;
- char **p;
struct addrinfo *res1 = NULL, *res2 = NULL, *ii, *ij;
diff --git a/env.c b/env.c
index cccc4f11..b3d27164 100644
--- a/env.c
+++ b/env.c
@@ -149,7 +149,7 @@ char *host_fqdn(void)
if (strchr(tmpbuf, '.') == NULL)
{
/* if we got a basename (as we do in Linux) make a FQDN of it */
- struct addrinfo hints, *res, *res0;
+ struct addrinfo hints, *res;
int e;
memset(&hints, 0, sizeof hints);
diff --git a/imap.c b/imap.c
index c76decc0..00955946 100644
--- a/imap.c
+++ b/imap.c
@@ -24,15 +24,30 @@
#define IMAP4 0 /* IMAP4 rev 0, RFC1730 */
#define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */
+/* global variables: please reinitialize them explicitly for proper
+ * working in daemon mode */
+
+/* TODO: session variables to be initialized before server greeting */
+static int preauth = FALSE;
+
+/* session variables initialized in capa_probe() or imap_getauth() */
+static char capabilities[MSGBUFSIZE+1];
+static int imap_version = IMAP4;
+static flag do_idle = FALSE, has_idle = FALSE;
+static int expunge_period = 1;
+
+/* mailbox variables initialized in imap_getrange() */
static int count = 0, recentcount = 0, unseen = 0, deletions = 0;
-static int recentcount_ok = 0;
static unsigned int startcount = 1;
-static int expunged, expunge_period, saved_timeout = 0;
-static int imap_version, preauth;
-static flag do_idle, has_idle;
-static char capabilities[MSGBUFSIZE+1];
+static int expunged = 0;
static unsigned int *unseen_messages;
+/* for "IMAP> EXPUNGE" */
+static int recentcount_ok = 0;
+
+/* for "IMAP> IDLE" */
+static int saved_timeout = 0;
+
static int imap_ok(int sock, char *argbuf)
/* parse command response */
{
@@ -168,10 +183,6 @@ static int imap_ok(int sock, char *argbuf)
#ifdef NTLM_ENABLE
#include "ntlm.h"
-static tSmbNtlmAuthRequest request;
-static tSmbNtlmAuthChallenge challenge;
-static tSmbNtlmAuthResponse response;
-
/*
* NTLM support by Grant Edwards.
*
@@ -185,6 +196,10 @@ static tSmbNtlmAuthResponse response;
static int do_imap_ntlm(int sock, struct query *ctl)
{
+ tSmbNtlmAuthRequest request;
+ tSmbNtlmAuthChallenge challenge;
+ tSmbNtlmAuthResponse response;
+
char msgbuf[2048];
int result,len;
@@ -300,13 +315,13 @@ static void capa_probe(int sock, struct query *ctl)
* Handle idling. We depend on coming through here on startup
* and after each timeout (including timeouts during idles).
*/
+ do_idle = ctl->idle;
if (ctl->idle)
{
- do_idle = TRUE;
if (strstr(capabilities, "IDLE"))
- {
has_idle = TRUE;
- }
+ else
+ has_idle = FALSE;
if (outlevel >= O_VERBOSE)
report(stdout, GT_("will idle after poll\n"));
}
diff --git a/pop3.c b/pop3.c
index 67489469..a18f8bc8 100644
--- a/pop3.c
+++ b/pop3.c
@@ -26,38 +26,41 @@
#include <opie.h>
#endif /* OPIE_ENABLE */
-static int last;
-#ifdef SDPS_ENABLE
-char *sdps_envfrom;
-char *sdps_envto;
-#endif /* SDPS_ENABLE */
+/* global variables: please reinitialize them explicitly for proper
+ * working in daemon mode */
+/* TODO: session variables to be initialized before server greeting */
#ifdef OPIE_ENABLE
static char lastok[POPBUFSIZE+1];
#endif /* OPIE_ENABLE */
-/* these variables are shared between the CAPA probe and the authenticator */
+/* session variables initialized in capa_probe() or pop3_getauth() */
#if defined(GSSAPI)
- flag has_gssapi = FALSE;
+flag has_gssapi = FALSE;
#endif /* defined(GSSAPI) */
#if defined(KERBEROS_V4) || defined(KERBEROS_V5)
- flag has_kerberos = FALSE;
+flag has_kerberos = FALSE;
#endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
- static flag has_cram = FALSE;
+static flag has_cram = FALSE;
#ifdef OPIE_ENABLE
- flag has_otp = FALSE;
+flag has_otp = FALSE;
#endif /* OPIE_ENABLE */
#ifdef SSL_ENABLE
- static flag has_ssl = FALSE;
+static flag has_ssl = FALSE;
#endif /* SSL_ENABLE */
+/* mailbox variables initialized in pop3_getrange() */
+static int last;
+
+/* mail variables initialized in pop3_fetch() */
+#ifdef SDPS_ENABLE
+char *sdps_envfrom;
+char *sdps_envto;
+#endif /* SDPS_ENABLE */
+
#ifdef NTLM_ENABLE
#include "ntlm.h"
-static tSmbNtlmAuthRequest request;
-static tSmbNtlmAuthChallenge challenge;
-static tSmbNtlmAuthResponse response;
-
/*
* NTLM support by Grant Edwards.
*
@@ -72,6 +75,10 @@ static tSmbNtlmAuthResponse response;
static int do_pop3_ntlm(int sock, struct query *ctl,
int msn_instead /** if true, send AUTH MSN, else send AUTH NTLM */)
{
+ tSmbNtlmAuthRequest request;
+ tSmbNtlmAuthChallenge challenge;
+ tSmbNtlmAuthResponse response;
+
char msgbuf[2048];
int result,len;
diff --git a/transact.c b/transact.c
index ec625e6a..a2e8d0b8 100644
--- a/transact.c
+++ b/transact.c
@@ -37,17 +37,23 @@
#include "socket.h"
#include "fetchmail.h"
-int mytimeout; /* value of nonreponse timeout */
-int suppress_tags; /* emit tags? */
-char shroud[PASSWORDLEN*2+3]; /* string to shroud in debug output */
-struct msgblk msgblk;
+/* global variables: please reinitialize them explicitly for proper
+ * working in daemon mode */
+/* session variables initialized in init_transact() */
+int suppress_tags = FALSE; /* emit tags? */
char tag[TAGLEN];
static int tagnum;
#define GENSYM (sprintf(tag, "A%04d", ++tagnum % TAGMOD), tag)
+static struct method *protocol;
+char shroud[PASSWORDLEN*2+3]; /* string to shroud in debug output */
+/* session variables initialized in do_session() */
+int mytimeout; /* value of nonreponse timeout */
+
+/* mail variables initialized in readheaders() */
+struct msgblk msgblk;
static int accept_count, reject_count;
-static struct method *protocol;
static void map_name(const char *name, struct query *ctl, struct idlist **xmit_names)
/* add given name to xmit_names if it matches declared localnames */
@@ -1391,9 +1397,11 @@ int readbody(int sock, struct query *ctl, flag forward, int len)
void init_transact(const struct method *proto)
/* initialize state for the send and receive functions */
{
+ suppress_tags = FALSE;
tagnum = 0;
tag[0] = '\0'; /* nuke any tag hanging out from previous query */
protocol = (struct method *)proto;
+ shroud[0] = '\0';
}
static void enshroud(char *buf)