Fixed virus scan path for mbfile adopt/import

This commit is contained in:
Michiel Broek 2002-06-01 12:27:11 +00:00
parent 74e18ac52a
commit 4bd2d5cddf
7 changed files with 74 additions and 34 deletions

View File

@ -4797,6 +4797,8 @@ v0.33.20 10-Feb-2002
letter 't'.
When a virus scanner is started, de mbtask connection timeout
is set to one hour.
The virus scanner was sometimes not executed in the right
directory with the adopt and import functions.
mball:
Will not crash anymore when it needs more then 10 minutes to

3
TODO
View File

@ -35,6 +35,9 @@ mbsebbs:
L: E-mail downloads with e-mail verification.
N: When a file is attached with netmail that doesn't exist the user
doesn't see an error message.
mbfido:
U: Code cleanup and make a structure in this program. Remove duplicate
or similar functions.

View File

@ -48,7 +48,7 @@ extern int do_annon; /* Supress announce file */
void AdoptFile(int Area, char *File, char *Description)
{
FILE *fp;
char *temp, *temp2, *unarc, *pwd;
char *temp, *temp2, *tmpdir, *unarc, *pwd;
char Desc[256], TDesc[256];
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
int IsVirus = FALSE, File_Id = FALSE;
@ -67,6 +67,7 @@ void AdoptFile(int Area, char *File, char *Description)
temp = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char));
pwd = calloc(PATH_MAX, sizeof(char));
tmpdir = calloc(PATH_MAX, sizeof(char));
if (CheckFDB(Area, area.Path))
die(0);
@ -79,6 +80,7 @@ void AdoptFile(int Area, char *File, char *Description)
}
sprintf(temp, "%s/%s", pwd, File);
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
if ((unarc = unpacker(File)) == NULL) {
Syslog('+', "No known archive: %s", File);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
@ -93,7 +95,7 @@ void AdoptFile(int Area, char *File, char *Description)
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
IsVirus = VirScan();
IsVirus = VirScan(tmpdir);
if (IsVirus) {
DeleteVirusWork();
chdir(pwd);
@ -116,7 +118,7 @@ void AdoptFile(int Area, char *File, char *Description)
fflush(stdout);
}
IsVirus = VirScan();
IsVirus = VirScan(tmpdir);
if (IsVirus) {
DeleteVirusWork();
chdir(pwd);
@ -277,6 +279,7 @@ void AdoptFile(int Area, char *File, char *Description)
free(pwd);
free(temp2);
free(temp);
free(tmpdir);
} else {
WriteError("Area %d is not available", Area);
if (!do_quiet)

View File

@ -47,7 +47,7 @@ extern int do_annon; /* Supress announce files */
void ImportFiles(int Area)
{
char *pwd, *temp, *temp2, *String, *token, *dest, *unarc;
char *pwd, *temp, *temp2, *tmpdir, *String, *token, *dest, *unarc;
FILE *fbbs;
int Append = FALSE, Files = 0, rc, i, j = 0, k = 0, x, Doit;
int Imported = 0, Errors = 0, Present = FALSE;
@ -66,12 +66,14 @@ void ImportFiles(int Area)
temp = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char));
pwd = calloc(PATH_MAX, sizeof(char));
tmpdir = calloc(PATH_MAX, sizeof(char));
String = calloc(4096, sizeof(char));
dest = calloc(PATH_MAX, sizeof(char));
getcwd(pwd, PATH_MAX);
if (CheckFDB(Area, area.Path))
die(0);
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
IsDoing("Import files");
@ -114,7 +116,7 @@ void ImportFiles(int Area)
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (VirScan()) {
if (VirScan(tmpdir)) {
Doit = FALSE;
}
}
@ -128,7 +130,7 @@ void ImportFiles(int Area)
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (VirScan()) {
if (VirScan(tmpdir)) {
Doit = FALSE;
}
} else {
@ -313,7 +315,7 @@ void ImportFiles(int Area)
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (VirScan()) {
if (VirScan(tmpdir)) {
Doit = FALSE;
}
}
@ -327,7 +329,7 @@ void ImportFiles(int Area)
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (VirScan()) {
if (VirScan(tmpdir)) {
Doit = FALSE;
}
} else {
@ -354,6 +356,7 @@ void ImportFiles(int Area)
free(pwd);
free(temp2);
free(temp);
free(tmpdir);
} else {
if (!area.Available) {
WriteError("Area not available");

View File

@ -513,7 +513,7 @@ int ProcessTic(fa_list *sbl)
fflush(stdout);
}
if (VirScan()) {
if (VirScan(NULL)) {
DeleteVirusWork();
chdir(TIC.Inbound);
Bad((char *)"Possible virus found!");

View File

@ -37,20 +37,46 @@
#include "virscan.h"
int VirScan(void)
/*
* Check for known viri, optional in a defined path.
*/
int VirScan(char *path)
{
char *temp, *cmd = NULL;
char *pwd, *temp, *cmd = NULL;
FILE *fp;
int rc = FALSE;
int rc = FALSE, has_scan = FALSE;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) {
WriteError("No virus scanners defined");
} else {
free(temp);
return FALSE;
}
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
if (virscan.available)
has_scan = TRUE;
}
if (!has_scan) {
Syslog('+', "No active virus scanners, skipping scan");
fclose(fp);
free(temp);
return FALSE;
}
pwd = calloc(PATH_MAX, sizeof(char));
getcwd(pwd, PATH_MAX);
if (path) {
chdir(path);
Syslog('+', "Start virusscan in %s", path);
} else {
Syslog('+', "Start virusscan in %s", pwd);
}
fseek(fp, virscanhdr.hdrsize, SEEK_SET);
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
cmd = NULL;
if (virscan.available) {
@ -69,8 +95,11 @@ int VirScan(void)
}
}
fclose(fp);
}
if (path)
chdir(pwd);
free(pwd);
free(temp);
return rc;
}

View File

@ -3,7 +3,7 @@
#ifndef _VIRSCAN_H
#define _VIRSCAN_H
int VirScan(void);
int VirScan(char *);
#endif