Finished new outbound queue

This commit is contained in:
Michiel Broek
2002-08-05 20:43:29 +00:00
parent 79327388e9
commit 445582946a
8 changed files with 319 additions and 243 deletions

View File

@@ -146,7 +146,7 @@ sendmail.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/
tracker.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbftn.h tracker.h
addpkt.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/dbmsgs.h addpkt.h
bwrite.o: ../config.h ../lib/libs.h ../lib/memwatch.h bwrite.h
forward.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbtic.h ../lib/diesel.h tic.h sendmail.h rollover.h mgrutil.h forward.h dirsession.h
forward.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbtic.h ../lib/diesel.h tic.h sendmail.h rollover.h mgrutil.h forward.h
lhash.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h lhash.h
mbfido.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbdupe.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbuser.h ../lib/dbftn.h ../lib/dbtic.h ../lib/msg.h flock.h tosspkt.h unpack.h tic.h fsort.h scan.h mbfido.h tracker.h notify.h rollover.h hatch.h scannews.h maketags.h makestat.h newspost.h rnews.h mgrutil.h backalias.h rfc2ftn.h dirsession.h dirlock.h queue.h
mkftnhdr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h atoul.h hash.h msgflags.h aliasdb.h mkftnhdr.h

View File

@@ -44,14 +44,13 @@
#include "rollover.h"
#include "mgrutil.h"
#include "forward.h"
#include "dirsession.h"
void ForwardFile(fidoaddr Node, fa_list *sbl)
{
char *subject = NULL, *temp, *fwdfile = NULL, *ticfile = NULL, fname[PATH_MAX], *ticname, flavor;
FILE *fp, *fi, *net;
char *subject = NULL, *temp, *fwdfile = NULL, *queuedir, *listfile, *ticfile = NULL, fname[PATH_MAX], *ticname, flavor;
FILE *fp, *fi, *fl, *net;
faddr *dest, *routeto, *Fa, *Temp, *ba;
int i, z, n;
time_t now, ftime;
@@ -90,7 +89,20 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
}
}
fwdfile = calloc(PATH_MAX, sizeof(char));
fwdfile = calloc(PATH_MAX, sizeof(char));
queuedir = calloc(PATH_MAX, sizeof(char));
listfile = calloc(PATH_MAX, sizeof(char));
sprintf(queuedir, "%s/%d.%d.%d.%d", CFG.out_queue, Node.zone, Node.net, Node.node, Node.point);
sprintf(listfile, "%s/.filelist", queuedir);
mkdirs(listfile, 0750);
if ((fl = fopen(listfile, "a+")) == NULL) {
WriteError("$Can't open %s", listfile);
free(fwdfile);
free(listfile);
free(queuedir);
return;
}
Syslog('f', "%s is open", listfile);
/*
* Create the full filename
@@ -109,39 +121,13 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
if (nodes.Hold)
flavor = 'h';
fprintf(fl, "%c LEAVE %s\n", flavor, fwdfile);
if (nodes.RouteVia.zone)
routeto = fido2faddr(nodes.RouteVia);
else
routeto = fido2faddr(Node);
dest = fido2faddr(Node);
if (nodes.Session_out == S_DIR) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr, 'p')) {
/*
* Not good, should go to a queue
*/
attach(*routeto, fwdfile, LEAVE, flavor);
} else {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p')) {
/*
* Not good again
*/
attach(*routeto, fwdfile, LEAVE, flavor);
} else {
/*
* Node locked, copy file to destination directory
*/
ticfile = calloc(PATH_MAX, sizeof(char));
sprintf(ticfile, "%s/%s", nodes.Dir_out_path, subject);
if (file_cp(fwdfile, ticfile))
WriteError("$Can't copy %s to %s", fwdfile, ticfile);
else
chmod(ticfile, 0660);
free(ticfile);
}
}
} else {
attach(*routeto, fwdfile, LEAVE, flavor);
}
ticfile = calloc(PATH_MAX, sizeof(char));
ticname = calloc(15, sizeof(char));
@@ -149,10 +135,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
sprintf(ticname, "%08lx.tic", sequencer());
subject = xstrcat(subject, (char *)" ");
subject = xstrcat(subject, ticname);
if (nodes.Session_out == S_DIR)
sprintf(ticfile, "%s/%s", nodes.Dir_out_path, ticname);
else
sprintf(ticfile, "%s/%s", CFG.ticout, ticname);
sprintf(ticfile, "%s/%s", CFG.ticout, ticname);
}
free(ticname);
@@ -316,8 +299,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
fprintf(fp, "Pw %s\r\n", nodes.Fpasswd);
fclose(fp);
if (nodes.Session_out == S_DIRECT)
attach(*routeto, ticfile, KFS, flavor);
fprintf(fl, "%c KFS %s\n", flavor, ticfile);
} else {
WriteError("$Can't create %s", ticfile);
}
@@ -346,10 +328,9 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
WriteError("$Can't create %s", fname);
}
}
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p');
fsync(fileno(fl));
fclose(fl);
/*
* Update the nodes statistic counters
*/
@@ -359,6 +340,8 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
SearchNode(Node);
free(ticfile);
free(fwdfile);
free(queuedir);
free(listfile);
tidy_faddr(routeto);
}

View File

