Revised TIC file processing

This commit is contained in:
Michiel Broek 2001-12-09 15:20:51 +00:00
parent 8eebc55e6d
commit 8094a0d1d7
15 changed files with 427 additions and 383 deletions

2
TODO
View File

@ -66,6 +66,8 @@ mbfido:
N: Also check for file_id.diz filenames. N: Also check for file_id.diz filenames.
mbcico: mbcico:
U: Implement nodes FNC flag for sending files.
L: Implement modem connect response translation for ISDN lines, i.e. L: Implement modem connect response translation for ISDN lines, i.e.
make the CAUSE responses human readable. see McMail for this make the CAUSE responses human readable. see McMail for this
option. option.

View File

@ -1401,7 +1401,6 @@ typedef enum {
MG_MOVE, /* Move to other area */ MG_MOVE, /* Move to other area */
MG_UPDALIAS, /* Update alias */ MG_UPDALIAS, /* Update alias */
MG_ADOPT, /* Adopt file */ MG_ADOPT, /* Adopt file */
MG_OTHER, /* Store in other path */
MG_DELETE /* Delete file */ MG_DELETE /* Delete file */
} MAGICTYPE; } MAGICTYPE;

View File

@ -82,7 +82,7 @@ int Add_BBS()
if (strlen(TIC.TicIn.Magic)) if (strlen(TIC.TicIn.Magic))
sprintf(frec.Desc[i], "Magic Request: %s", 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); sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
mkdirs(temp2); mkdirs(temp2);
@ -113,8 +113,7 @@ int Add_BBS()
if (ftell(fdb) == 0) { if (ftell(fdb) == 0) {
fwrite(&frec, sizeof(frec), 1, fdb); fwrite(&frec, sizeof(frec), 1, fdb);
fclose(fdb); fclose(fdb);
if (!TIC.NoMove) file_rm(temp1);
file_rm(temp1);
tic_imp++; tic_imp++;
return TRUE; return TRUE;
} }
@ -216,10 +215,8 @@ int Add_BBS()
/* /*
* Delete file from the inbound * Delete file from the inbound
*/ */
if (!TIC.NoMove) { if ((i = file_rm(temp1)))
if ((i = file_rm(temp1))) WriteError("$ %d = file_rm(%s)", i, temp1);
WriteError("$ %d = file_rm(%s)", i, temp1);
}
/* /*
* Handle the replace option. * Handle the replace option.

View File

@ -88,7 +88,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
* Create the full filename * Create the full filename
*/ */
if (TIC.SendOrg) if (TIC.SendOrg)
sprintf(fwdfile, "%s/%s", TIC.FilePath, TIC.TicIn.OrgName); sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.RealName);
else else
sprintf(fwdfile, "%s/%s", TIC.BBSpath, TIC.NewName); sprintf(fwdfile, "%s/%s", TIC.BBSpath, TIC.NewName);
@ -129,7 +129,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
fprintf(net, "\r"); fprintf(net, "\r");
fprintf(net, "I sent the following file to your system:\r"); fprintf(net, "I sent the following file to your system:\r");
fprintf(net, "\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, "Description : %s\r", TIC.TicIn.Desc);
fprintf(net, "Area : %s %s\r", TIC.TicIn.Area, TIC.TicIn.AreaDesc); fprintf(net, "Area : %s %s\r", TIC.TicIn.Area, TIC.TicIn.AreaDesc);
fprintf(net, "Size : %ld\r", (long)(TIC.FileSize)); fprintf(net, "Size : %ld\r", (long)(TIC.FileSize));
@ -167,7 +167,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
if (strlen(TIC.TicIn.Magic)) if (strlen(TIC.TicIn.Magic))
fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic); fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic);
if ((TIC.PassThru) || (TIC.SendOrg)) if ((TIC.PassThru) || (TIC.SendOrg))
subject = xstrcpy(TIC.TicIn.OrgName); subject = xstrcpy(TIC.RealName);
else else
subject = xstrcpy(TIC.NewName); subject = xstrcpy(TIC.NewName);
if (nodes.FNC) { if (nodes.FNC) {

View File

@ -211,7 +211,7 @@ int Magic_MoveFile(void)
{ {
if (GetMagicRec(MG_MOVE, TRUE)) { if (GetMagicRec(MG_MOVE, TRUE)) {
strcpy(TIC.TicIn.Area, magic.ToArea); 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; return TRUE;
} else } else
return FALSE; 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) void Magic_UnpackFile(void)
{ {
int rc, First = TRUE; int rc, First = TRUE;

View File

@ -7,7 +7,6 @@ void MagicResult(char *, ...);
int Magic_MoveFile(void); int Magic_MoveFile(void);
void Magic_ExecCommand(void); void Magic_ExecCommand(void);
void Magic_CopyFile(void); void Magic_CopyFile(void);
void Magic_OtherPath(void);
void Magic_UnpackFile(void); void Magic_UnpackFile(void);
void Magic_Keepnum(void); void Magic_Keepnum(void);
void Magic_UpDateAlias(void); void Magic_UpDateAlias(void);

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: mbfido/mover.c * $Id$
* Purpose ...............: Bad file mover * Purpose ...............: Bad file mover
* Last modification date : 02-Nov-1999
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-1999 * Copyright (C) 1997-1999
@ -39,15 +38,15 @@
void mover(char *srcdir, char *fn) void mover(char *fn)
{ {
char *From, *To; char *From, *To;
From = calloc(128, sizeof(char)); From = calloc(PATH_MAX, sizeof(char));
To = calloc(128, sizeof(char)); To = calloc(PATH_MAX, sizeof(char));
sprintf(From, "%s%s", srcdir, fn); sprintf(From, "%s/%s", TIC.Inbound, fn);
sprintf(To, "%s/%s", CFG.badtic, fn); sprintf(To, "%s/%s", TIC.Inbound, fn);
Syslog('!', "Moving %s to %s", From, To); Syslog('!', "Moving %s to %s", From, To);
if (mkdirs(To)) { if (mkdirs(To)) {
@ -66,8 +65,8 @@ void mover(char *srcdir, char *fn)
*/ */
void MoveBad() void MoveBad()
{ {
mover(TIC.Inbound, TIC.TicName); mover(TIC.TicName);
mover(TIC.FilePath, TIC.TicIn.OrgName); mover(TIC.RealName);
} }

View File

@ -1,8 +1,10 @@
/* $Id$ */
#ifndef _MOVER_H #ifndef _MOVER_H
#define _MOVER_H #define _MOVER_H
void mover(char *, char *); void mover(char *);
void MoveBad(void); void MoveBad(void);

View File

@ -66,15 +66,15 @@ extern int check_dupe;
* 1 - Some error * 1 - Some error
* 2 - Orphaned tic * 2 - Orphaned tic
*/ */
int ProcessTic(fa_list *sbl, char *Realname) int ProcessTic(fa_list *sbl)
{ {
time_t Now, Fdate; time_t Now, Fdate;
int Age, First, Listed = FALSE; int Age, First, Listed = FALSE;
int DownLinks = 0; int DownLinks = 0;
int MustRearc = FALSE, MustVirus = FALSE; int MustRearc = FALSE;
int IsVirus = FALSE, UnPacked = FALSE, IsArchive = FALSE; int UnPacked = FALSE, IsArchive = FALSE;
int i, j, k, File_Id = 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]; char temp1[PATH_MAX], temp2[PATH_MAX], sbe[24], TDesc[256];
unsigned long crc, crc2, Kb; unsigned long crc, crc2, Kb;
sysconnect Link; sysconnect Link;
@ -86,13 +86,12 @@ int ProcessTic(fa_list *sbl, char *Realname)
time(&Now); time(&Now);
if (TIC.PathErr) { if (TIC.TicIn.PathError) {
WriteError("Our Aka is in the path"); WriteError("Our Aka is in the path");
return 1; return 1;
} }
Temp = calloc(PATH_MAX, sizeof(char)); Temp = calloc(PATH_MAX, sizeof(char));
sprintf(Temp, "%s%s", TIC.FilePath, TIC.TicIn.OrgName);
if (!do_quiet) { if (!do_quiet) {
colour(10, 0); colour(10, 0);
@ -100,40 +99,27 @@ int ProcessTic(fa_list *sbl, char *Realname)
fflush(stdout); fflush(stdout);
} }
/* if (strlen(TIC.RealName) == 0) {
* A hack to work around received uppercase or mixed case filenames. WriteError("File not in inbound: %s", TIC.TicIn.File);
*/
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);
/* /*
* Now check the age of the .tic 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); Fdate = file_time(Temp);
Age = (Now - Fdate) / 84400; Age = (Now - Fdate) / 84400;
Syslog('+', "Orphaned tic age %d days", Age); Syslog('+', "Orphaned tic age %d days", Age);
if (Age > 21) { if (Age > 21) {
tic_bad++; tic_bad++;
mover(TIC.Inbound, TIC.TicName); mover(TIC.TicName);
} }
free(Temp); free(Temp);
return 2; 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.FileSize = file_size(Temp);
TIC.FileDate = file_time(Temp); TIC.FileDate = file_time(Temp);
@ -146,7 +132,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
if (crc != TIC.Crc_Int) { if (crc != TIC.Crc_Int) {
Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc); Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc);
if (check_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); free(Temp);
return 1; return 1;
} else { } else {
@ -168,7 +154,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
return 1; return 1;
} }
if ((tic.Secure) && (!TIC.Hatch)) { if ((tic.Secure) && (!TIC.TicIn.Hatch)) {
First = TRUE; First = TRUE;
while (GetTicSystem(&Link, First)) { while (GetTicSystem(&Link, First)) {
First = FALSE; 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)); Bad((char *)"%s NOT known", aka2str(TIC.Aka));
free(Temp); free(Temp);
return 1; return 1;
} }
if (!TIC.Hatch) { if (!TIC.TicIn.Hatch) {
if (strcasecmp(TIC.TicIn.Pw, nodes.Fpasswd)) { if (strcasecmp(TIC.TicIn.Pw, nodes.Fpasswd)) {
Bad((char *)"Pwd error, got %s, expected %s", TIC.TicIn.Pw, nodes.Fpasswd); Bad((char *)"Pwd error, got %s, expected %s", TIC.TicIn.Pw, nodes.Fpasswd);
free(Temp); free(Temp);
@ -210,9 +196,10 @@ int ProcessTic(fa_list *sbl, char *Realname)
} }
if (Magic_DeleteFile()) { if (Magic_DeleteFile()) {
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicName); sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicName);
file_rm(temp1); file_rm(temp1);
Syslog('+', "Deleted file %s", temp1); Syslog('+', "Deleted file %s", temp1);
file_rm(Temp);
free(Temp); free(Temp);
return 0; return 0;
} }
@ -269,11 +256,6 @@ int ProcessTic(fa_list *sbl, char *Realname)
} }
strcpy(T_File.Comment, tic.Comment); 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 * Check if the destination area really exists, it may be that
* the area is not linked to an existing BBS area. * 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.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024; T_File.SizeKb = TIC.FileSize / 1024;
if ((fgroup.UnitCost) || (TIC.TicIn.UplinkCost)) if ((fgroup.UnitCost) || (TIC.TicIn.Cost))
TIC.Charge = TRUE; TIC.Charge = TRUE;
else else
TIC.Charge = FALSE; TIC.Charge = FALSE;
@ -333,8 +315,8 @@ int ProcessTic(fa_list *sbl, char *Realname)
else else
TIC.FileCost = FwdCost; TIC.FileCost = FwdCost;
if (TIC.TicIn.UplinkCost) if (TIC.TicIn.Cost)
TIC.FileCost += TIC.TicIn.UplinkCost; TIC.FileCost += TIC.TicIn.Cost;
if (fgroup.AddProm) if (fgroup.AddProm)
TIC.FileCost += (TIC.FileCost * fgroup.AddProm / 1000); TIC.FileCost += (TIC.FileCost * fgroup.AddProm / 1000);
@ -361,9 +343,10 @@ int ProcessTic(fa_list *sbl, char *Realname)
*/ */
Kb = TIC.FileSize / 1024; Kb = TIC.FileSize / 1024;
if (SearchNode(TIC.Aka)) { if (SearchNode(TIC.Aka)) {
nodes.Debet -= TIC.TicIn.UplinkCost; if (TIC.TicIn.Cost) {
if (TIC.TicIn.UplinkCost) nodes.Debet -= TIC.TicIn.Cost;
Syslog('f', "Uplink cost %ld, debet %ld", TIC.TicIn.UplinkCost, nodes.Debet); Syslog('f', "Uplink cost %ld, debet %ld", TIC.TicIn.Cost, nodes.Debet);
}
StatAdd(&nodes.FilesRcvd, 1L); StatAdd(&nodes.FilesRcvd, 1L);
StatAdd(&nodes.F_KbRcvd, Kb); StatAdd(&nodes.F_KbRcvd, Kb);
UpdateNode(); UpdateNode();
@ -381,299 +364,315 @@ int ProcessTic(fa_list *sbl, char *Realname)
tic.LastAction = time(NULL); tic.LastAction = time(NULL);
UpdateTic(); UpdateTic();
if (!TIC.HatchNew) { if (!do_quiet) {
printf("Unpacking \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
/*
* 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.RealName)) == NULL)
Syslog('+', "Unknown archive format %s", TIC.RealName);
else {
IsArchive = TRUE;
if ((strlen(tic.Convert) && (strcmp(unarc, tic.Convert) == 0)) || (tic.ConvertAll))
MustRearc = TRUE;
}
}
/*
* Copy the file if there are downlinks and we send the
* original file, but want to rearc it for ourself, or if
* it's a passthru area.
*/
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
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 {
WriteError("$Copy %s to %s failed", temp1, temp2);
}
}
if ((tic.VirScan || MustRearc) && IsArchive) {
/*
* Check if there is a temp directory for the archive
* conversion.
*/
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
if ((access(temp2, R_OK)) != 0) {
if (mkdir(temp2, 0777)) {
WriteError("$Can't create %s", temp2);
free(Temp);
return 1;
}
}
/*
* 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.RealName, UNPACK_FACTOR)) {
Bad((char *)"Not enough free diskspace left");
free(Temp);
return 1;
}
if (chdir(temp2) != 0) {
WriteError("$Can't change to %s", temp2);
free(Temp);
return 1;
}
if (!getarchiver(unarc)) {
chdir(TIC.Inbound);
free(Temp);
return 1;
}
cmd = xstrcpy(archiver.funarc);
if ((cmd == NULL) || (cmd == "")) {
Syslog('!', "No unarc command available");
} else {
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 {
chdir(TIC.Inbound);
Bad((char *)"Archive maybe corrupt");
free(Temp);
DeleteVirusWork();
return 1;
}
free(cmd);
}
}
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) { if (!do_quiet) {
printf("Unpacking \b\b\b\b\b\b\b\b\b\b"); printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout); fflush(stdout);
} }
/* if (VirScan()) {
* Move the file to the inbound directory if it isn't DeleteVirusWork();
* already there (needed by unpacker). chdir(TIC.Inbound);
*/ Bad((char *)"Possible virus found!");
if (strcmp(TIC.FilePath,TIC.Inbound)) { free(Temp);
sprintf(temp1, "%s%s", TIC.FilePath, TIC.TicIn.OrgName); return 1;
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);
}
} }
/* if (!do_quiet) {
* Check if this is an archive, and if so, compression method printf("Checking \b\b\b\b\b\b\b\b\b\b");
* is used for this file. fflush(stdout);
*/
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);
else {
IsArchive = TRUE;
if ((strlen(tic.Convert) && (strcmp(unarc, tic.Convert) == 0)) || (tic.ConvertAll))
MustRearc = TRUE;
}
} }
/* }
* Copy the file if there are downlinks and we send the
* original file, but want to rearc it for ourself, or if
* 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);
if (file_cp(temp1, temp2) == 0) {
TIC.SendOrg = TRUE;
} else {
WriteError("$Copy %s to %s failed", temp1, temp2);
}
}
if ((tic.VirScan) && (IsArchive)) if (tic.FileId && tic.FileArea && IsArchive) {
MustVirus = TRUE; if (UnPacked) {
if (MustVirus || MustRearc) {
/*
* Check if there is a temp directory for the archive
* conversion.
*/
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
if ((access(temp2, R_OK)) != 0) {
if (mkdir(temp2, 0777)) {
WriteError("$Can't create %s", temp2);
free(Temp);
return 1;
}
}
/*
* Check for stale FILE_ID.DIZ files
*/
sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT")); sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
if (!unlink(temp1)) sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
Syslog('+', "Removed stale %s", temp1); if (file_cp(temp1, temp2) == 0) {
sprintf(temp1, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT")); File_Id = TRUE;
if (!unlink(temp1)) } else {
Syslog('+', "Removed stale %s", temp1); sprintf(temp1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
if (file_cp(temp1, temp2) == 0) {
if (!checkspace(temp2, TIC.TicIn.OrgName, UNPACK_FACTOR)) { File_Id = TRUE;
Bad((char *)"Not enough free diskspace left"); }
free(Temp);
return 1;
} }
} else {
if (chdir(temp2) != 0) {
WriteError("$Can't change to %s", temp2);
free(Temp);
return 1;
}
if (!getarchiver(unarc)) { if (!getarchiver(unarc)) {
chdir(TIC.Inbound); chdir(TIC.Inbound);
free(Temp);
return 1;
}
cmd = xstrcpy(archiver.funarc);
if ((cmd == NULL) || (cmd == "")) {
Syslog('!', "No unarc command available");
} else { } else {
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicIn.OrgName); cmd = xstrcpy(archiver.iunarc);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
UnPacked = TRUE; if (cmd == NULL) {
WriteError("No unarc command available");
} else { } else {
chdir(TIC.Inbound); sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
Bad((char *)"Archive maybe corrupt"); chdir(temp1);
free(Temp); sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.RealName);
DeleteVirusWork(); if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null",
return 1; (char *)"/dev/null", (char *)"/dev/null") == 0) {
} File_Id = TRUE;
free(cmd);
}
}
if (MustVirus && UnPacked) {
if (!do_quiet) {
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
IsVirus = VirScan();
if (IsVirus) {
DeleteVirusWork();
chdir(TIC.Inbound);
Bad((char *)"Possible virus found!");
free(Temp);
return 1;
}
if (!do_quiet) {
printf("Checking \b\b\b\b\b\b\b\b\b\b");
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)
File_Id = TRUE;
} else {
if (!getarchiver(unarc)) {
chdir(TIC.Inbound);
} else {
cmd = xstrcpy(archiver.iunarc);
if (cmd == NULL) {
WriteError("No unarc command available");
} else { } else {
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT")); sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.RealName);
chdir(temp1); if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null",
sprintf(temp1, "%s%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.OrgName); (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) { File_Id = TRUE;
File_Id = TRUE; }
}
free(cmd);
} }
} /* if getarchiver */ free(cmd);
} /* if not unpacked */ }
} /* if need FILE_ID.DIZ and not passthru */ } /* if getarchiver */
} /* if not unpacked */
} /* if need FILE_ID.DIZ and not passthru */
/* /*
* Create internal file description, priority is FILE_ID.DIZ, * Create internal file description, priority is FILE_ID.DIZ,
* 2nd LDesc, and finally the standard description. * 2nd LDesc, and finally the standard description.
*/ */
if (!Get_File_Id()) { if (!Get_File_Id()) {
if (TIC.TicIn.TotLDesc > 2) { if (TIC.TicIn.TotLDesc > 2) {
for (i = 0; i < TIC.TicIn.TotLDesc; i++) { for (i = 0; i < TIC.TicIn.TotLDesc; i++) {
strcpy(temp1, TIC.TicIn.LDesc[i]); strcpy(temp1, TIC.TicIn.LDesc[i]);
temp1[48] = '\0'; temp1[48] = '\0';
strcpy(TIC.File_Id[i], temp1); strcpy(TIC.File_Id[i], temp1);
}
TIC.File_Id_Ct = TIC.TicIn.TotLDesc;
} else {
/*
* Format the description line (max 255 chars)
* in parts of 48 characters.
*/
if (strlen(TIC.TicIn.Desc) <= 48) {
strcpy(TIC.File_Id[0], TIC.TicIn.Desc);
TIC.File_Id_Ct++;
} else {
memset(&TDesc, 0, sizeof(TDesc));
strcpy(TDesc, TIC.TicIn.Desc);
while (strlen(TDesc) > 48) {
j = 48;
while (TDesc[j] != ' ')
j--;
strncat(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
TIC.File_Id_Ct++;
k = strlen(TDesc);
j++; /* Correct space */
for (i = 0; i <= k; i++, j++)
TDesc[i] = TDesc[j];
}
strcpy(TIC.File_Id[TIC.File_Id_Ct], TDesc);
TIC.File_Id_Ct++;
}
} }
} /* not get FILE_ID.DIZ */ TIC.File_Id_Ct = TIC.TicIn.TotLDesc;
if ((MustRearc) && (UnPacked) && (tic.FileArea)) {
if (Rearc(tic.Convert)) {
if (strlen(tic.Banner)) {
Syslog('f', "Must replace banner 1");
}
/*
* Get new filesize for import and announce
*/
sprintf(temp1, "%s%s", TIC.FilePath, TIC.NewName);
TIC.FileSize = file_size(temp1);
T_File.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024;
/*
* Calculate the CRC if we must send the new
* archived file.
*/
if (!TIC.SendOrg) {
ReCalcCrc(temp1);
}
} else {
WriteError("Rearc failed");
} /* if Rearc() */
} else { } else {
/* /*
* If the file is not unpacked, change the banner * Format the description line (max 255 chars)
* direct if this is needed. * in parts of 48 characters.
*/ */
if ((strlen(tic.Banner)) && IsArchive) { if (strlen(TIC.TicIn.Desc) <= 48) {
cmd = xstrcpy(archiver.barc); strcpy(TIC.File_Id[0], TIC.TicIn.Desc);
if ((cmd == NULL) || (!strlen(cmd))) { TIC.File_Id_Ct++;
Syslog('!', "No banner command for %s", archiver.name); } else {
memset(&TDesc, 0, sizeof(TDesc));
strcpy(TDesc, TIC.TicIn.Desc);
while (strlen(TDesc) > 48) {
j = 48;
while (TDesc[j] != ' ')
j--;
strncat(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
TIC.File_Id_Ct++;
k = strlen(TDesc);
j++; /* Correct space */
for (i = 0; i <= k; i++, j++)
TDesc[i] = TDesc[j];
}
strcpy(TIC.File_Id[TIC.File_Id_Ct], TDesc);
TIC.File_Id_Ct++;
}
}
} /* not get FILE_ID.DIZ */
if ((MustRearc) && (UnPacked) && (tic.FileArea)) {
if (Rearc(tic.Convert)) {
if (strlen(tic.Banner)) {
Syslog('f', "Must replace banner 1");
}
/*
* Get new filesize for import and announce
*/
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
TIC.FileSize = file_size(temp1);
T_File.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024;
/*
* Calculate the CRC if we must send the new
* archived file.
*/
if (!TIC.SendOrg) {
ReCalcCrc(temp1);
}
} else {
WriteError("Rearc failed");
} /* if Rearc() */
} else {
/*
* If the file is not unpacked, change the banner
* direct if this is needed.
*/
if ((strlen(tic.Banner)) && IsArchive) {
cmd = xstrcpy(archiver.barc);
if ((cmd == NULL) || (!strlen(cmd))) {
Syslog('!', "No banner command for %s", archiver.name);
} else {
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");
} else { } else {
sprintf(temp1, "%s%s", TIC.Inbound, TIC.TicIn.OrgName); Syslog('+', "New banner %s", tic.Banner);
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner); TIC.FileSize = file_size(temp1);
if (execute(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) { T_File.Size = TIC.FileSize;
WriteError("$Changing the banner failed"); T_File.SizeKb = TIC.FileSize / 1024;
} else { ReCalcCrc(temp1);
Syslog('+', "New banner %s", tic.Banner); DidBanner = TRUE;
TIC.FileSize = file_size(temp1);
T_File.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024;
ReCalcCrc(temp1);
DidBanner = TRUE;
}
} }
} }
} /* if MustRearc and Unpacked and not Passthtru */
if (UnPacked)
DeleteVirusWork();
chdir(TIC.Inbound);
/*
* If the file is converted, we set the date of the original
* received file as the file creation date.
*/
if (MustRearc || DidBanner) {
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);
utime(Temp, &ut);
}
} }
} /* if MustRearc and Unpacked and not Passthtru */
if (tic.FileArea) { DeleteVirusWork();
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area); chdir(TIC.Inbound);
if (TIC.OtherPath) { /*
/* BBS_Imp = Add_DOS */ * If the file is converted, we set the date of the original
} else { * received file as the file creation date.
BBS_Imp = Add_BBS(); */
} if (MustRearc || DidBanner) {
if ((!tic.NoTouch) && (tic.FileArea)) {
if (!BBS_Imp) { ut.actime = mktime(localtime(&TIC.FileDate));
Bad((char *)"File Import Error"); ut.modtime = mktime(localtime(&TIC.FileDate));
free(Temp); sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewName);
return 1; utime(Temp, &ut);
}
} }
}
} /* Not TIC.HatchNew */ if (tic.FileArea) {
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area);
BBS_Imp = Add_BBS();
if (!BBS_Imp) {
Bad((char *)"File Import Error");
free(Temp);
return 1;
}
}
chdir(TIC.Inbound); chdir(TIC.Inbound);
if ((!TIC.HatchNew) && (tic.FileArea)) { if (tic.FileArea) {
if (strlen(TIC.TicIn.Magic)) if (strlen(TIC.TicIn.Magic))
UpDateAlias(TIC.TicIn.Magic); UpDateAlias(TIC.TicIn.Magic);
else else
@ -685,7 +684,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
T_File.Announce = tic.Announce; T_File.Announce = tic.Announce;
strcpy(T_File.Name, TIC.NewName); strcpy(T_File.Name, TIC.NewName);
T_File.Fdate = TIC.FileDate; T_File.Fdate = TIC.FileDate;
T_File.Cost = TIC.TicIn.UplinkCost; T_File.Cost = TIC.TicIn.Cost;
Add_ToBeRep(); Add_ToBeRep();
} }
@ -695,7 +694,7 @@ int ProcessTic(fa_list *sbl, char *Realname)
* file in the inbound anymore so it can be * file in the inbound anymore so it can be
* deleted. * deleted.
*/ */
sprintf(temp1, "%s%s", TIC.FilePath, TIC.TicIn.OrgName); sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
if (file_rm(temp1) == 0) if (file_rm(temp1) == 0)
Syslog('f', "Deleted %s", temp1); Syslog('f', "Deleted %s", temp1);
} }
@ -746,14 +745,12 @@ int ProcessTic(fa_list *sbl, char *Realname)
} }
} }
if (!TIC.HatchNew) { Magic_ExecCommand();
Magic_ExecCommand(); Magic_CopyFile();
Magic_CopyFile(); Magic_UnpackFile();
Magic_UnpackFile(); Magic_AdoptFile();
Magic_AdoptFile();
}
sprintf(Temp, "%s%s", TIC.Inbound, TIC.TicName); sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
unlink(Temp); unlink(Temp);
free(Temp); free(Temp);
return 0; return 0;

View File

@ -1,7 +1,7 @@
#ifndef _PTIC_H #ifndef _PTIC_H
#define _PTIC_H #define _PTIC_H
int ProcessTic(fa_list *, char *); int ProcessTic(fa_list *);
#endif #endif

View File

@ -163,7 +163,7 @@ int Tic()
int LoadTic(char *inb, char *tfn) int LoadTic(char *inb, char *tfn)
{ {
FILE *tfp; FILE *tfp;
char *Temp, *Buf, *Log = NULL; char *Temp, *Temp2, *Buf, *Log = NULL;
int i, j, rc; int i, j, rc;
fa_list *sbl = NULL; fa_list *sbl = NULL;
int DescCnt = FALSE; int DescCnt = FALSE;
@ -174,9 +174,8 @@ int LoadTic(char *inb, char *tfn)
memset(&TIC, 0, sizeof(TIC)); memset(&TIC, 0, sizeof(TIC));
memset(&T_File, 0, sizeof(T_File)); memset(&T_File, 0, sizeof(T_File));
sprintf(TIC.Inbound, "%s/", inb); sprintf(TIC.Inbound, "%s", inb);
sprintf(TIC.FilePath, "%s/", inb); strncpy(TIC.TicName, tfn, 12);
strcpy(TIC.TicName, tfn);
chdir(inb); chdir(inb);
if ((tfp = fopen(tfn, "r")) == NULL) { if ((tfp = fopen(tfn, "r")) == NULL) {
@ -184,8 +183,8 @@ int LoadTic(char *inb, char *tfn)
return 1; return 1;
} }
Temp = calloc(256, sizeof(char)); Temp = calloc(PATH_MAX, sizeof(char));
Buf = calloc(256, sizeof(char)); Buf = calloc(257, sizeof(char));
while ((fgets(Buf, 256, tfp)) != NULL) { while ((fgets(Buf, 256, tfp)) != NULL) {
/* /*
@ -200,17 +199,12 @@ int LoadTic(char *inb, char *tfn)
} }
Temp[j] = '\0'; Temp[j] = '\0';
Syslog('f', "TIC: %s", Temp);
if (strncasecmp(Temp, "hatch", 5) == 0) { if (strncasecmp(Temp, "hatch", 5) == 0) {
TIC.TicIn.Hatch = TRUE; TIC.TicIn.Hatch = TRUE;
} else if (TIC.TicIn.Hatch && (strncasecmp(Temp, "pth ", 4) == 0)) { } else if (TIC.TicIn.Hatch && (strncasecmp(Temp, "pth ", 4) == 0)) {
sprintf(TIC.TicIn.Pth, "%s/", Temp+4); strncpy(TIC.TicIn.Pth, Temp+4, PATH_MAX);
} 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;
} else if (strncasecmp(Temp, "area ", 5) == 0) { } else if (strncasecmp(Temp, "area ", 5) == 0) {
strncpy(TIC.TicIn.Area, Temp+5, 20); strncpy(TIC.TicIn.Area, Temp+5, 20);
@ -229,7 +223,7 @@ int LoadTic(char *inb, char *tfn)
} else if (strncasecmp(Temp, "fullname ", 9) == 0) { } else if (strncasecmp(Temp, "fullname ", 9) == 0) {
strncpy(TIC.TicIn.FullName, Temp+9, 80); 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) { } else if (strncasecmp(Temp, "created ", 8) == 0) {
strncpy(TIC.TicIn.Created, Temp+8, 80); strncpy(TIC.TicIn.Created, Temp+8, 80);
@ -337,7 +331,7 @@ int LoadTic(char *inb, char *tfn)
printf("\r"); printf("\r");
for (i = 0; i < 79; i++) for (i = 0; i < 79; i++)
printf(" "); 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); fflush(stdout);
} }
@ -365,7 +359,7 @@ int LoadTic(char *inb, char *tfn)
Log = NULL; Log = NULL;
} }
strcpy(Temp, TIC.TicIn.From); strcpy(Temp, TIC.TicIn.Origin);
TIC.Aka.zone = atoi(strtok(Temp, ":")); TIC.Aka.zone = atoi(strtok(Temp, ":"));
TIC.Aka.net = atoi(strtok(NULL, "/")); TIC.Aka.net = atoi(strtok(NULL, "/"));
TIC.Aka.node = atoi(strtok(NULL, "@\0")); TIC.Aka.node = atoi(strtok(NULL, "@\0"));
@ -377,6 +371,81 @@ int LoadTic(char *inb, char *tfn)
TIC.OrgAka.node = atoi(strtok(NULL, "@\0")); TIC.OrgAka.node = atoi(strtok(NULL, "@\0"));
if (SearchFidonet(TIC.OrgAka.zone)) if (SearchFidonet(TIC.OrgAka.zone))
strcpy(TIC.OrgAka.domain, fidonet.domain); 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(Temp);
free(Buf); free(Buf);

View File

@ -6,10 +6,8 @@
typedef struct _tic_in { typedef struct _tic_in {
unsigned Hatch : 1; /* Hatch keyword */ unsigned Hatch : 1; /* Hatch keyword */
unsigned NoMove : 1; /* Nomove keyword */
unsigned HatchNew : 1; /* Hatchnew keyword */
unsigned PathError : 1; /* Our system is in path */ 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 Area[21]; /* Area name */
char Origin[81]; /* Origin address */ char Origin[81]; /* Origin address */
char From[81]; /* From name */ char From[81]; /* From name */
@ -36,7 +34,7 @@ typedef struct _tic_in {
typedef struct _TICrec { typedef struct _TICrec {
char Inbound[PATH_MAX]; /* Inbound directory */ char Inbound[PATH_MAX+1]; /* Inbound directory */
char TicName[13]; /* Name of .TIC file */ char TicName[13]; /* Name of .TIC file */
Tic_in TicIn; /* Original TIC record */ Tic_in TicIn; /* Original TIC record */
fidoaddr OrgAka; /* Origin address */ fidoaddr OrgAka; /* Origin address */
@ -50,11 +48,6 @@ typedef struct _TICrec {
off_t FileSize; /* Size of file */ off_t FileSize; /* Size of file */
time_t FileDate; /* Date of file */ time_t FileDate; /* Date of file */
time_t UpLoadDate; /* Upload 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 SendOrg : 1; /* Send original file */
unsigned Charge : 1; /* Charge for this file */ unsigned Charge : 1; /* Charge for this file */
unsigned PassThru : 1; /* PassThru file */ unsigned PassThru : 1; /* PassThru file */

View File

@ -108,7 +108,7 @@ int Rearc(char *unarc)
WriteError("Rearc(): No arc command available"); WriteError("Rearc(): No arc command available");
return FALSE; return FALSE;
} else { } 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) { if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
/* MUST SET TIC.FileDate to NEW ARCHIVE */ /* MUST SET TIC.FileDate to NEW ARCHIVE */
return TRUE; return TRUE;
@ -171,14 +171,20 @@ void ReCalcCrc(char *fn)
int Get_File_Id() int Get_File_Id()
{ {
char temp[81]; char *temp;
char Desc[256]; char Desc[256];
FILE *fp; FILE *fp;
int i, j, lines = 0; int i, j, lines = 0;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT")); 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; return FALSE;
}
}
/* /*
* Read no more then 25 lines. * Read no more then 25 lines.
@ -197,6 +203,7 @@ int Get_File_Id()
TIC.File_Id_Ct = 0; TIC.File_Id_Ct = 0;
Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc)); Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc));
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ"); Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
free(temp);
return FALSE; return FALSE;
} }
@ -219,6 +226,7 @@ int Get_File_Id()
} }
fclose(fp); fclose(fp);
unlink(temp); unlink(temp);
free(temp);
/* /*
* Strip empty lines at end of FILE_ID.DIZ * Strip empty lines at end of FILE_ID.DIZ

View File

@ -1421,7 +1421,6 @@ char *getmagictype(int val)
case MG_MOVE: return (char *)"Move file "; case MG_MOVE: return (char *)"Move file ";
case MG_UPDALIAS: return (char *)"Update alias"; case MG_UPDALIAS: return (char *)"Update alias";
case MG_ADOPT: return (char *)"Adopt file "; case MG_ADOPT: return (char *)"Adopt file ";
case MG_OTHER: return (char *)"Other path ";
case MG_DELETE: return (char *)"Delete file "; case MG_DELETE: return (char *)"Delete file ";
default: return NULL; default: return NULL;
} }

View File

@ -229,11 +229,9 @@ void ScreenM(void)
break; break;
case MG_COPY: case MG_COPY:
case MG_OTHER:
case MG_UNPACK: case MG_UNPACK:
mvprintw(12, 2, "6. To path"); mvprintw(12, 2, "6. To path");
if (magic.Attrib != MG_OTHER) mvprintw(13, 2, "7. Compile");
mvprintw(13, 2, "7. Compile");
break; break;
case MG_KEEPNUM: case MG_KEEPNUM:
@ -265,7 +263,6 @@ void FieldsM(void)
case MG_UNPACK: case MG_UNPACK:
case MG_COPY: case MG_COPY:
show_bool(13,16, magic.Compile); show_bool(13,16, magic.Compile);
case MG_OTHER:
show_str(12,16,64, magic.Path); show_str(12,16,64, magic.Path);
break; break;
case MG_KEEPNUM: case MG_KEEPNUM:
@ -364,7 +361,6 @@ int EditMagicRec(int Area)
break; break;
case MG_COPY: case MG_COPY:
case MG_OTHER:
case MG_UNPACK: case MG_UNPACK:
E_PTH(12,16,64, magic.Path, "The ^path^ to use") 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_UNPACK:
case MG_COPY: case MG_COPY:
fprintf(fp, " Compile NL %s\n", getboolean(magic.Compile)); fprintf(fp, " Compile NL %s\n", getboolean(magic.Compile));
case MG_OTHER:
fprintf(fp, " Path %s\n", magic.Path); fprintf(fp, " Path %s\n", magic.Path);
break; break;