Switched to virus scanner from library
This commit is contained in:
parent
e9dbd74830
commit
adda1c3b6a
@ -18,6 +18,7 @@ v0.95.1 07-Jan-2008
|
|||||||
|
|
||||||
mbsebbs:
|
mbsebbs:
|
||||||
Added MIB counters.
|
Added MIB counters.
|
||||||
|
Switched to virus scanner from library.
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
Added support for TCP stream scanners.
|
Added support for TCP stream scanners.
|
||||||
|
@ -481,75 +481,28 @@ void Home()
|
|||||||
*/
|
*/
|
||||||
int ScanDirect(char *fn)
|
int ScanDirect(char *fn)
|
||||||
{
|
{
|
||||||
FILE *fp, *lp;
|
int Found = FALSE;
|
||||||
int err, Found = FALSE;
|
char *temp, msg[81];
|
||||||
char *temp, *temp1, *stdlog, *errlog, buf[256], msg[81];
|
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
snprintf(temp, PATH_MAX, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
||||||
stdlog = calloc(PATH_MAX, sizeof(char));
|
|
||||||
errlog = calloc(PATH_MAX, sizeof(char));
|
|
||||||
|
|
||||||
snprintf(temp, PATH_MAX, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
|
||||||
snprintf(temp1, PATH_MAX, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
|
||||||
snprintf(stdlog, PATH_MAX, "%s/tmp/stdlog%d", getenv("MBSE_ROOT"), mypid);
|
|
||||||
snprintf(errlog, PATH_MAX, "%s/tmp/errlog%d", getenv("MBSE_ROOT"), mypid);
|
|
||||||
|
|
||||||
if ((fp = fopen(temp1, "r")) != NULL) {
|
/* Scanning */
|
||||||
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
|
snprintf(msg, 81, "%s %s ", (char *) Language(132), fn);
|
||||||
|
pout(CFG.TextColourF, CFG.TextColourB, msg);
|
||||||
|
|
||||||
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
if (VirScanFile(temp)) {
|
||||||
|
/* Possible VIRUS found! */
|
||||||
if (virscan.available && (file_exist(virscan.scanner, X_OK) == 0)) {
|
snprintf(msg, 81, "%s", (char *) Language(199));
|
||||||
/* Scanning */ /* with */
|
pout(CFG.HiliteF, CFG.HiliteB, msg);
|
||||||
snprintf(msg, 81, "%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
Found = TRUE;
|
||||||
pout(CFG.TextColourF, CFG.TextColourB, msg);
|
} else {
|
||||||
|
/* Ok */
|
||||||
Altime(3600);
|
snprintf(msg, 81, "%s", (char *) Language(200));
|
||||||
err = execute_str(virscan.scanner, virscan.options, temp, (char *)"/dev/null", stdlog, errlog);
|
PUTSTR(msg);
|
||||||
if (file_size(stdlog)) {
|
|
||||||
if ((lp = fopen(stdlog, "r"))) {
|
|
||||||
while (fgets(buf, sizeof(buf) -1, lp)) {
|
|
||||||
Striplf(buf);
|
|
||||||
Syslog('+', "stdout: \"%s\"", printable(buf, 0));
|
|
||||||
}
|
|
||||||
fclose(lp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (file_size(errlog)) {
|
|
||||||
if ((lp = fopen(errlog, "r"))) {
|
|
||||||
while (fgets(buf, sizeof(buf) -1, lp)) {
|
|
||||||
Striplf(buf);
|
|
||||||
Syslog('+', "stderr: \"%s\"", printable(buf, 0));
|
|
||||||
}
|
|
||||||
fclose(lp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unlink(stdlog);
|
|
||||||
unlink(errlog);
|
|
||||||
if (err != virscan.error) {
|
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
|
||||||
/* Possible VIRUS found! */
|
|
||||||
snprintf(msg, 81, "%s", (char *) Language(199));
|
|
||||||
pout(CFG.HiliteF, CFG.HiliteB, msg);
|
|
||||||
Found = TRUE;
|
|
||||||
} else {
|
|
||||||
/* Ok */
|
|
||||||
snprintf(msg, 81, "%s", (char *) Language(200));
|
|
||||||
PUTSTR(msg);
|
|
||||||
}
|
|
||||||
Enter(1);
|
|
||||||
Altime(0);
|
|
||||||
Nopper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
Enter(1);
|
||||||
free(temp);
|
free(temp);
|
||||||
free(temp1);
|
|
||||||
free(stdlog);
|
|
||||||
free(errlog);
|
|
||||||
return Found;
|
return Found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,18 +518,32 @@ int ScanDirect(char *fn)
|
|||||||
*/
|
*/
|
||||||
int ScanArchive(char *fn, char *ftype)
|
int ScanArchive(char *fn, char *ftype)
|
||||||
{
|
{
|
||||||
FILE *fp, *lp;
|
FILE *fp;
|
||||||
int err = 0, Found = FALSE;
|
char *temp, *temp2, msg[81], *cwd = NULL, *fid;
|
||||||
char *temp, *stdlog, *errlog, buf[256], msg[81];
|
|
||||||
char *cwd = NULL, *fid;
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan file for viri
|
||||||
|
*/
|
||||||
|
snprintf(msg, 81, "%s %s ", (char *) Language(132), fn);
|
||||||
|
pout(CFG.TextColourF, CFG.TextColourB, msg);
|
||||||
|
snprintf(temp, PATH_MAX, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
||||||
|
if (VirScanFile(temp)) {
|
||||||
|
/* Possible VIRUS found! */
|
||||||
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(199));
|
||||||
|
free(temp);
|
||||||
|
Enter(1);
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
/* Ok */
|
||||||
|
PUTSTR((char *) Language(200));
|
||||||
|
}
|
||||||
|
Enter(1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First search for the right archiver program
|
* Search the right archiver program.
|
||||||
*/
|
*/
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
stdlog = calloc(PATH_MAX, sizeof(char));
|
|
||||||
errlog = calloc(PATH_MAX, sizeof(char));
|
|
||||||
|
|
||||||
snprintf(temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
@ -636,65 +603,15 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
snprintf(temp, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
|
snprintf(temp, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
if (getfilecase(temp, fid)) {
|
if (getfilecase(temp, fid)) {
|
||||||
snprintf(temp, PATH_MAX, "%s/%s/tmp/%s", CFG.bbs_usersdir, exitinfo.Name, fid);
|
snprintf(temp, PATH_MAX, "%s/%s/tmp/%s", CFG.bbs_usersdir, exitinfo.Name, fid);
|
||||||
snprintf(stdlog, PATH_MAX, "%s/%s/wrk/FILE_ID.DIZ", CFG.bbs_usersdir, exitinfo.Name);
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
if (file_cp(temp, stdlog) == 0) {
|
snprintf(temp2, PATH_MAX, "%s/%s/wrk/FILE_ID.DIZ", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
|
if (file_cp(temp, temp2) == 0) {
|
||||||
Syslog('b', "Copied %s", temp);
|
Syslog('b', "Copied %s", temp);
|
||||||
}
|
}
|
||||||
|
free(temp2);
|
||||||
}
|
}
|
||||||
free(fid);
|
free(fid);
|
||||||
|
|
||||||
snprintf(stdlog, PATH_MAX, "%s/tmp/stdlog%d", getenv("MBSE_ROOT"), mypid);
|
|
||||||
snprintf(errlog, PATH_MAX, "%s/tmp/errlog%d", getenv("MBSE_ROOT"), mypid);
|
|
||||||
snprintf(temp, PATH_MAX, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r")) != NULL) {
|
|
||||||
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
|
|
||||||
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
|
||||||
|
|
||||||
if (virscan.available && (file_exist(virscan.scanner, X_OK) == 0)) {
|
|
||||||
/* Scanning */ /* with */
|
|
||||||
snprintf(msg, 81, "%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
|
||||||
pout(CFG.TextColourF, CFG.TextColourB, msg);
|
|
||||||
|
|
||||||
Altime(3600);
|
|
||||||
err = execute_str(virscan.scanner, virscan.options, (char *)NULL, (char *)"/dev/null", stdlog, errlog);
|
|
||||||
if (file_size(stdlog)) {
|
|
||||||
if ((lp = fopen(stdlog, "r"))) {
|
|
||||||
while (fgets(buf, sizeof(buf) -1, lp)) {
|
|
||||||
Striplf(buf);
|
|
||||||
Syslog('+', "stdout: \"%s\"", printable(buf, 0));
|
|
||||||
}
|
|
||||||
fclose(lp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (file_size(errlog)) {
|
|
||||||
if ((lp = fopen(errlog, "r"))) {
|
|
||||||
while (fgets(buf, sizeof(buf) -1, lp)) {
|
|
||||||
Striplf(buf);
|
|
||||||
Syslog('+', "stderr: \"%s\"", printable(buf, 0));
|
|
||||||
}
|
|
||||||
fclose(lp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unlink(stdlog);
|
|
||||||
unlink(errlog);
|
|
||||||
if (err != virscan.error) {
|
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
|
||||||
/* Possible VIRUS found! */
|
|
||||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(199));
|
|
||||||
Found = TRUE;
|
|
||||||
} else {
|
|
||||||
/* Ok */
|
|
||||||
PUTSTR((char *) Language(200));
|
|
||||||
}
|
|
||||||
Enter(1);
|
|
||||||
Altime(0);
|
|
||||||
Nopper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove and recreate tmp directory if it was used (or not)
|
* Remove and recreate tmp directory if it was used (or not)
|
||||||
*/
|
*/
|
||||||
@ -706,13 +623,8 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
free(cwd);
|
free(cwd);
|
||||||
free(temp);
|
free(temp);
|
||||||
free(stdlog);
|
|
||||||
free(errlog);
|
|
||||||
|
|
||||||
if (Found)
|
return 0;
|
||||||
return 2;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user