@@ -50,6 +50,10 @@ static char *dow[] = {(char *)"su", (char *)"mo", (char *)"tu", (char *)"we",
extern int do_quiet;
/*
* Flush one queue directory of a node. If everything is successfull the
* directory will become empty.
*/
void flush_dir(char *);
void flush_dir(char *ndir)
{
@@ -58,9 +62,9 @@ void flush_dir(char *ndir)
FILE *fp, *inf, *ouf;
faddr noden, *bestaka;
fidoaddr nodenr;
int flavor, Attach, fage, first, bread;
int flavor, mode, Attach, fage, first, bread, rc;
long fsize;
char *temp, *fname, *arcfile, *pktfile, *ext, maxnr, nr, oldnr, *buf;
char *p, *temp, *fname, *arcfile, *pktfile, *ext, maxnr, nr, oldnr, *buf;
time_t Now;
struct tm *ptm;
struct stat sbuf;
@@ -192,7 +196,7 @@ void flush_dir(char *ndir)
Syslog('p', "Arcmail file %s", arcfile);
/*
* If a not finished .pkt file exist, close it first and rename it.
* If there is a mailpkt.qqq file, close it and rename it.
*/
pktfile = calloc(PATH_MAX, sizeof(char));
fname = calloc(PATH_MAX, sizeof(char));
@@ -487,8 +491,70 @@ void flush_dir(char *ndir)
}
Syslog('p', "Done with netmail");
// Add files
/*
* Now add the files for the node, information is in the .filelist
* file, this tells the location of the file and what to do with
* it after it is sent.
*/
sprintf(pktfile, "%s/.filelist", temp);
if ((fp = fopen(pktfile, "r")) != NULL) {
Syslog('+', "Adding files for %s, via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
if (!do_quiet) {
printf("\rAdding files for %s ", ascfnode(&noden, 0x1f));
fflush(stdout);
}
buf = calloc(PATH_MAX + 1, sizeof(char));
while (fgets(buf, PATH_MAX, fp)) {
Striplf(buf);
Syslog('p', "File: %s", buf);
flavor = buf[0];
p = strchr(buf, ' ');
p++;
if (strncmp(p, "LEAVE ", 6) == 0)
mode = LEAVE;
else if (strncmp(p, "KFS ", 4) == 0)
mode = KFS;
else if (strncmp(p, "TFS ", 4) == 0)
mode = TFS;
else {
WriteError("Syntax error in filelist \"%s\"", buf);
mode = LEAVE;
}
p = strchr(p, ' ');
p++;
Syslog('+', "File attach %s", p);
if (nodes.Session_out == S_DIRECT) {
attach(noden, p, mode, flavor);
} else if (nodes.Session_out == S_DIR) {
sprintf(arcfile, "%s/%s", nodes.Dir_out_path, basename(p));
if (mode == LEAVE) {
/*
* LEAVE file, so we copy this one.
*/
rc = file_cp(p, arcfile);
Syslog('p', "file_cp(%s, %s) rc=%d", p, arcfile, rc);
} else {
/*
* KFS or TFS, move file to node directory
*/
rc = file_mv(p, arcfile);
Syslog('p', "file_mv(%s, %s) rc=%d", p, arcfile, rc);
}
chmod(arcfile, 0660);
}
Syslog('p', "%c %d %s", flavor, mode, pktfile);
}
free(buf);
fclose(fp);
unlink(pktfile);
}
/*
* We are done, the queue is flushed, unlock the node.

View File

@@ -783,7 +783,7 @@ void ExportNet(unsigned long MsgNum, int UUCPgate)
{
char *p, *q, ext[4], fromname[37], flavor, MailFrom[128], MailTo[128];
int i, rc, flags = 0, first, is_fmpt = FALSE, is_topt = FALSE, is_intl = FALSE;
FILE *qp, *fp;
FILE *qp, *fp, *fl;
fidoaddr Dest, Route, *dest;
time_t now;
struct tm *tm;
@@ -1041,12 +1041,22 @@ void ExportNet(unsigned long MsgNum, int UUCPgate)
flavor = 'f';
ta = parsefnode(Msg.ToAddress);
if (strlen(CFG.dospath)) {
rc = attach(*ta, Dos2Unix(Msg.Subject), LEAVE, flavor);
Syslog('+', "FileAttach %s %s", Dos2Unix(Msg.Subject), rc ? "Success":"Failed");
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/%d.%d.%d.%d/.filelist", CFG.out_queue, ta->zone, ta->net, ta->node, ta->point);
mkdirs(p, 0750);
if ((fl = fopen(p, "a+")) == NULL) {
WriteError("$Can't open %s", p);
} else {
rc = attach(*ta, Msg.Subject, LEAVE, flavor);
Syslog('+', "FileAttach %s %s", Msg.Subject, rc ? "Success":"Failed");
if (strlen(CFG.dospath)) {
fprintf(fl, "%c LEAVE %s\n", flavor, Dos2Unix(Msg.Subject));
Syslog('+', "FileAttach %s", Dos2Unix(Msg.Subject));
} else {
fprintf(fl, "%c LEAVE %s\n", flavor, Msg.Subject);
Syslog('+', "FileAttach %s", Msg.Subject);
}
fsync(fileno(fl));
fclose(fl);
}
tidy_faddr(ta);
}