Revised TIC file processing
This commit is contained in:
parent
8eebc55e6d
commit
8094a0d1d7
2
TODO
2
TODO
@ -66,6 +66,8 @@ mbfido:
|
||||
N: Also check for file_id.diz filenames.
|
||||
|
||||
mbcico:
|
||||
U: Implement nodes FNC flag for sending files.
|
||||
|
||||
L: Implement modem connect response translation for ISDN lines, i.e.
|
||||
make the CAUSE responses human readable. see McMail for this
|
||||
option.
|
||||
|
@ -1401,7 +1401,6 @@ typedef enum {
|
||||
MG_MOVE, /* Move to other area */
|
||||
MG_UPDALIAS, /* Update alias */
|
||||
MG_ADOPT, /* Adopt file */
|
||||
MG_OTHER, /* Store in other path */
|
||||
MG_DELETE /* Delete file */
|
||||
} MAGICTYPE;
|
||||
|
||||
|
@ -82,7 +82,7 @@ int Add_BBS()
|
||||
if (strlen(TIC.TicIn.Magic))
|
||||
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
|
||||
|
||||
sprintf(temp1, "%s%s", TIC.FilePath, TIC.NewName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
|
||||
mkdirs(temp2);
|
||||
|
||||
@ -113,7 +113,6 @@ int Add_BBS()
|
||||
if (ftell(fdb) == 0) {
|
||||
fwrite(&frec, sizeof(frec), 1, fdb);
|
||||
fclose(fdb);
|
||||
if (!TIC.NoMove)
|
||||
file_rm(temp1);
|
||||
tic_imp++;
|
||||
return TRUE;
|
||||
@ -216,10 +215,8 @@ int Add_BBS()
|
||||
/*
|
||||
* Delete file from the inbound
|
||||
*/
|
||||
if (!TIC.NoMove) {
|
||||
if ((i = file_rm(temp1)))
|
||||
WriteError("$ %d = file_rm(%s)", i, temp1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the replace option.
|
||||
|
@ -88,7 +88,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
||||
* Create the full filename
|
||||
*/
|
||||
if (TIC.SendOrg)
|
||||
sprintf(fwdfile, "%s/%s", TIC.FilePath, TIC.TicIn.OrgName);
|
||||
sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
else
|
||||
sprintf(fwdfile, "%s/%s", TIC.BBSpath, TIC.NewName);
|
||||
|
||||
@ -129,7 +129,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
||||
fprintf(net, "\r");
|
||||
fprintf(net, "I sent the following file to your system:\r");
|
||||
fprintf(net, "\r");
|
||||
fprintf(net, "File : %s\r", TIC.TicIn.OrgName);
|
||||
fprintf(net, "File : %s\r", TIC.RealName);
|
||||
fprintf(net, "Description : %s\r", TIC.TicIn.Desc);
|
||||
fprintf(net, "Area : %s %s\r", TIC.TicIn.Area, TIC.TicIn.AreaDesc);
|
||||
fprintf(net, "Size : %ld\r", (long)(TIC.FileSize));
|
||||
@ -167,7 +167,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
||||
if (strlen(TIC.TicIn.Magic))
|
||||
fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic);
|
||||
if ((TIC.PassThru) || (TIC.SendOrg))
|
||||
subject = xstrcpy(TIC.TicIn.OrgName);
|
||||
subject = xstrcpy(TIC.RealName);
|
||||
else
|
||||
subject = xstrcpy(TIC.NewName);
|
||||
if (nodes.FNC) {
|
||||
|
@ -211,7 +211,7 @@ int Magic_MoveFile(void)
|
||||
{
|
||||
if (GetMagicRec(MG_MOVE, TRUE)) {
|
||||
strcpy(TIC.TicIn.Area, magic.ToArea);
|
||||
MagicResult((char *)"Move %s to Area %s", TIC.TicIn.OrgName, TIC.TicIn.Area);
|
||||
MagicResult((char *)"Move %s to Area %s", TIC.RealName, TIC.TicIn.Area);
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
@ -293,21 +293,6 @@ void Magic_CopyFile(void)
|
||||
|
||||
|
||||
|
||||
void Magic_OtherPath(void)
|
||||
{
|
||||
if (GetMagicRec(MG_OTHER, TRUE)) {
|
||||
if (access(magic.Path, W_OK) == 0) {
|
||||
strcpy(TIC.BBSpath, magic.Path);
|
||||
MagicResult((char *)"Otherpath %s", TIC.BBSpath);
|
||||
TIC.OtherPath = TRUE;
|
||||
} else {
|
||||
WriteError("$Magic: otherpath \"%s\" no access", magic.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Magic_UnpackFile(void)
|
||||
{
|
||||
int rc, First = TRUE;
|
||||
|
@ -7,7 +7,6 @@ void MagicResult(char *, ...);
|
||||
int Magic_MoveFile(void);
|
||||
void Magic_ExecCommand(void);
|
||||
void Magic_CopyFile(void);
|
||||
void Magic_OtherPath(void);
|
||||
void Magic_UnpackFile(void);
|
||||
void Magic_Keepnum(void);
|
||||
void Magic_UpDateAlias(void);
|
||||
|
@ -1,8 +1,7 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File ..................: mbfido/mover.c
|
||||
* $Id$
|
||||
* Purpose ...............: Bad file mover
|
||||
* Last modification date : 02-Nov-1999
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-1999
|
||||
@ -39,15 +38,15 @@
|
||||
|
||||
|
||||
|
||||
void mover(char *srcdir, char *fn)
|
||||
void mover(char *fn)
|
||||
{
|
||||
char *From, *To;
|
||||
|
||||
From = calloc(128, sizeof(char));
|
||||
To = calloc(128, sizeof(char));
|
||||
From = calloc(PATH_MAX, sizeof(char));
|
||||
To = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
sprintf(From, "%s%s", srcdir, fn);
|
||||
sprintf(To, "%s/%s", CFG.badtic, fn);
|
||||
sprintf(From, "%s/%s", TIC.Inbound, fn);
|
||||
sprintf(To, "%s/%s", TIC.Inbound, fn);
|
||||
Syslog('!', "Moving %s to %s", From, To);
|
||||
|
||||
if (mkdirs(To)) {
|
||||
@ -66,8 +65,8 @@ void mover(char *srcdir, char *fn)
|
||||
*/
|
||||
void MoveBad()
|
||||
{
|
||||
mover(TIC.Inbound, TIC.TicName);
|
||||
mover(TIC.FilePath, TIC.TicIn.OrgName);
|
||||
mover(TIC.TicName);
|
||||
mover(TIC.RealName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _MOVER_H
|
||||
#define _MOVER_H
|
||||
|
||||
|
||||
void mover(char *, char *);
|
||||
void mover(char *);
|
||||
void MoveBad(void);
|
||||
|
||||
|
||||
|
183
mbfido/ptic.c
183
mbfido/ptic.c
@ -66,15 +66,15 @@ extern int check_dupe;
|
||||
* 1 - Some error
|
||||
* 2 - Orphaned tic
|
||||
*/
|
||||
int ProcessTic(fa_list *sbl, char *Realname)
|
||||
int ProcessTic(fa_list *sbl)
|
||||
{
|
||||
time_t Now, Fdate;
|
||||
int Age, First, Listed = FALSE;
|
||||
int DownLinks = 0;
|
||||
int MustRearc = FALSE, MustVirus = FALSE;
|
||||
int IsVirus = FALSE, UnPacked = FALSE, IsArchive = FALSE;
|
||||
int MustRearc = FALSE;
|
||||
int UnPacked = FALSE, IsArchive = FALSE;
|
||||
int i, j, k, File_Id = FALSE;
|
||||
char *Temp, *Temp2, *unarc = NULL, *cmd = NULL;
|
||||
char *Temp, *unarc = NULL, *cmd = NULL;
|
||||
char temp1[PATH_MAX], temp2[PATH_MAX], sbe[24], TDesc[256];
|
||||
unsigned long crc, crc2, Kb;
|
||||
sysconnect Link;
|
||||
@ -86,13 +86,12 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
|
||||
time(&Now);
|
||||
|
||||
if (TIC.PathErr) {
|
||||
if (TIC.TicIn.PathError) {
|
||||
WriteError("Our Aka is in the path");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(Temp, "%s%s", TIC.FilePath, TIC.TicIn.OrgName);
|
||||
|
||||
if (!do_quiet) {
|
||||
colour(10, 0);
|
||||
@ -100,40 +99,27 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
* A hack to work around received uppercase or mixed case filenames.
|
||||
*/
|
||||
Temp2 = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(Temp2, "%s%s", TIC.FilePath, Realname);
|
||||
Syslog('f', "Realname with path \"%s\"", Temp2);
|
||||
if (file_exist(Temp, R_OK) && !file_exist(Temp2, R_OK)) {
|
||||
if (rename(Temp2, Temp))
|
||||
WriteError("$Rename %s to %s failed", Temp2, Temp);
|
||||
else
|
||||
Syslog('f', "File %s renamed to %s", Temp2, Temp);
|
||||
}
|
||||
free(Temp2);
|
||||
|
||||
crc = file_crc(Temp, CFG.slow_util && do_quiet);
|
||||
if (crc == -1) {
|
||||
WriteError("File not in inbound: %s", Temp);
|
||||
if (strlen(TIC.RealName) == 0) {
|
||||
WriteError("File not in inbound: %s", TIC.TicIn.File);
|
||||
/*
|
||||
* Now check the age of the .tic file.
|
||||
*/
|
||||
sprintf(Temp, "%s%s", TIC.Inbound, TIC.TicName);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||
Fdate = file_time(Temp);
|
||||
Age = (Now - Fdate) / 84400;
|
||||
Syslog('+', "Orphaned tic age %d days", Age);
|
||||
|
||||
if (Age > 21) {
|
||||
tic_bad++;
|
||||
mover(TIC.Inbound, TIC.TicName);
|
||||
mover(TIC.TicName);
|
||||
}
|
||||
|
||||
free(Temp);
|
||||
return 2;
|
||||
}
|
||||
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
crc = file_crc(Temp, CFG.slow_util && do_quiet);
|
||||
TIC.FileSize = file_size(Temp);
|
||||
TIC.FileDate = file_time(Temp);
|
||||
|
||||
@ -146,7 +132,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
if (crc != TIC.Crc_Int) {
|
||||
Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc);
|
||||
if (check_crc) {
|
||||
Bad((char *)"CRC: error, %s may be damaged", TIC.TicIn.OrgName);
|
||||
Bad((char *)"CRC: error, %s may be damaged", TIC.RealName);
|
||||
free(Temp);
|
||||
return 1;
|
||||
} else {
|
||||
@ -168,7 +154,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((tic.Secure) && (!TIC.Hatch)) {
|
||||
if ((tic.Secure) && (!TIC.TicIn.Hatch)) {
|
||||
First = TRUE;
|
||||
while (GetTicSystem(&Link, First)) {
|
||||
First = FALSE;
|
||||
@ -188,13 +174,13 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
}
|
||||
|
||||
if ((!SearchNode(TIC.Aka)) && (!TIC.Hatch)) {
|
||||
if ((!SearchNode(TIC.Aka)) && (!TIC.TicIn.Hatch)) {
|
||||
Bad((char *)"%s NOT known", aka2str(TIC.Aka));
|
||||
free(Temp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!TIC.Hatch) {
|
||||
if (!TIC.TicIn.Hatch) {
|
||||
if (strcasecmp(TIC.TicIn.Pw, nodes.Fpasswd)) {
|
||||
Bad((char *)"Pwd error, got %s, expected %s", TIC.TicIn.Pw, nodes.Fpasswd);
|
||||
free(Temp);
|
||||
@ -210,9 +196,10 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
|
||||
if (Magic_DeleteFile()) {
|
||||
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||
file_rm(temp1);
|
||||
Syslog('+', "Deleted file %s", temp1);
|
||||
file_rm(Temp);
|
||||
free(Temp);
|
||||
return 0;
|
||||
}
|
||||
@ -269,11 +256,6 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
strcpy(T_File.Comment, tic.Comment);
|
||||
|
||||
/*
|
||||
* The destination may be changed now.
|
||||
*/
|
||||
Magic_OtherPath();
|
||||
|
||||
/*
|
||||
* Check if the destination area really exists, it may be that
|
||||
* the area is not linked to an existing BBS area.
|
||||
@ -312,7 +294,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
*/
|
||||
T_File.Size = TIC.FileSize;
|
||||
T_File.SizeKb = TIC.FileSize / 1024;
|
||||
if ((fgroup.UnitCost) || (TIC.TicIn.UplinkCost))
|
||||
if ((fgroup.UnitCost) || (TIC.TicIn.Cost))
|
||||
TIC.Charge = TRUE;
|
||||
else
|
||||
TIC.Charge = FALSE;
|
||||
@ -333,8 +315,8 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
else
|
||||
TIC.FileCost = FwdCost;
|
||||
|
||||
if (TIC.TicIn.UplinkCost)
|
||||
TIC.FileCost += TIC.TicIn.UplinkCost;
|
||||
if (TIC.TicIn.Cost)
|
||||
TIC.FileCost += TIC.TicIn.Cost;
|
||||
|
||||
if (fgroup.AddProm)
|
||||
TIC.FileCost += (TIC.FileCost * fgroup.AddProm / 1000);
|
||||
@ -361,9 +343,10 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
*/
|
||||
Kb = TIC.FileSize / 1024;
|
||||
if (SearchNode(TIC.Aka)) {
|
||||
nodes.Debet -= TIC.TicIn.UplinkCost;
|
||||
if (TIC.TicIn.UplinkCost)
|
||||
Syslog('f', "Uplink cost %ld, debet %ld", TIC.TicIn.UplinkCost, nodes.Debet);
|
||||
if (TIC.TicIn.Cost) {
|
||||
nodes.Debet -= TIC.TicIn.Cost;
|
||||
Syslog('f', "Uplink cost %ld, debet %ld", TIC.TicIn.Cost, nodes.Debet);
|
||||
}
|
||||
StatAdd(&nodes.FilesRcvd, 1L);
|
||||
StatAdd(&nodes.F_KbRcvd, Kb);
|
||||
UpdateNode();
|
||||
@ -381,34 +364,18 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
tic.LastAction = time(NULL);
|
||||
UpdateTic();
|
||||
|
||||
if (!TIC.HatchNew) {
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("Unpacking \b\b\b\b\b\b\b\b\b\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the file to the inbound directory if it isn't
|
||||
* already there (needed by unpacker).
|
||||
*/
|
||||
if (strcmp(TIC.FilePath,TIC.Inbound)) {
|
||||
sprintf(temp1, "%s%s", TIC.FilePath, TIC.TicIn.OrgName);
|
||||
sprintf(temp2, "%s%s", TIC.Inbound, TIC.TicIn.OrgName);
|
||||
if (!file_mv(temp1, temp2)) {
|
||||
sprintf(TIC.FilePath, "%s/", TIC.Inbound);
|
||||
} else {
|
||||
WriteError("Can't move %s to inbound", temp1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if this is an archive, and if so, compression method
|
||||
* Check if this is an archive, and if so, which compression method
|
||||
* is used for this file.
|
||||
*/
|
||||
if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) {
|
||||
if ((unarc = unpacker(TIC.TicIn.OrgName)) == NULL)
|
||||
Syslog('+', "Unknown archive format %s", TIC.TicIn.OrgName);
|
||||
if ((unarc = unpacker(TIC.RealName)) == NULL)
|
||||
Syslog('+', "Unknown archive format %s", TIC.RealName);
|
||||
else {
|
||||
IsArchive = TRUE;
|
||||
if ((strlen(tic.Convert) && (strcmp(unarc, tic.Convert) == 0)) || (tic.ConvertAll))
|
||||
@ -422,8 +389,8 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
* it's a passthru area.
|
||||
*/
|
||||
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
|
||||
sprintf(temp1, "%s%s", TIC.FilePath, TIC.TicIn.OrgName);
|
||||
sprintf(temp2, "%s/%s", CFG.ticout, TIC.TicIn.OrgName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
sprintf(temp2, "%s/%s", CFG.ticout, TIC.RealName);
|
||||
if (file_cp(temp1, temp2) == 0) {
|
||||
TIC.SendOrg = TRUE;
|
||||
} else {
|
||||
@ -431,10 +398,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
}
|
||||
|
||||
if ((tic.VirScan) && (IsArchive))
|
||||
MustVirus = TRUE;
|
||||
|
||||
if (MustVirus || MustRearc) {
|
||||
if ((tic.VirScan || MustRearc) && IsArchive) {
|
||||
|
||||
/*
|
||||
* Check if there is a temp directory for the archive
|
||||
@ -453,13 +417,19 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
* Check for stale FILE_ID.DIZ files
|
||||
*/
|
||||
sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||
if (!unlink(temp1))
|
||||
Syslog('+', "Removed stale %s", temp1);
|
||||
sprintf(temp1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||
if (!unlink(temp1))
|
||||
Syslog('+', "Removed stale %s", temp1);
|
||||
sprintf(temp1, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||
if (!unlink(temp1))
|
||||
Syslog('+', "Removed stale %s", temp1);
|
||||
sprintf(temp1, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
||||
if (!unlink(temp1))
|
||||
Syslog('+', "Removed stale %s", temp1);
|
||||
|
||||
if (!checkspace(temp2, TIC.TicIn.OrgName, UNPACK_FACTOR)) {
|
||||
if (!checkspace(temp2, TIC.RealName, UNPACK_FACTOR)) {
|
||||
Bad((char *)"Not enough free diskspace left");
|
||||
free(Temp);
|
||||
return 1;
|
||||
@ -482,7 +452,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
if ((cmd == NULL) || (cmd == "")) {
|
||||
Syslog('!', "No unarc command available");
|
||||
} else {
|
||||
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicIn.OrgName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||
UnPacked = TRUE;
|
||||
} else {
|
||||
@ -496,15 +466,39 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
}
|
||||
|
||||
if (MustVirus && UnPacked) {
|
||||
if (tic.VirScan && !UnPacked) {
|
||||
/*
|
||||
* Copy file to tempdir and run scanner over the file
|
||||
* whatever that is. This should catch single files
|
||||
* with worms or other macro viri
|
||||
*/
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.RealName);
|
||||
|
||||
if (file_cp(temp1, temp2)) {
|
||||
WriteError("Can't copy %s to %s", temp1, temp2);
|
||||
free(Temp);
|
||||
return 1;
|
||||
} else {
|
||||
Syslog('f', "file_cp(%s, %s) ok", temp1, temp2);
|
||||
}
|
||||
|
||||
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||
if (chdir(temp2) != 0) {
|
||||
WriteError("$Can't change to %s", temp2);
|
||||
free(Temp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (tic.VirScan) {
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
IsVirus = VirScan();
|
||||
if (IsVirus) {
|
||||
if (VirScan()) {
|
||||
DeleteVirusWork();
|
||||
chdir(TIC.Inbound);
|
||||
Bad((char *)"Possible virus found!");
|
||||
@ -517,14 +511,20 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
} /* MustVirus and Unpacked */
|
||||
}
|
||||
|
||||
if (tic.FileId && tic.FileArea && IsArchive) {
|
||||
if (UnPacked) {
|
||||
sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||
sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||
if (file_cp(temp1, temp2) == 0)
|
||||
if (file_cp(temp1, temp2) == 0) {
|
||||
File_Id = TRUE;
|
||||
} else {
|
||||
sprintf(temp1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||
if (file_cp(temp1, temp2) == 0) {
|
||||
File_Id = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!getarchiver(unarc)) {
|
||||
chdir(TIC.Inbound);
|
||||
@ -536,9 +536,16 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
} else {
|
||||
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
||||
chdir(temp1);
|
||||
sprintf(temp1, "%s%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.OrgName);
|
||||
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.RealName);
|
||||
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null",
|
||||
(char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||
File_Id = TRUE;
|
||||
} else {
|
||||
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.RealName);
|
||||
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null",
|
||||
(char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||
File_Id = TRUE;
|
||||
}
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
@ -595,7 +602,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
/*
|
||||
* Get new filesize for import and announce
|
||||
*/
|
||||
sprintf(temp1, "%s%s", TIC.FilePath, TIC.NewName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||
TIC.FileSize = file_size(temp1);
|
||||
T_File.Size = TIC.FileSize;
|
||||
T_File.SizeKb = TIC.FileSize / 1024;
|
||||
@ -619,7 +626,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
if ((cmd == NULL) || (!strlen(cmd))) {
|
||||
Syslog('!', "No banner command for %s", archiver.name);
|
||||
} else {
|
||||
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicIn.OrgName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
|
||||
if (execute(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
|
||||
WriteError("$Changing the banner failed");
|
||||
@ -635,9 +642,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
} /* if MustRearc and Unpacked and not Passthtru */
|
||||
|
||||
if (UnPacked)
|
||||
DeleteVirusWork();
|
||||
|
||||
chdir(TIC.Inbound);
|
||||
|
||||
/*
|
||||
@ -648,19 +653,15 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
if ((!tic.NoTouch) && (tic.FileArea)) {
|
||||
ut.actime = mktime(localtime(&TIC.FileDate));
|
||||
ut.modtime = mktime(localtime(&TIC.FileDate));
|
||||
sprintf(Temp, "%s%s", TIC.FilePath, TIC.NewName);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||
utime(Temp, &ut);
|
||||
}
|
||||
}
|
||||
|
||||
if (tic.FileArea) {
|
||||
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area);
|
||||
|
||||
if (TIC.OtherPath) {
|
||||
/* BBS_Imp = Add_DOS */
|
||||
} else {
|
||||
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area);
|
||||
BBS_Imp = Add_BBS();
|
||||
}
|
||||
|
||||
if (!BBS_Imp) {
|
||||
Bad((char *)"File Import Error");
|
||||
@ -669,11 +670,9 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
}
|
||||
|
||||
} /* Not TIC.HatchNew */
|
||||
|
||||
chdir(TIC.Inbound);
|
||||
|
||||
if ((!TIC.HatchNew) && (tic.FileArea)) {
|
||||
if (tic.FileArea) {
|
||||
if (strlen(TIC.TicIn.Magic))
|
||||
UpDateAlias(TIC.TicIn.Magic);
|
||||
else
|
||||
@ -685,7 +684,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
T_File.Announce = tic.Announce;
|
||||
strcpy(T_File.Name, TIC.NewName);
|
||||
T_File.Fdate = TIC.FileDate;
|
||||
T_File.Cost = TIC.TicIn.UplinkCost;
|
||||
T_File.Cost = TIC.TicIn.Cost;
|
||||
Add_ToBeRep();
|
||||
}
|
||||
|
||||
@ -695,7 +694,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
* file in the inbound anymore so it can be
|
||||
* deleted.
|
||||
*/
|
||||
sprintf(temp1, "%s%s", TIC.FilePath, TIC.TicIn.OrgName);
|
||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
||||
if (file_rm(temp1) == 0)
|
||||
Syslog('f', "Deleted %s", temp1);
|
||||
}
|
||||
@ -746,14 +745,12 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
||||
}
|
||||
}
|
||||
|
||||
if (!TIC.HatchNew) {
|
||||
Magic_ExecCommand();
|
||||
Magic_CopyFile();
|
||||
Magic_UnpackFile();
|
||||
Magic_AdoptFile();
|
||||
}
|
||||
|
||||
sprintf(Temp, "%s%s", TIC.Inbound, TIC.TicName);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||
unlink(Temp);
|
||||
free(Temp);
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _PTIC_H
|
||||
#define _PTIC_H
|
||||
|
||||
int ProcessTic(fa_list *, char *);
|
||||
int ProcessTic(fa_list *);
|
||||
|
||||
#endif
|
||||
|
||||
|
101
mbfido/tic.c
101
mbfido/tic.c
@ -163,7 +163,7 @@ int Tic()
|
||||
int LoadTic(char *inb, char *tfn)
|
||||
{
|
||||
FILE *tfp;
|
||||
char *Temp, *Buf, *Log = NULL;
|
||||
char *Temp, *Temp2, *Buf, *Log = NULL;
|
||||
int i, j, rc;
|
||||
fa_list *sbl = NULL;
|
||||
int DescCnt = FALSE;
|
||||
@ -174,9 +174,8 @@ int LoadTic(char *inb, char *tfn)
|
||||
memset(&TIC, 0, sizeof(TIC));
|
||||
memset(&T_File, 0, sizeof(T_File));
|
||||
|
||||
sprintf(TIC.Inbound, "%s/", inb);
|
||||
sprintf(TIC.FilePath, "%s/", inb);
|
||||
strcpy(TIC.TicName, tfn);
|
||||
sprintf(TIC.Inbound, "%s", inb);
|
||||
strncpy(TIC.TicName, tfn, 12);
|
||||
|
||||
chdir(inb);
|
||||
if ((tfp = fopen(tfn, "r")) == NULL) {
|
||||
@ -184,8 +183,8 @@ int LoadTic(char *inb, char *tfn)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Temp = calloc(256, sizeof(char));
|
||||
Buf = calloc(256, sizeof(char));
|
||||
Temp = calloc(PATH_MAX, sizeof(char));
|
||||
Buf = calloc(257, sizeof(char));
|
||||
|
||||
while ((fgets(Buf, 256, tfp)) != NULL) {
|
||||
/*
|
||||
@ -200,17 +199,12 @@ int LoadTic(char *inb, char *tfn)
|
||||
}
|
||||
Temp[j] = '\0';
|
||||
|
||||
Syslog('f', "TIC: %s", Temp);
|
||||
if (strncasecmp(Temp, "hatch", 5) == 0) {
|
||||
TIC.TicIn.Hatch = TRUE;
|
||||
|
||||
} else if (TIC.TicIn.Hatch && (strncasecmp(Temp, "pth ", 4) == 0)) {
|
||||
sprintf(TIC.TicIn.Pth, "%s/", Temp+4);
|
||||
|
||||
} else if (TIC.TicIn.Hatch && (strncasecmp(Temp, "nomove", 6) == 0)) {
|
||||
TIC.TicIn.NoMove = TRUE;
|
||||
|
||||
} else if (TIC.TicIn.Hatch && (strncasecmp(Temp, "hatchnew", 8) == 0)) {
|
||||
TIC.TicIn.HatchNew = TRUE;
|
||||
strncpy(TIC.TicIn.Pth, Temp+4, PATH_MAX);
|
||||
|
||||
} else if (strncasecmp(Temp, "area ", 5) == 0) {
|
||||
strncpy(TIC.TicIn.Area, Temp+5, 20);
|
||||
@ -229,7 +223,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
|
||||
} else if (strncasecmp(Temp, "fullname ", 9) == 0) {
|
||||
strncpy(TIC.TicIn.FullName, Temp+9, 80);
|
||||
Syslog('f', "Long filename: %s", TIC.TicIn.LName);
|
||||
Syslog('f', "Long filename: %s", TIC.TicIn.FullName);
|
||||
|
||||
} else if (strncasecmp(Temp, "created ", 8) == 0) {
|
||||
strncpy(TIC.TicIn.Created, Temp+8, 80);
|
||||
@ -337,7 +331,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
printf("\r");
|
||||
for (i = 0; i < 79; i++)
|
||||
printf(" ");
|
||||
printf("\rTic: %12s File: %-14s Area: %-12s ", TIC.TicName, TIC.TicIn.OrgName, TIC.TicIn.Area);
|
||||
printf("\rTic: %12s File: %-14s Area: %-12s ", TIC.TicName, TIC.TicIn.File, TIC.TicIn.Area);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@ -365,7 +359,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
Log = NULL;
|
||||
}
|
||||
|
||||
strcpy(Temp, TIC.TicIn.From);
|
||||
strcpy(Temp, TIC.TicIn.Origin);
|
||||
TIC.Aka.zone = atoi(strtok(Temp, ":"));
|
||||
TIC.Aka.net = atoi(strtok(NULL, "/"));
|
||||
TIC.Aka.node = atoi(strtok(NULL, "@\0"));
|
||||
@ -377,6 +371,81 @@ int LoadTic(char *inb, char *tfn)
|
||||
TIC.OrgAka.node = atoi(strtok(NULL, "@\0"));
|
||||
if (SearchFidonet(TIC.OrgAka.zone))
|
||||
strcpy(TIC.OrgAka.domain, fidonet.domain);
|
||||
|
||||
Temp2 = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
if (TIC.TicIn.Hatch) {
|
||||
/*
|
||||
* Try to move the hatched file to the inbound
|
||||
*/
|
||||
sprintf(Temp, "%s/%s", TIC.TicIn.Pth, TIC.TicIn.FullName);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, TIC.TicIn.FullName);
|
||||
} else {
|
||||
WriteError("Can't find %s", Temp);
|
||||
tidy_falist(&sbl);
|
||||
return 2;
|
||||
}
|
||||
sprintf(Temp2, "%s/%s", TIC.Inbound, TIC.TicIn.FullName);
|
||||
if (file_mv(Temp, Temp2)) {
|
||||
WriteError("Can't move %s to inbound", Temp);
|
||||
tidy_falist(&sbl);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Find out what the real name of the file is
|
||||
*/
|
||||
sprintf(Temp2, "%s", TIC.TicIn.File);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
} else {
|
||||
tu(Temp2);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
} else {
|
||||
tl(Temp2);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(TIC.TicIn.FullName) && (strlen(TIC.RealName) == 0)) {
|
||||
sprintf(Temp2, "%s", TIC.TicIn.FullName);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
} else {
|
||||
tu(Temp2);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
} else {
|
||||
tl(Temp2);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
if (file_exist(Temp, R_OK) == 0) {
|
||||
strcpy(TIC.RealName, Temp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(TIC.RealName) == 0) {
|
||||
/*
|
||||
* We leave RealName empty, the ProcessTic function
|
||||
* will handle this orphaned tic file.
|
||||
*/
|
||||
WriteError("Can't find file in inbound");
|
||||
} else {
|
||||
Syslog('f', "Real filename in inbound is \"%s\"", TIC.RealName);
|
||||
strncpy(TIC.NewName, TIC.RealName, 80);
|
||||
}
|
||||
|
||||
free(Temp2);
|
||||
free(Temp);
|
||||
free(Buf);
|
||||
|
||||
|
11
mbfido/tic.h
11
mbfido/tic.h
@ -6,10 +6,8 @@
|
||||
|
||||
typedef struct _tic_in {
|
||||
unsigned Hatch : 1; /* Hatch keyword */
|
||||
unsigned NoMove : 1; /* Nomove keyword */
|
||||
unsigned HatchNew : 1; /* Hatchnew keyword */
|
||||
unsigned PathError : 1; /* Our system is in path */
|
||||
char Pth[PATH_MAX]; /* Path to hatched file */
|
||||
char Pth[PATH_MAX+1]; /* Path to hatched file */
|
||||
char Area[21]; /* Area name */
|
||||
char Origin[81]; /* Origin address */
|
||||
char From[81]; /* From name */
|
||||
@ -36,7 +34,7 @@ typedef struct _tic_in {
|
||||
|
||||
|
||||
typedef struct _TICrec {
|
||||
char Inbound[PATH_MAX]; /* Inbound directory */
|
||||
char Inbound[PATH_MAX+1]; /* Inbound directory */
|
||||
char TicName[13]; /* Name of .TIC file */
|
||||
Tic_in TicIn; /* Original TIC record */
|
||||
fidoaddr OrgAka; /* Origin address */
|
||||
@ -50,11 +48,6 @@ typedef struct _TICrec {
|
||||
off_t FileSize; /* Size of file */
|
||||
time_t FileDate; /* Date of file */
|
||||
time_t UpLoadDate; /* Upload date of file */
|
||||
char FilePath[PATH_MAX]; /* Path to the file */
|
||||
unsigned PathErr : 1; /* If path error */
|
||||
unsigned OtherPath : 1; /* If otherpath is true */
|
||||
unsigned NoMove : 1; /* No move magic */
|
||||
unsigned HatchNew : 1; /* Hatch in new areas */
|
||||
unsigned SendOrg : 1; /* Send original file */
|
||||
unsigned Charge : 1; /* Charge for this file */
|
||||
unsigned PassThru : 1; /* PassThru file */
|
||||
|
@ -108,7 +108,7 @@ int Rearc(char *unarc)
|
||||
WriteError("Rearc(): No arc command available");
|
||||
return FALSE;
|
||||
} else {
|
||||
sprintf(temp, "%s%s .", TIC.Inbound, TIC.NewName);
|
||||
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewName);
|
||||
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||
/* MUST SET TIC.FileDate to NEW ARCHIVE */
|
||||
return TRUE;
|
||||
@ -171,14 +171,20 @@ void ReCalcCrc(char *fn)
|
||||
|
||||
int Get_File_Id()
|
||||
{
|
||||
char temp[81];
|
||||
char *temp;
|
||||
char Desc[256];
|
||||
FILE *fp;
|
||||
int i, j, lines = 0;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||
if ((fp = fopen(temp, "r")) == NULL)
|
||||
if ((fp = fopen(temp, "r")) == NULL) {
|
||||
sprintf(temp, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
||||
if ((fp = fopen(temp, "r")) == NULL) {
|
||||
free(temp);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read no more then 25 lines.
|
||||
@ -197,6 +203,7 @@ int Get_File_Id()
|
||||
TIC.File_Id_Ct = 0;
|
||||
Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc));
|
||||
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
|
||||
free(temp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -219,6 +226,7 @@ int Get_File_Id()
|
||||
}
|
||||
fclose(fp);
|
||||
unlink(temp);
|
||||
free(temp);
|
||||
|
||||
/*
|
||||
* Strip empty lines at end of FILE_ID.DIZ
|
||||
|
@ -1421,7 +1421,6 @@ char *getmagictype(int val)
|
||||
case MG_MOVE: return (char *)"Move file ";
|
||||
case MG_UPDALIAS: return (char *)"Update alias";
|
||||
case MG_ADOPT: return (char *)"Adopt file ";
|
||||
case MG_OTHER: return (char *)"Other path ";
|
||||
case MG_DELETE: return (char *)"Delete file ";
|
||||
default: return NULL;
|
||||
}
|
||||
|
@ -229,10 +229,8 @@ void ScreenM(void)
|
||||
break;
|
||||
|
||||
case MG_COPY:
|
||||
case MG_OTHER:
|
||||
case MG_UNPACK:
|
||||
mvprintw(12, 2, "6. To path");
|
||||
if (magic.Attrib != MG_OTHER)
|
||||
mvprintw(13, 2, "7. Compile");
|
||||
break;
|
||||
|
||||
@ -265,7 +263,6 @@ void FieldsM(void)
|
||||
case MG_UNPACK:
|
||||
case MG_COPY:
|
||||
show_bool(13,16, magic.Compile);
|
||||
case MG_OTHER:
|
||||
show_str(12,16,64, magic.Path);
|
||||
break;
|
||||
case MG_KEEPNUM:
|
||||
@ -364,7 +361,6 @@ int EditMagicRec(int Area)
|
||||
break;
|
||||
|
||||
case MG_COPY:
|
||||
case MG_OTHER:
|
||||
case MG_UNPACK:
|
||||
E_PTH(12,16,64, magic.Path, "The ^path^ to use")
|
||||
|
||||
@ -532,7 +528,6 @@ int tic_magic_doc(FILE *fp, FILE *toc, int page)
|
||||
case MG_UNPACK:
|
||||
case MG_COPY:
|
||||
fprintf(fp, " Compile NL %s\n", getboolean(magic.Compile));
|
||||
case MG_OTHER:
|
||||
fprintf(fp, " Path %s\n", magic.Path);
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user