Skip to content
Snippets Groups Projects
Commit bdde52f7 authored by Eric Oulashin's avatar Eric Oulashin Committed by Rob Swindell
Browse files

Updated Digital Distortion Upload Processor so that the scanning works...

Updated Digital Distortion Upload Processor so that the scanning works properly in Linux (directory permissions)
parent d3e4c4ed
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!178Updated Digital Distortion Upload Processor so that the scanning works properly in Linux (directory permissions)
nhc Digital Distortion Upload Processor yvw1.00
hy For Synchronet 3.14+
kÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ncThis is an upload processor for Synchronet
that allows for performing a virus scan on
files inside of archives. File extraction
commands and the virus scan command are
configurable.
bhRelease date: 2009-12-29
\ No newline at end of file
File moved
......@@ -9,11 +9,13 @@
* BBS: Digital Distortion
* BBS address: digdist.bbsindex.com
*
* Date User Description
* Date Author Description
* 2009-12-25-
* 2009-12-28 Eric Oulashin Initial development
* 2009-12-29 Eric Oulashin Version 1.00
* Initial public release
* 2022-06-08 Eric Oulashin Version 1.01
* Made fixes to get the scanner functionality working properly in Linux
*/
/* Command-line arguments:
......@@ -22,6 +24,13 @@
load("sbbsdefs.js");
// Require version 3.17 or newer of Synchronet (for file_chmod())
if (system.version_num < 31700)
{
console.print("\1nDigital Distortion Upload Processor requires Synchronet 3.17 or newer.\r\n");
exit(1);
}
// Determine the script's execution directory.
// This code is a trick that was created by Deuce, suggested by Rob
// Swindell as a way to detect which directory the script was executed
......@@ -31,11 +40,14 @@ var gStartupPath = '.';
try { throw dig.dist(dist); } catch(e) { gStartupPath = e.fileName; }
gStartupPath = backslash(gStartupPath.replace(/[\/\\][^\/\\]*$/,''));
load(gStartupPath + "DDUP_Cleanup.js");
load(gStartupPath + "ddup_cleanup.js");
// Version information
var gDDUPVersion = "1.00";
var gDDUPVerDate = "2009-12-29";
var gDDUPVersion = "1.01";
var gDDUPVerDate = "2022-06-08";
// Store whether or not this is running in Windows
var gRunningInWindows = /^WIN/.test(system.platform.toUpperCase());
// If the filename was specified on the command line, then use that
......@@ -92,11 +104,12 @@ if (gFileToScan.length == 0)
}
// Create the global configuration objects.
var gGenCfg = new Object();
gGenCfg.scanCmd = "";
gGenCfg.skipScanIfSysop = false;
gGenCfg.pauseAtEnd = false;
var gFileTypeCfg = new Object();
var gGenCfg = {
scanCmd: "",
skipScanIfSysop: false,
pauseAtEnd: false
};
var gFileTypeCfg = {};
// Read the configuration files to populate the global configuration object.
var configFileRead = ReadConfigFile(gStartupPath);
......@@ -271,6 +284,8 @@ function processFile(pFilename)
console.print("nyhWarning: nwh Unable to create the work dir.n\r\n");
retval = -1;
}
file_chmod(baseWorkDir, 0x1fd); // Octal 775, rwxrwxr-x
//chmodDirsRecursive(baseWorkDir, 0x1fd); // Octal 775, rwxrwxr-x
// If all is okay, then create the directory in the temporary work dir.
var workDir = baseWorkDir + "/" + justFilename + "_temp";
......@@ -292,6 +307,8 @@ function processFile(pFilename)
var errorStr = extractFileToDir(pFilename, workDir);
if (errorStr.length == 0)
{
// In case we're running in Linux, chmod all directories in the work dir recursively so the scanner can access their files
chmodDirsRecursive(workDir, 0x1fd); // Octal 775, rwxrwxr-x
console.print(gOKStrWithNewline);
// Scan the files in the work directory.
printf(gStatusPrintfStr, "r", "Scanning files inside the archive for viruses...");
......@@ -302,7 +319,7 @@ function processFile(pFilename)
else
{
console.print(gFailStrWithNewline);
console.print("nyhVirus scan failed. Scan output:n\r\n");
console.print("nyhVirus scan failed.(1) Scan output:n\r\n");
for (var index = 0; index < retObj.cmdOutput.length; ++index)
{
console.print(retObj.cmdOutput[index]);
......@@ -334,7 +351,7 @@ function processFile(pFilename)
else
{
console.print(gFailStrWithNewline);
console.print("nyhVirus scan failed. Scan output:n\r\n");
console.print("nyhVirus scan failed.(2) Scan output:n\r\n");
for (var index = 0; index < retObj.cmdOutput.length; ++index)
{
console.print(retObj.cmdOutput[index]);
......@@ -358,7 +375,7 @@ function processFile(pFilename)
else
{
console.print(gFailStrWithNewline);
console.print("nyhVirus scan failed. Scan output:n\r\n");
console.print("nyhVirus scan failed.(3) Scan output:n\r\n");
for (var index = 0; index < retObj.cmdOutput.length; ++index)
{
console.print(retObj.cmdOutput[index]);
......@@ -481,7 +498,7 @@ function ReadConfigFile(pCfgFilePath)
{
// Read the file type settings.
var fileTypeSettingsRead = false;
var fileTypeCfgFile = new File(pCfgFilePath + "DDUPFileTypes.cfg");
var fileTypeCfgFile = new File(pCfgFilePath + "ddup_file_types.cfg");
if (fileTypeCfgFile.open("r"))
{
if (fileTypeCfgFile.length > 0)
......@@ -566,7 +583,7 @@ function ReadConfigFile(pCfgFilePath)
// Read the general program configuration
var genSettingsRead = false;
var genCfgFile = new File(pCfgFilePath + "DDUP.cfg");
var genCfgFile = new File(pCfgFilePath + "ddup.cfg");
if (genCfgFile.open("r"))
{
if (genCfgFile.length > 0)
......@@ -728,11 +745,7 @@ function getPathFromFilename(pFilename)
if (pFilename.length == 0)
return "";
// Determine which slash character to use for paths, depending
// on the OS.
if (getPathFromFilename.inWin == undefined)
getPathFromFilename.inWin = /^WIN/.test(system.platform.toUpperCase());
var pathSlash = (getPathFromFilename.inWin ? "\\" : "/");
var pathSlash = (gRunningInWindows ? "\\" : "/");
// Make sure the filename has the correct slashes for
// the platform.
......@@ -783,15 +796,10 @@ function fixPathSlashes(pPath)
if (pPath.length == 0)
return "";
// Create a variable to store whether or not we're in Windows,
// but only once (for speed).
if (fixPathSlashes.inWin == undefined)
fixPathSlashes.inWin = /^WIN/.test(system.platform.toUpperCase());
// Fix the slashes and return the fixed version.
//return(fixPathSlashes.inWin ? pPath.replace("/", "\\") : pPath.replace("\\", "/"));
//return(gRunningInWindows ? pPath.replace("/", "\\") : pPath.replace("\\", "/"));
var path = pPath;
if (fixPathSlashes.inWin) // Windows
if (gRunningInWindows) // Windows
{
while (path.indexOf("/") > -1)
path = path.replace("/", "\\");
......@@ -956,17 +964,13 @@ function execCmdWithOutput(pCommand)
// cmdOutput: An array of strings containing the program's output.
function runExternalCmdWithOutput(pCommand)
{
// Determine whether or not we're in Windows.
if (runExternalCmdWithOutput.inWin == undefined)
runExternalCmdWithOutput.inWin = /^WIN/.test(system.platform.toUpperCase());
var retObj = null; // The return object
var wroteScriptFile = false; // Whether or not we were able to write the script file
// In the node directory, write a batch file (if in Windows) or a *nix shell
// script (if not in Windows) containing the command to run.
var scriptFilename = "";
if (runExternalCmdWithOutput.inWin)
if (gRunningInWindows)
{
// Write a Windows batch file to run the command
scriptFilename = fixPathSlashes(system.node_dir + "DDUP_ScanCmd.bat");
......@@ -992,7 +996,7 @@ function runExternalCmdWithOutput(pCommand)
scriptFile.writeln(pCommand);
scriptFile.close();
wroteScriptFile = true;
system.exec("chmod ugo+x " + scriptFilename);
file_chmod(scriptFilename, 775); // rwxrwxr-x
retObj = execCmdWithOutput("bash " + scriptFilename);
}
}
......@@ -1006,10 +1010,30 @@ function runExternalCmdWithOutput(pCommand)
if (!wroteScriptFile)
{
// Could not open the script file for writing
retObj = new Object();
retObj.cmdOutput = new Array();
retObj.returnCode = -1;
retObj = {
cmdOutput: [],
returnCode: -1
};
}
return retObj;
}
// Changes the mode value of a directory and all of its subdirectories recursively
//
// Parameters:
// pBaseDir: The directory to chmod recursively (along with all of its subdirectories)
// pMode: The mode value (number) to apply
function chmodDirsRecursive(pBaseDir, pMode)
{
if (typeof(pBaseDir) !== "string" || !file_isdir(pBaseDir) || typeof(pMode) !== "number")
return;
file_chmod(pBaseDir, pMode);
var fileEntries = directory(backslash(pBaseDir) + "*");
for (var i = 0; i < fileEntries.length; ++i)
{
if (file_isdir(fileEntries[i]))
chmodDirsRecursive(fileEntries[i], pMode);
}
}
\ No newline at end of file
Digital Distortion Upload Processor
Version 1.00
Release date: 2009-12-29
Version 1.01
Release date: 2022-06-08
by
Eric Oulashin
Sysop of Digital Distortion BBS
BBS internet address: digitaldistortionbbs.com
digdist.bbsindex.com
BBS internet address: digdist.bbsindex.com
Email: eric.oulashin@gmail.com
......@@ -22,6 +21,7 @@ Contents
4. Installation and Setup
5. Main configuration file
6. Archive file type configuration file
7. Revision History
1. Disclaimer
......@@ -90,19 +90,17 @@ EXTRACT command lines set properly for your system. For information on
that configuration file, see section 6: Archive file type configuration
file.
The following archive contains Win32 command-line archivers for popular
archive file formats:
http://digdist.bbsindex.com/miscFilesForDL/Win32CmdLineCompressionTools.zip
The archivers included in that archive handle the most popular file formats
(ZIP, 7Z (7-Zip), RAR, ARJ, TAR, GZ, TGZ, and TAR.GZ), and they are set up in
DDUPFileTypes.cfg to extract popular file formats (ZIP, 7Z (7-Zip), RAR, ARJ,
MSI, TAR, GZ, TGZ, and TAR.GZ). Note that you will need to edit that .cfg
file and change the path to the .exe file according to where you copied them
on your system. If your BBS is running in Windows, the included configuration
file should work for you (although it does also have the Linux command lines
as comments). If you copy the archivers to a directory that is not in your
system path, you will need to edit the DDUPFileTypes.cfg file to include the
full paths with the archive executables.
Win32 command-line archivers have been included with this script for
convenience. Those archivers have been set up in DDUPFileTypes.cfg
to extract popular file formats (ZIP, 7Z (7-Zip), RAR, ARJ, MSI, TAR,
GZ, TGZ, and TAR.GZ). The Win32 archivers are in the Win32Archivers
directory. So if your BBS is running in Windows, the included
configuration file should work for you (although it does also have the
Linux command lines as comments). You will need to copy the files from
the Win32Archivers directory to a directory in your path or another
directory of your choice. If you copy them to a directory that is not
in your path, you will need to edit the DDUPFileTypes.cfg file to include
the full paths with the archive executables.
Extractor notes:
DDUPFileTypes.cfg includes a setup for using 7-Zip to extract ISO (CD/DVD
......@@ -341,3 +339,10 @@ uploads D:\Files\someArchive.zip and your Synchronet installation is located
in D:\sbbs, the temp directory is D:\sbbs\node1\DDUploadProcessor_Temp, and
the extract command will be translated to the following:
unzip.exe -qq -o D:\Files\someArchive.zip -d D:\sbbs\node1\DDUploadProcessor_Temp
7. Revision History
===================
Version Date Description
------- ---- -----------
1.00 2009-12-29 First general public release
\ No newline at end of file
......@@ -2,4 +2,5 @@ Revision History for Digital Distortion Upload Processor
========================================================
Version Date Description
------- ---- -----------
1.01 2022-06-08 Updated so that the scanning works properly in Linux
1.00 2009-12-29 First general public release
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment