Fixed a bug where mbtask would not stop calling undialable nodes
This commit is contained in:
parent
af926964ba
commit
e52324bf3a
@ -117,7 +117,6 @@ static int getkwd(char **dest)
|
||||
(*tmpm)->name = xstrcpy(v);
|
||||
tmp = strtoul(p, NULL, 0);
|
||||
(*tmpm)->value = tmp;
|
||||
// Syslog('n', "getkwd: %s(%d): \"%s\" \"%s\" \"%08x\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->name, (*tmpm)->value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -161,8 +160,6 @@ static int getmdm(char **dest)
|
||||
tmp2 = strtoul(q, NULL, 0);
|
||||
(*tmpm)->mask = tmp1;
|
||||
(*tmpm)->value = tmp2;
|
||||
// Syslog('n', "getmdm: %s(%d): \"%s\" \"%s\" \"%08x\" \"%08x\"", nlpath, linecnt, MBSE_SS(k),
|
||||
// (*tmpm)->name, (*tmpm)->mask, (*tmpm)->value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -185,7 +182,6 @@ static int getarr(char **dest)
|
||||
(*tmpm) = (nodelist_array *) xmalloc(sizeof(nodelist_array));
|
||||
(*tmpm)->next = NULL;
|
||||
(*tmpm)->name = xstrcpy(v);
|
||||
// Syslog('n', "getarr: %s(%d): \"%s\" \"%s\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -216,7 +212,6 @@ static int getdom(char **dest)
|
||||
tmp = strtod(v, NULL);
|
||||
(*tmpm)->zone = tmp;
|
||||
(*tmpm)->name = xstrcpy(p);
|
||||
// Syslog('n', "getdom: %s(%d): \"%s\" \"%d\" \"%s\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->zone, (*tmpm)->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -259,8 +254,6 @@ static int getsrv(char **dest)
|
||||
(*tmpm)->service = xstrcpy(p);
|
||||
tmp = strtoul(q, NULL, 0);
|
||||
(*tmpm)->port = tmp;
|
||||
// Syslog('n', "getsrv: %s(%d): \"%s\" \"%s\" \"%s\" \"%d\"", nlpath, linecnt, MBSE_SS(k),
|
||||
// (*tmpm)->flag, (*tmpm)->service, (*tmpm)->port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -459,8 +452,6 @@ int initnl(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Syslog('n', "\"%s\" \"%s\" - parsed", MBSE_SS(k), MBSE_SS(v));
|
||||
|
||||
for (i = 0; keytab[i].key; i++)
|
||||
if (strcasecmp(k,keytab[i].key) == 0)
|
||||
break;
|
||||
@ -636,12 +627,18 @@ node *getnlent(faddr *addr)
|
||||
fread(&fidonethdr, sizeof(fidonethdr), 1, fp);
|
||||
while (fread(&fidonet, fidonethdr.recsize, 1, fp) == 1) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (addr->zone == fidonet.zone[i])
|
||||
if (addr->zone == fidonet.zone[i]) {
|
||||
nodebuf.addr.domain = xstrcpy(fidonet.domain);
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Found)
|
||||
break;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
Found = FALSE;
|
||||
|
||||
/*
|
||||
* First, lookup node in index. NOTE -- NOT 5D YET
|
||||
@ -735,7 +732,6 @@ node *getnlent(faddr *addr)
|
||||
if ((addr->zone == nd.Aka[i].zone) && (addr->net == nd.Aka[i].net) &&
|
||||
(addr->node == nd.Aka[i].node) && (addr->point == nd.Aka[i].point)) {
|
||||
ndrecord = TRUE;
|
||||
Syslog('n', "getnlent: node record is present");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -783,7 +779,7 @@ node *getnlent(faddr *addr)
|
||||
if ((q=strchr(p,',')))
|
||||
*q++ = '\0';
|
||||
if (ndrecord && strlen(nd.Nl_hostname)) {
|
||||
Syslog('n', "getnlent: system name override with %s", nd.Nl_hostname);
|
||||
Syslog('+', "getnlent: %s system name override with %s", ascfnode(addr,0xff), nd.Nl_hostname);
|
||||
nodebuf.name = nd.Nl_hostname;
|
||||
} else
|
||||
nodebuf.name = p;
|
||||
@ -843,7 +839,7 @@ node *getnlent(faddr *addr)
|
||||
* Process the nodelist flags.
|
||||
*/
|
||||
if (ndrecord && strlen(nd.Nl_flags)) {
|
||||
Syslog('n', "getnlent: flags override %s", nd.Nl_flags);
|
||||
Syslog('+', "getnlent: %s flags override %s", ascfnode(addr,0xff), nd.Nl_flags);
|
||||
q = nd.Nl_flags;
|
||||
}
|
||||
ixflag = 0;
|
||||
@ -900,7 +896,7 @@ node *getnlent(faddr *addr)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Linse starting with ;E space are real errors.
|
||||
* Lines starting with ;E space are real errors.
|
||||
*/
|
||||
if (strncmp(ebuf, (char *)";E ", 3) == 0)
|
||||
break;
|
||||
@ -1011,7 +1007,6 @@ node *getnlent(faddr *addr)
|
||||
for (p = q; p; p = q) {
|
||||
if ((q = strchr(p, ',')))
|
||||
*q++ = '\0';
|
||||
Syslog('n', "\"%s\"", MBSE_SS(p));
|
||||
if ((r = strchr(p, ':'))) {
|
||||
r++;
|
||||
/*
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Read mailer last call status
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -41,95 +41,92 @@ extern struct sysconfig CFG;
|
||||
char *stsname(faddr *);
|
||||
char *stsname(faddr *addr)
|
||||
{
|
||||
static char buf[PATH_MAX];
|
||||
char *p, *domain=NULL;
|
||||
char zpref[8];
|
||||
int i;
|
||||
static char buf[PATH_MAX];
|
||||
char *p, *domain=NULL, zpref[8];
|
||||
int i;
|
||||
|
||||
sprintf(buf, "%s", CFG.outbound);
|
||||
sprintf(buf, "%s", CFG.outbound);
|
||||
|
||||
if (CFG.addr4d) {
|
||||
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
||||
zpref[0] = '\0';
|
||||
else
|
||||
sprintf(zpref, ".%03x", addr->zone);
|
||||
} else {
|
||||
/*
|
||||
* If we got a 5d address we use the given domain, if
|
||||
* we got a 4d address, we look for a matching domain name.
|
||||
*/
|
||||
if (addr->domain)
|
||||
domain = xstrcpy(addr->domain);
|
||||
else
|
||||
for (i = 0; i < 40; i++)
|
||||
if (CFG.aka[i].zone == addr->zone) {
|
||||
domain = xstrcpy(CFG.aka[i].domain);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((domain != NULL) && (strlen(CFG.aka[0].domain) != 0) &&
|
||||
(strcasecmp(domain,CFG.aka[0].domain) != 0)) {
|
||||
if ((p = strrchr(buf,'/')))
|
||||
p++;
|
||||
else
|
||||
p = buf;
|
||||
strcpy(p, domain);
|
||||
for (; *p; p++)
|
||||
*p = tolower(*p);
|
||||
for (i = 0; i < 40; i++)
|
||||
if ((strlen(CFG.aka[i].domain)) &&
|
||||
(strcasecmp(CFG.aka[i].domain, domain) == 0))
|
||||
break;
|
||||
|
||||
/*
|
||||
* The default zone must be the first one in the
|
||||
* setup, other zones get the hexadecimal zone
|
||||
* number appended.
|
||||
*/
|
||||
if (CFG.aka[i].zone == addr->zone)
|
||||
zpref[0] = '\0';
|
||||
else
|
||||
sprintf(zpref, ".%03x", addr->zone);
|
||||
} else {
|
||||
/*
|
||||
* this is our primary domain
|
||||
*/
|
||||
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
||||
zpref[0]='\0';
|
||||
else
|
||||
sprintf(zpref,".%03x",addr->zone);
|
||||
}
|
||||
}
|
||||
|
||||
p = buf + strlen(buf);
|
||||
|
||||
if (addr->point)
|
||||
sprintf(p,"%s/%04x%04x.pnt/%08x.sts", zpref,addr->net,addr->node,addr->point);
|
||||
if (CFG.addr4d) {
|
||||
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
||||
zpref[0] = '\0';
|
||||
else
|
||||
sprintf(p,"%s/%04x%04x.sts",zpref,addr->net,addr->node);
|
||||
sprintf(zpref, ".%03x", addr->zone);
|
||||
} else {
|
||||
/*
|
||||
* If we got a 5d address we use the given domain, if
|
||||
* we got a 4d address, we look for a matching domain name.
|
||||
*/
|
||||
if (addr->domain)
|
||||
domain = xstrcpy(addr->domain);
|
||||
else
|
||||
for (i = 0; i < 40; i++)
|
||||
if (CFG.aka[i].zone == addr->zone) {
|
||||
domain = xstrcpy(CFG.aka[i].domain);
|
||||
break;
|
||||
}
|
||||
|
||||
if (domain)
|
||||
free(domain);
|
||||
return buf;
|
||||
if ((domain != NULL) && (strlen(CFG.aka[0].domain) != 0) && (strcasecmp(domain,CFG.aka[0].domain) != 0)) {
|
||||
if ((p = strrchr(buf,'/')))
|
||||
p++;
|
||||
else
|
||||
p = buf;
|
||||
strcpy(p, domain);
|
||||
for (; *p; p++)
|
||||
*p = tolower(*p);
|
||||
for (i = 0; i < 40; i++)
|
||||
if ((strlen(CFG.aka[i].domain)) && (strcasecmp(CFG.aka[i].domain, domain) == 0))
|
||||
break;
|
||||
|
||||
/*
|
||||
* The default zone must be the first one in the
|
||||
* setup, other zones get the hexadecimal zone
|
||||
* number appended.
|
||||
*/
|
||||
if (CFG.aka[i].zone == addr->zone)
|
||||
zpref[0] = '\0';
|
||||
else
|
||||
sprintf(zpref, ".%03x", addr->zone);
|
||||
} else {
|
||||
/*
|
||||
* this is our primary domain
|
||||
*/
|
||||
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
||||
zpref[0]='\0';
|
||||
else
|
||||
sprintf(zpref,".%03x",addr->zone);
|
||||
}
|
||||
}
|
||||
|
||||
p = buf + strlen(buf);
|
||||
|
||||
if (addr->point)
|
||||
sprintf(p,"%s/%04x%04x.pnt/%08x.sts", zpref,addr->net,addr->node,addr->point);
|
||||
else
|
||||
sprintf(p,"%s/%04x%04x.sts",zpref,addr->net,addr->node);
|
||||
|
||||
if (domain)
|
||||
free(domain);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
callstat *getstatus(faddr *addr)
|
||||
{
|
||||
static callstat cst;
|
||||
FILE *fp;
|
||||
static callstat cst;
|
||||
FILE *fp;
|
||||
|
||||
cst.trytime = 0L;
|
||||
cst.tryno = 0;
|
||||
cst.trystat = 0;
|
||||
cst.trytime = 0L;
|
||||
cst.tryno = 0;
|
||||
cst.trystat = 0;
|
||||
|
||||
if ((fp = fopen(stsname(addr), "r"))) {
|
||||
fread(&cst, sizeof(callstat), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
if ((fp = fopen(stsname(addr), "r"))) {
|
||||
fread(&cst, sizeof(callstat), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return &cst;
|
||||
return &cst;
|
||||
}
|
||||
|
||||
|
||||
|
271
mbtask/outstat.c
271
mbtask/outstat.c
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: mbtask - Scan mail outbound status
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -395,7 +395,6 @@ int outstat()
|
||||
else
|
||||
tmin = 30;
|
||||
sprintf(be, "%02d:%02d", thour, tmin);
|
||||
// Syslog('o', "Setting next hour for Txx node at %s", be);
|
||||
set_next(thour, tmin);
|
||||
if (strcmp(as, be) > 0) {
|
||||
/*
|
||||
@ -592,142 +591,142 @@ int outstat()
|
||||
|
||||
int each(faddr *addr, char flavor, int isflo, char *fname)
|
||||
{
|
||||
struct _alist **tmp;
|
||||
struct stat st;
|
||||
FILE *fp;
|
||||
char buf[256], *p;
|
||||
node *nlent;
|
||||
callstat *cst;
|
||||
|
||||
if ((isflo != OUT_PKT) && (isflo != OUT_FLO) && (isflo != OUT_REQ) && (isflo != OUT_POL) && (isflo != OUT_FIL))
|
||||
return 0;
|
||||
|
||||
for (tmp = &alist; *tmp; tmp = &((*tmp)->next))
|
||||
if (((*tmp)->addr.zone == addr->zone) && ((*tmp)->addr.net == addr->net) &&
|
||||
((*tmp)->addr.node == addr->node) && ((*tmp)->addr.point == addr->point) &&
|
||||
(((*tmp)->addr.domain == NULL) || (addr->domain == NULL) ||
|
||||
(strcasecmp((*tmp)->addr.domain,addr->domain) == 0)))
|
||||
break;
|
||||
if (*tmp == NULL) {
|
||||
Syslog('-', "%s", ascfnode(addr, 0xff));
|
||||
nlent = getnlent(addr);
|
||||
*tmp = (struct _alist *)malloc(sizeof(struct _alist));
|
||||
(*tmp)->next = NULL;
|
||||
(*tmp)->addr.zone = addr->zone;
|
||||
(*tmp)->addr.net = addr->net;
|
||||
(*tmp)->addr.node = addr->node;
|
||||
(*tmp)->addr.point = addr->point;
|
||||
sprintf((*tmp)->addr.domain, "%s", addr->domain);
|
||||
if (nlent->addr.domain)
|
||||
free(nlent->addr.domain);
|
||||
(*tmp)->flavors = 0;
|
||||
if (nlent->pflag != NL_DUMMY) {
|
||||
(*tmp)->olflags = nlent->oflags;
|
||||
(*tmp)->moflags = nlent->mflags;
|
||||
(*tmp)->diflags = nlent->dflags;
|
||||
(*tmp)->ipflags = nlent->iflags;
|
||||
(*tmp)->t1 = nlent->t1;
|
||||
(*tmp)->t2 = nlent->t2;
|
||||
} else {
|
||||
(*tmp)->olflags = 0L;
|
||||
(*tmp)->moflags = 0L;
|
||||
(*tmp)->diflags = 0L;
|
||||
(*tmp)->ipflags = 0L;
|
||||
(*tmp)->t1 = '\0';
|
||||
(*tmp)->t2 = '\0';
|
||||
}
|
||||
(*tmp)->time = time(NULL);
|
||||
(*tmp)->size = 0L;
|
||||
}
|
||||
|
||||
cst = getstatus(addr);
|
||||
(*tmp)->cst.trytime = cst->trytime;
|
||||
(*tmp)->cst.tryno = cst->tryno;
|
||||
(*tmp)->cst.trystat = cst->trystat;
|
||||
|
||||
if ((isflo == OUT_FLO) || (isflo == OUT_PKT) || (isflo == OUT_FIL))
|
||||
switch (flavor) {
|
||||
case '?': break;
|
||||
case 'i': (*tmp)->flavors |= F_IMM; break;
|
||||
case 'o': (*tmp)->flavors |= F_NORMAL; break;
|
||||
case 'c': (*tmp)->flavors |= F_CRASH; break;
|
||||
case 'h': (*tmp)->flavors |= F_HOLD; break;
|
||||
default: Syslog('?', "Unknown flavor: '%c'\n",flavor); break;
|
||||
}
|
||||
|
||||
if (stat(fname,&st) != 0) {
|
||||
Syslog('?', "$Can't stat %s", fname);
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the oldest time
|
||||
*/
|
||||
if (st.st_mtime < (*tmp)->time)
|
||||
(*tmp)->time = st.st_mtime;
|
||||
|
||||
if (isflo == OUT_FLO) {
|
||||
(*tmp)->flavors |= F_ISFLO;
|
||||
if ((fp = fopen(fname,"r"))) {
|
||||
while (fgets(buf, sizeof(buf) - 1, fp)) {
|
||||
if (*(p = buf + strlen(buf) - 1) == '\n')
|
||||
*p-- = '\0';
|
||||
while (isspace(*p))
|
||||
*p-- = '\0';
|
||||
for (p = buf; *p; p++)
|
||||
if (*p == '\\')
|
||||
*p='/';
|
||||
for (p = buf; *p && isspace(*p); p++);
|
||||
if (*p == '~') continue;
|
||||
if ((*p == '#') || (*p == '-') || (*p == '^') || (*p == '@'))
|
||||
p++;
|
||||
if (stat(p, &st) != 0) {
|
||||
if (strlen(CFG.dospath)) {
|
||||
if (stat(Dos2Unix(p), &st) != 0) {
|
||||
/*
|
||||
* Fileattach dissapeared, maybe
|
||||
* the node doesn't poll enough and
|
||||
* is losing mail or files.
|
||||
*/
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
} else {
|
||||
if (stat(p, &st) != 0) {
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((p = strrchr(fname,'/')))
|
||||
p++;
|
||||
else
|
||||
p = fname;
|
||||
if ((strlen(p) == 12) && (strspn(p,"0123456789abcdefABCDEF") == 8) && (p[8] == '.')) {
|
||||
if (st.st_mtime < (*tmp)->time)
|
||||
(*tmp)->time = st.st_mtime;
|
||||
}
|
||||
(*tmp)->size += st.st_size;
|
||||
}
|
||||
fclose(fp);
|
||||
} else
|
||||
Syslog('?', "Can't open %s", fname);
|
||||
|
||||
} else if (isflo == OUT_PKT) {
|
||||
(*tmp)->size += st.st_size;
|
||||
(*tmp)->flavors |= F_ISPKT;
|
||||
} else if (isflo == OUT_REQ) {
|
||||
(*tmp)->flavors |= F_FREQ;
|
||||
} else if (isflo == OUT_POL) {
|
||||
(*tmp)->flavors |= F_POLL;
|
||||
} else if (isflo == OUT_FIL) {
|
||||
(*tmp)->size += st.st_size;
|
||||
(*tmp)->flavors |= F_ISFIL;
|
||||
}
|
||||
struct _alist **tmp;
|
||||
struct stat st;
|
||||
FILE *fp;
|
||||
char buf[256], *p;
|
||||
node *nlent;
|
||||
callstat *cst;
|
||||
|
||||
if ((isflo != OUT_PKT) && (isflo != OUT_FLO) && (isflo != OUT_REQ) && (isflo != OUT_POL) && (isflo != OUT_FIL))
|
||||
return 0;
|
||||
|
||||
for (tmp = &alist; *tmp; tmp = &((*tmp)->next))
|
||||
if (((*tmp)->addr.zone == addr->zone) && ((*tmp)->addr.net == addr->net) &&
|
||||
((*tmp)->addr.node == addr->node) && ((*tmp)->addr.point == addr->point) &&
|
||||
(((*tmp)->addr.domain == NULL) || (addr->domain == NULL) ||
|
||||
(strcasecmp((*tmp)->addr.domain,addr->domain) == 0)))
|
||||
break;
|
||||
if (*tmp == NULL) {
|
||||
nlent = getnlent(addr);
|
||||
*tmp = (struct _alist *)malloc(sizeof(struct _alist));
|
||||
(*tmp)->next = NULL;
|
||||
(*tmp)->addr.zone = addr->zone;
|
||||
(*tmp)->addr.net = addr->net;
|
||||
(*tmp)->addr.node = addr->node;
|
||||
(*tmp)->addr.point = addr->point;
|
||||
sprintf((*tmp)->addr.domain, "%s", addr->domain);
|
||||
if (nlent->addr.domain)
|
||||
free(nlent->addr.domain);
|
||||
(*tmp)->flavors = 0;
|
||||
if (nlent->pflag != NL_DUMMY) {
|
||||
(*tmp)->olflags = nlent->oflags;
|
||||
(*tmp)->moflags = nlent->mflags;
|
||||
(*tmp)->diflags = nlent->dflags;
|
||||
(*tmp)->ipflags = nlent->iflags;
|
||||
(*tmp)->t1 = nlent->t1;
|
||||
(*tmp)->t2 = nlent->t2;
|
||||
} else {
|
||||
(*tmp)->olflags = 0L;
|
||||
(*tmp)->moflags = 0L;
|
||||
(*tmp)->diflags = 0L;
|
||||
(*tmp)->ipflags = 0L;
|
||||
(*tmp)->t1 = '\0';
|
||||
(*tmp)->t2 = '\0';
|
||||
}
|
||||
(*tmp)->time = time(NULL);
|
||||
(*tmp)->size = 0L;
|
||||
}
|
||||
|
||||
cst = getstatus(addr);
|
||||
(*tmp)->cst.trytime = cst->trytime;
|
||||
(*tmp)->cst.tryno = cst->tryno;
|
||||
(*tmp)->cst.trystat = cst->trystat;
|
||||
|
||||
if ((isflo == OUT_FLO) || (isflo == OUT_PKT) || (isflo == OUT_FIL))
|
||||
switch (flavor) {
|
||||
case '?': break;
|
||||
case 'i': (*tmp)->flavors |= F_IMM; break;
|
||||
case 'o': (*tmp)->flavors |= F_NORMAL; break;
|
||||
case 'c': (*tmp)->flavors |= F_CRASH; break;
|
||||
case 'h': (*tmp)->flavors |= F_HOLD; break;
|
||||
default: Syslog('?', "Unknown flavor: '%c'\n",flavor); break;
|
||||
}
|
||||
|
||||
if (stat(fname,&st) != 0) {
|
||||
Syslog('?', "$Can't stat %s", fname);
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the oldest time
|
||||
*/
|
||||
if (st.st_mtime < (*tmp)->time)
|
||||
(*tmp)->time = st.st_mtime;
|
||||
|
||||
if (isflo == OUT_FLO) {
|
||||
(*tmp)->flavors |= F_ISFLO;
|
||||
if ((fp = fopen(fname,"r"))) {
|
||||
while (fgets(buf, sizeof(buf) - 1, fp)) {
|
||||
if (*(p = buf + strlen(buf) - 1) == '\n')
|
||||
*p-- = '\0';
|
||||
while (isspace(*p))
|
||||
*p-- = '\0';
|
||||
for (p = buf; *p; p++)
|
||||
if (*p == '\\')
|
||||
*p='/';
|
||||
for (p = buf; *p && isspace(*p); p++);
|
||||
if (*p == '~')
|
||||
continue;
|
||||
if ((*p == '#') || (*p == '-') || (*p == '^') || (*p == '@'))
|
||||
p++;
|
||||
if (stat(p, &st) != 0) {
|
||||
if (strlen(CFG.dospath)) {
|
||||
if (stat(Dos2Unix(p), &st) != 0) {
|
||||
/*
|
||||
* Fileattach dissapeared, maybe
|
||||
* the node doesn't poll enough and
|
||||
* is losing mail or files.
|
||||
*/
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
} else {
|
||||
if (stat(p, &st) != 0) {
|
||||
st.st_size = 0L;
|
||||
st.st_mtime = time(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((p = strrchr(fname,'/')))
|
||||
p++;
|
||||
else
|
||||
p = fname;
|
||||
if ((strlen(p) == 12) && (strspn(p,"0123456789abcdefABCDEF") == 8) && (p[8] == '.')) {
|
||||
if (st.st_mtime < (*tmp)->time)
|
||||
(*tmp)->time = st.st_mtime;
|
||||
}
|
||||
(*tmp)->size += st.st_size;
|
||||
}
|
||||
fclose(fp);
|
||||
} else
|
||||
Syslog('?', "Can't open %s", fname);
|
||||
|
||||
} else if (isflo == OUT_PKT) {
|
||||
(*tmp)->size += st.st_size;
|
||||
(*tmp)->flavors |= F_ISPKT;
|
||||
} else if (isflo == OUT_REQ) {
|
||||
(*tmp)->flavors |= F_FREQ;
|
||||
} else if (isflo == OUT_POL) {
|
||||
(*tmp)->flavors |= F_POLL;
|
||||
} else if (isflo == OUT_FIL) {
|
||||
(*tmp)->size += st.st_size;
|
||||
(*tmp)->flavors |= F_ISFIL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
307
mbtask/scanout.c
307
mbtask/scanout.c
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Outbound scanning
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -52,191 +52,178 @@ extern struct _fidonet fidonet;
|
||||
|
||||
|
||||
|
||||
static int scan_dir(int (*)(faddr*,char,int,char*),char*,int);
|
||||
static int scan_dir(int (*)(faddr*, char, int, char *), char *, int);
|
||||
static int scan_dir(int (*fn)(faddr *, char, int, char *), char *dname, int ispoint)
|
||||
{
|
||||
char fname[PATH_MAX];
|
||||
char flavor = '?';
|
||||
DIR *dp = NULL;
|
||||
struct dirent *de;
|
||||
int rc = 0, isflo, fage;
|
||||
time_t t_start;
|
||||
char fname[PATH_MAX], flavor = '?';
|
||||
DIR *dp = NULL;
|
||||
struct dirent *de;
|
||||
int rc = 0, isflo, fage;
|
||||
time_t t_start;
|
||||
|
||||
t_start = time(NULL);
|
||||
// Syslog('o' ,"scan_dir \"%s\" (%s)",MBSE_SS(dname),ispoint?"point":"node");
|
||||
t_start = time(NULL);
|
||||
|
||||
if ((dp = opendir(dname)) == NULL) {
|
||||
Syslog('-', "Creating directory %s", dname);
|
||||
/*
|
||||
* Create a fake filename, mkdirs() likes that.
|
||||
*/
|
||||
sprintf(fname, "%s/foo", dname);
|
||||
(void)mkdirs(fname, 0770);
|
||||
if ((dp = opendir(dname)) == NULL) {
|
||||
Syslog('-', "Creating directory %s", dname);
|
||||
/*
|
||||
* Create a fake filename, mkdirs() likes that.
|
||||
*/
|
||||
sprintf(fname, "%s/foo", dname);
|
||||
(void)mkdirs(fname, 0770);
|
||||
if ((dp = opendir(dname)) == NULL) {
|
||||
Syslog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
|
||||
return 0;
|
||||
}
|
||||
Syslog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ((de=readdir(dp)))
|
||||
if ((strlen(de->d_name) == 12) && (de->d_name[8] == '.') &&
|
||||
(strspn(de->d_name,"0123456789abcdefABCDEF") == 8)) {
|
||||
// Syslog('o' ,"checking: \"%s\"",de->d_name);
|
||||
addr.point= 0;
|
||||
strncpy(fname,dname,PATH_MAX-2);
|
||||
strcat(fname,"/");
|
||||
strncat(fname,de->d_name,PATH_MAX-strlen(fname)-2);
|
||||
while ((de=readdir(dp))) {
|
||||
if ((strlen(de->d_name) == 12) && (de->d_name[8] == '.') && (strspn(de->d_name,"0123456789abcdefABCDEF") == 8)) {
|
||||
addr.point= 0;
|
||||
strncpy(fname,dname,PATH_MAX-2);
|
||||
strcat(fname,"/");
|
||||
strncat(fname,de->d_name,PATH_MAX-strlen(fname)-2);
|
||||
|
||||
if ((strcasecmp(de->d_name+9,"pnt") == 0) && !ispoint) {
|
||||
sscanf(de->d_name,"%04x%04x",&addr.net,&addr.node);
|
||||
if ((rc = scan_dir(fn, fname, 1)))
|
||||
goto exout;
|
||||
} else if ((strcasecmp(de->d_name+8,".out") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".cut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".iut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".opk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".cpk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hpk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".ipk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".flo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".clo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hlo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".ilo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".req") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".pol") == 0)) {
|
||||
if (ispoint)
|
||||
sscanf(de->d_name,"%08x", &addr.point);
|
||||
else
|
||||
sscanf(de->d_name,"%04x%04x", &addr.net,&addr.node);
|
||||
flavor = tolower(de->d_name[9]);
|
||||
if (flavor == 'f')
|
||||
flavor='o';
|
||||
if (strcasecmp(de->d_name+10,"ut") == 0)
|
||||
isflo=OUT_PKT;
|
||||
else if (strcasecmp(de->d_name+10,"pk") == 0)
|
||||
isflo=OUT_DIR;
|
||||
else if (strcasecmp(de->d_name+10,"lo") == 0)
|
||||
isflo=OUT_FLO;
|
||||
else if (strcasecmp(de->d_name+9,"req") == 0)
|
||||
isflo=OUT_REQ;
|
||||
else if (strcasecmp(de->d_name+9,"pol") == 0)
|
||||
isflo=OUT_POL;
|
||||
else
|
||||
isflo=-1;
|
||||
// Syslog('o' ,"%s \"%s\"", (isflo == OUT_FLO) ? "flo file" : "packet", de->d_name);
|
||||
if ((rc=fn(&addr,flavor,isflo,fname)))
|
||||
goto exout;
|
||||
} else if ((strncasecmp(de->d_name+9,"su",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"mo",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"tu",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"we",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"th",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"fr",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"sa",2) == 0)) {
|
||||
isflo = OUT_ARC;
|
||||
if ((rc = fn(&addr, flavor, isflo, fname)))
|
||||
goto exout;
|
||||
if ((strcasecmp(de->d_name+9,"pnt") == 0) && !ispoint) {
|
||||
sscanf(de->d_name,"%04x%04x",&addr.net,&addr.node);
|
||||
if ((rc = scan_dir(fn, fname, 1)))
|
||||
goto exout;
|
||||
} else if ((strcasecmp(de->d_name+8,".out") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".cut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".iut") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".opk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".cpk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hpk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".ipk") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".flo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".clo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".hlo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".ilo") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".req") == 0) ||
|
||||
(strcasecmp(de->d_name+8,".pol") == 0)) {
|
||||
if (ispoint)
|
||||
sscanf(de->d_name,"%08x", &addr.point);
|
||||
else
|
||||
sscanf(de->d_name,"%04x%04x", &addr.net,&addr.node);
|
||||
flavor = tolower(de->d_name[9]);
|
||||
if (flavor == 'f')
|
||||
flavor='o';
|
||||
if (strcasecmp(de->d_name+10,"ut") == 0)
|
||||
isflo=OUT_PKT;
|
||||
else if (strcasecmp(de->d_name+10,"pk") == 0)
|
||||
isflo=OUT_DIR;
|
||||
else if (strcasecmp(de->d_name+10,"lo") == 0)
|
||||
isflo=OUT_FLO;
|
||||
else if (strcasecmp(de->d_name+9,"req") == 0)
|
||||
isflo=OUT_REQ;
|
||||
else if (strcasecmp(de->d_name+9,"pol") == 0)
|
||||
isflo=OUT_POL;
|
||||
else
|
||||
isflo=-1;
|
||||
if ((rc=fn(&addr,flavor,isflo,fname)))
|
||||
goto exout;
|
||||
} else if ((strncasecmp(de->d_name+9,"su",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"mo",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"tu",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"we",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"th",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"fr",2) == 0) ||
|
||||
(strncasecmp(de->d_name+9,"sa",2) == 0)) {
|
||||
isflo = OUT_ARC;
|
||||
if ((rc = fn(&addr, flavor, isflo, fname)))
|
||||
goto exout;
|
||||
|
||||
// Syslog('o' ,"arcmail file \"%s\"",de->d_name);
|
||||
sprintf(fname, "%s/%s", dname, de->d_name);
|
||||
fage = (int)((t_start - file_time(fname)) / 86400);
|
||||
sprintf(fname, "%s/%s", dname, de->d_name);
|
||||
fage = (int)((t_start - file_time(fname)) / 86400);
|
||||
|
||||
if (file_size(fname) == 0) {
|
||||
// Syslog('o', "Age %d days", fage);
|
||||
/*
|
||||
* Remove truncated ARCmail that has a day extension
|
||||
* other then the current day or if the file is older
|
||||
* then 6 days.
|
||||
*/
|
||||
if ((strncasecmp(de->d_name+9, dayname(), 2)) || (fage > 6)) {
|
||||
if (unlink(fname) == 0)
|
||||
Syslog('-', "Removed truncated ARCmail file %s", fname);
|
||||
}
|
||||
}
|
||||
|
||||
if (CFG.toss_days && (fage > CFG.toss_days)) {
|
||||
/*
|
||||
* Remove ARCmail that is on hold too long.
|
||||
*/
|
||||
if (unlink(fname) == 0)
|
||||
Syslog('+', "Removed ARCmail %s, %d days", fname, fage);
|
||||
}
|
||||
} else {
|
||||
// Syslog('o' ,"skipping \"%s\"",de->d_name);
|
||||
if (file_size(fname) == 0) {
|
||||
/*
|
||||
* Remove truncated ARCmail that has a day extension
|
||||
* other then the current day or if the file is older
|
||||
* then 6 days.
|
||||
*/
|
||||
if ((strncasecmp(de->d_name+9, dayname(), 2)) || (fage > 6)) {
|
||||
if (unlink(fname) == 0)
|
||||
Syslog('-', "Removed truncated ARCmail file %s", fname);
|
||||
}
|
||||
}
|
||||
|
||||
if (CFG.toss_days && (fage > CFG.toss_days)) {
|
||||
/*
|
||||
* Remove ARCmail that is on hold too long.
|
||||
*/
|
||||
if (unlink(fname) == 0)
|
||||
Syslog('+', "Removed ARCmail %s, %d days", fname, fage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exout:
|
||||
closedir(dp);
|
||||
return rc;
|
||||
closedir(dp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int scanout(int (*fn)(faddr *, char, int, char *))
|
||||
{
|
||||
int i, j, rc = 0;
|
||||
unsigned short zone = 0;
|
||||
char fext[5];
|
||||
char *p = NULL, *q = NULL;
|
||||
DIR *dp;
|
||||
int i, j, rc = 0;
|
||||
unsigned short zone = 0;
|
||||
char fext[5], *p = NULL, *q = NULL;
|
||||
DIR *dp;
|
||||
|
||||
if ((dp = opendir(CFG.outbound)) == NULL) {
|
||||
Syslog('?', "$Can't open outbound directory \"%s\" for reading", MBSE_SS(CFG.outbound));
|
||||
return 1;
|
||||
}
|
||||
closedir(dp);
|
||||
if ((dp = opendir(CFG.outbound)) == NULL) {
|
||||
Syslog('?', "$Can't open outbound directory \"%s\" for reading", MBSE_SS(CFG.outbound));
|
||||
return 1;
|
||||
}
|
||||
closedir(dp);
|
||||
|
||||
/*
|
||||
* Build outbound directory names with zone numbers.
|
||||
*/
|
||||
for (i = 0; i < 40; i++) {
|
||||
if ((CFG.aka[i].zone) && (CFG.aka[i].zone != zone)) {
|
||||
zone = CFG.aka[i].zone;
|
||||
if (SearchFidonet(zone)) {
|
||||
for (j = 0; j < 6; j++) {
|
||||
/*
|
||||
* Create outbound directory name for
|
||||
* the primary aka of that zone.
|
||||
*/
|
||||
p = xstrcpy(CFG.outbound);
|
||||
if (zone != CFG.aka[0].zone) {
|
||||
if ((q = strrchr(p, '/')))
|
||||
*q = '\0';
|
||||
p = xstrcat(p, (char *)"/");
|
||||
p = xstrcat(p, fidonet.domain);
|
||||
}
|
||||
/*
|
||||
* Build outbound directory names with zone numbers.
|
||||
*/
|
||||
for (i = 0; i < 40; i++) {
|
||||
if ((CFG.aka[i].zone) && (CFG.aka[i].zone != zone)) {
|
||||
zone = CFG.aka[i].zone;
|
||||
if (SearchFidonet(zone)) {
|
||||
for (j = 0; j < 6; j++) {
|
||||
/*
|
||||
* Create outbound directory name for the primary aka of that zone.
|
||||
*/
|
||||
p = xstrcpy(CFG.outbound);
|
||||
if (zone != CFG.aka[0].zone) {
|
||||
if ((q = strrchr(p, '/')))
|
||||
*q = '\0';
|
||||
p = xstrcat(p, (char *)"/");
|
||||
p = xstrcat(p, fidonet.domain);
|
||||
}
|
||||
|
||||
/*
|
||||
* Not primary zones in the domain get
|
||||
* a directory extension.
|
||||
*/
|
||||
if (fidonet.zone[j]) {
|
||||
if (j) {
|
||||
sprintf(fext, ".%03x", fidonet.zone[j]);
|
||||
p = xstrcat(p, fext);
|
||||
}
|
||||
// Syslog('o', "Zone %d Dir %s", fidonet.zone[j], p);
|
||||
addr.zone = fidonet.zone[j];
|
||||
addr.domain = fidonet.domain;
|
||||
|
||||
if ((rc = scan_dir(fn, p, 0))) {
|
||||
if (p)
|
||||
free(p);
|
||||
p = NULL;
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (p)
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
/*
|
||||
* Not primary zones in the domain get a directory extension.
|
||||
*/
|
||||
if (fidonet.zone[j]) {
|
||||
if (j) {
|
||||
sprintf(fext, ".%03x", fidonet.zone[j]);
|
||||
p = xstrcat(p, fext);
|
||||
}
|
||||
addr.zone = fidonet.zone[j];
|
||||
addr.domain = fidonet.domain;
|
||||
if ((rc = scan_dir(fn, p, 0))) {
|
||||
if (p)
|
||||
free(p);
|
||||
p = NULL;
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (p)
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user