Fixed virus scan path for mbfile adopt/import
This commit is contained in:
parent
74e18ac52a
commit
4bd2d5cddf
@ -4797,6 +4797,8 @@ v0.33.20 10-Feb-2002
|
|||||||
letter 't'.
|
letter 't'.
|
||||||
When a virus scanner is started, de mbtask connection timeout
|
When a virus scanner is started, de mbtask connection timeout
|
||||||
is set to one hour.
|
is set to one hour.
|
||||||
|
The virus scanner was sometimes not executed in the right
|
||||||
|
directory with the adopt and import functions.
|
||||||
|
|
||||||
mball:
|
mball:
|
||||||
Will not crash anymore when it needs more then 10 minutes to
|
Will not crash anymore when it needs more then 10 minutes to
|
||||||
|
3
TODO
3
TODO
@ -35,6 +35,9 @@ mbsebbs:
|
|||||||
|
|
||||||
L: E-mail downloads with e-mail verification.
|
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:
|
mbfido:
|
||||||
U: Code cleanup and make a structure in this program. Remove duplicate
|
U: Code cleanup and make a structure in this program. Remove duplicate
|
||||||
or similar functions.
|
or similar functions.
|
||||||
|
@ -48,7 +48,7 @@ extern int do_annon; /* Supress announce file */
|
|||||||
void AdoptFile(int Area, char *File, char *Description)
|
void AdoptFile(int Area, char *File, char *Description)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *temp, *temp2, *unarc, *pwd;
|
char *temp, *temp2, *tmpdir, *unarc, *pwd;
|
||||||
char Desc[256], TDesc[256];
|
char Desc[256], TDesc[256];
|
||||||
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
|
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
|
||||||
int IsVirus = FALSE, File_Id = 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));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
pwd = calloc(PATH_MAX, sizeof(char));
|
pwd = calloc(PATH_MAX, sizeof(char));
|
||||||
|
tmpdir = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
if (CheckFDB(Area, area.Path))
|
if (CheckFDB(Area, area.Path))
|
||||||
die(0);
|
die(0);
|
||||||
@ -79,6 +80,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", pwd, File);
|
sprintf(temp, "%s/%s", pwd, File);
|
||||||
|
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
if ((unarc = unpacker(File)) == NULL) {
|
if ((unarc = unpacker(File)) == NULL) {
|
||||||
Syslog('+', "No known archive: %s", File);
|
Syslog('+', "No known archive: %s", File);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), 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");
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
IsVirus = VirScan();
|
IsVirus = VirScan(tmpdir);
|
||||||
if (IsVirus) {
|
if (IsVirus) {
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(pwd);
|
chdir(pwd);
|
||||||
@ -116,7 +118,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsVirus = VirScan();
|
IsVirus = VirScan(tmpdir);
|
||||||
if (IsVirus) {
|
if (IsVirus) {
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(pwd);
|
chdir(pwd);
|
||||||
@ -277,6 +279,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
free(pwd);
|
free(pwd);
|
||||||
free(temp2);
|
free(temp2);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
free(tmpdir);
|
||||||
} else {
|
} else {
|
||||||
WriteError("Area %d is not available", Area);
|
WriteError("Area %d is not available", Area);
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
|
@ -47,7 +47,7 @@ extern int do_annon; /* Supress announce files */
|
|||||||
|
|
||||||
void ImportFiles(int Area)
|
void ImportFiles(int Area)
|
||||||
{
|
{
|
||||||
char *pwd, *temp, *temp2, *String, *token, *dest, *unarc;
|
char *pwd, *temp, *temp2, *tmpdir, *String, *token, *dest, *unarc;
|
||||||
FILE *fbbs;
|
FILE *fbbs;
|
||||||
int Append = FALSE, Files = 0, rc, i, j = 0, k = 0, x, Doit;
|
int Append = FALSE, Files = 0, rc, i, j = 0, k = 0, x, Doit;
|
||||||
int Imported = 0, Errors = 0, Present = FALSE;
|
int Imported = 0, Errors = 0, Present = FALSE;
|
||||||
@ -66,12 +66,14 @@ void ImportFiles(int Area)
|
|||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
pwd = calloc(PATH_MAX, sizeof(char));
|
pwd = calloc(PATH_MAX, sizeof(char));
|
||||||
|
tmpdir = calloc(PATH_MAX, sizeof(char));
|
||||||
String = calloc(4096, sizeof(char));
|
String = calloc(4096, sizeof(char));
|
||||||
dest = calloc(PATH_MAX, sizeof(char));
|
dest = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
getcwd(pwd, PATH_MAX);
|
getcwd(pwd, PATH_MAX);
|
||||||
if (CheckFDB(Area, area.Path))
|
if (CheckFDB(Area, area.Path))
|
||||||
die(0);
|
die(0);
|
||||||
|
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
IsDoing("Import files");
|
IsDoing("Import files");
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ void ImportFiles(int Area)
|
|||||||
printf("Virscan \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()) {
|
if (VirScan(tmpdir)) {
|
||||||
Doit = FALSE;
|
Doit = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +130,7 @@ void ImportFiles(int Area)
|
|||||||
printf("Virscan \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()) {
|
if (VirScan(tmpdir)) {
|
||||||
Doit = FALSE;
|
Doit = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -313,7 +315,7 @@ void ImportFiles(int Area)
|
|||||||
printf("Virscan \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()) {
|
if (VirScan(tmpdir)) {
|
||||||
Doit = FALSE;
|
Doit = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +329,7 @@ void ImportFiles(int Area)
|
|||||||
printf("Virscan \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()) {
|
if (VirScan(tmpdir)) {
|
||||||
Doit = FALSE;
|
Doit = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -354,6 +356,7 @@ void ImportFiles(int Area)
|
|||||||
free(pwd);
|
free(pwd);
|
||||||
free(temp2);
|
free(temp2);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
free(tmpdir);
|
||||||
} else {
|
} else {
|
||||||
if (!area.Available) {
|
if (!area.Available) {
|
||||||
WriteError("Area not available");
|
WriteError("Area not available");
|
||||||
|
@ -513,7 +513,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VirScan()) {
|
if (VirScan(NULL)) {
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(TIC.Inbound);
|
chdir(TIC.Inbound);
|
||||||
Bad((char *)"Possible virus found!");
|
Bad((char *)"Possible virus found!");
|
||||||
|
@ -37,20 +37,46 @@
|
|||||||
#include "virscan.h"
|
#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;
|
FILE *fp;
|
||||||
int rc = FALSE;
|
int rc = FALSE, has_scan = FALSE;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("No virus scanners defined");
|
WriteError("No virus scanners defined");
|
||||||
} else {
|
free(temp);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
|
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) {
|
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
if (virscan.available) {
|
if (virscan.available) {
|
||||||
@ -69,8 +95,11 @@ int VirScan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
chdir(pwd);
|
||||||
|
|
||||||
|
free(pwd);
|
||||||
free(temp);
|
free(temp);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#ifndef _VIRSCAN_H
|
#ifndef _VIRSCAN_H
|
||||||
#define _VIRSCAN_H
|
#define _VIRSCAN_H
|
||||||
|
|
||||||
int VirScan(void);
|
int VirScan(char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user