Replaces some system calls with execute
This commit is contained in:
parent
21f5c5d2e7
commit
9aaef089b7
@ -4334,6 +4334,8 @@ v0.33.19 26-Oct-2001
|
|||||||
areas if you want to test the users age. Also the age in the
|
areas if you want to test the users age. Also the age in the
|
||||||
users record is invalid.
|
users record is invalid.
|
||||||
Fixes for Sparc systems.
|
Fixes for Sparc systems.
|
||||||
|
System calls for archivers and virus scanners are replaced
|
||||||
|
with execute.
|
||||||
|
|
||||||
mbnewusr:
|
mbnewusr:
|
||||||
New program, run by user bbs. This is only to register a new
|
New program, run by user bbs. This is only to register a new
|
||||||
|
@ -1055,9 +1055,9 @@ int Upload()
|
|||||||
printf("%d ", File[i]);
|
printf("%d ", File[i]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a space in filename being uploaded
|
* Check for a space or ; in filename being uploaded
|
||||||
*/
|
*/
|
||||||
if ((strchr(File, 32)) != NULL) {
|
if (((strchr(File, 32)) != NULL) || ((strchr(File, ';')) != NULL)) {
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
/* Illegal Filename! */
|
/* Illegal Filename! */
|
||||||
printf("\n%s\n\n", (char *) Language(247));
|
printf("\n%s\n\n", (char *) Language(247));
|
||||||
@ -1126,7 +1126,7 @@ int Upload()
|
|||||||
*/
|
*/
|
||||||
Altime(7200);
|
Altime(7200);
|
||||||
alarm_set(7190);
|
alarm_set(7190);
|
||||||
if ((err = system(temp)) != 0) {
|
if ((err = system(temp))) {
|
||||||
/*
|
/*
|
||||||
* Log any errors
|
* Log any errors
|
||||||
*/
|
*/
|
||||||
@ -1158,7 +1158,6 @@ int Upload()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Syslog('b', "Start checking uploaded files");
|
|
||||||
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"\n\nChecking your upload(s)\n\n");
|
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"\n\nChecking your upload(s)\n\n");
|
||||||
|
|
||||||
while ((dp = readdir(dirp)) != NULL) {
|
while ((dp = readdir(dirp)) != NULL) {
|
||||||
@ -1173,7 +1172,8 @@ int Upload()
|
|||||||
* a textfile or so. Import it direct.
|
* a textfile or so. Import it direct.
|
||||||
*/
|
*/
|
||||||
Syslog('b', "Unknown file type");
|
Syslog('b', "Unknown file type");
|
||||||
ImportFile(dp->d_name, Area, FALSE, iTime, statfile.st_size);
|
if (!ScanDirect(dp->d_name))
|
||||||
|
ImportFile(dp->d_name, Area, FALSE, iTime, statfile.st_size);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* We figured out the type of the uploaded file.
|
* We figured out the type of the uploaded file.
|
||||||
@ -1290,7 +1290,7 @@ int DownloadDirect(char *Name, int Wait)
|
|||||||
ElapstimeStart = time(NULL);
|
ElapstimeStart = time(NULL);
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s %s", sProtDn, symFrom);
|
sprintf(temp, "%s '%s'", sProtDn, symFrom);
|
||||||
Syslog('+', "Download command %s", temp);
|
Syslog('+', "Download command %s", temp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1300,7 +1300,7 @@ int DownloadDirect(char *Name, int Wait)
|
|||||||
*/
|
*/
|
||||||
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
||||||
Altime((exitinfo.iTimeLeft + 10) * 60);
|
Altime((exitinfo.iTimeLeft + 10) * 60);
|
||||||
if ((err = system(temp)) != 0) {
|
if ((err = system(temp))) {
|
||||||
/*
|
/*
|
||||||
* Only log the error, we might have sent some files
|
* Only log the error, we might have sent some files
|
||||||
* instead of nothing.
|
* instead of nothing.
|
||||||
|
@ -528,13 +528,13 @@ int ScanDirect(char *fn)
|
|||||||
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
||||||
|
|
||||||
if (virscan.available) {
|
if (virscan.available) {
|
||||||
sprintf(temp1, "%s %s %s >/dev/null", virscan.scanner, virscan.options, temp);
|
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
/* Scanning */ /* with */
|
/* Scanning */ /* with */
|
||||||
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if ((err = system(temp1))) {
|
if ((err = execute(virscan.scanner, virscan.options, temp, (char *)"/dev/null",
|
||||||
|
(char *)"/dev/null" , (char *)"/dev/null")) != virscan.error) {
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
/* Possible VIRUS found! */
|
/* Possible VIRUS found! */
|
||||||
@ -566,103 +566,109 @@ int ScanDirect(char *fn)
|
|||||||
*/
|
*/
|
||||||
int ScanArchive(char *fn, char *ftype)
|
int ScanArchive(char *fn, char *ftype)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int err, Found = FALSE;
|
int err = 0, Found = FALSE;
|
||||||
char *temp;
|
char *temp;
|
||||||
char *cwd = NULL;
|
char *cwd = NULL;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First search for the right archiver program
|
* First search for the right archiver program
|
||||||
*/
|
*/
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
free(temp);
|
free(temp);
|
||||||
return 3;
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
fread(&archiverhdr, sizeof(archiverhdr), 1, fp);
|
||||||
|
|
||||||
|
while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) {
|
||||||
|
if ((strcmp(ftype, archiver.name) == 0) && (archiver.available)) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
if ((strcmp(ftype, archiver.name)) || (!archiver.available)) {
|
||||||
|
free(temp);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
fread(&archiverhdr, sizeof(archiverhdr), 1, fp);
|
cwd = getcwd(cwd, 80);
|
||||||
|
sprintf(temp, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
|
if (chdir(temp)) {
|
||||||
|
WriteError("$Can't chdir(%s)", temp);
|
||||||
|
free(temp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) {
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
if ((strcmp(ftype, archiver.name) == 0) && (archiver.available)) {
|
/* Unpacking archive */
|
||||||
break;
|
printf("%s %s", (char *) Language(201), fn);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
if (!strlen(archiver.funarc)) {
|
||||||
|
WriteError("No unarc command available");
|
||||||
|
} else {
|
||||||
|
sprintf(temp, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
||||||
|
if (execute(archiver.funarc, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
|
||||||
|
WriteError("$Failed %s %s", archiver.funarc, temp);
|
||||||
|
system("rm -f -r ./*");
|
||||||
|
chdir(cwd);
|
||||||
|
free(cwd);
|
||||||
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
|
/* ERROR */
|
||||||
|
printf("%s\n", (char *) Language(217));
|
||||||
|
fflush(stdout);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ok */
|
||||||
|
printf("%s\n", (char *) Language(200));
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
sprintf(temp, "%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) {
|
||||||
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
|
/* Scanning */ /* with */
|
||||||
|
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
err = execute(virscan.scanner, virscan.options, (char *)"*", (char *)"/dev/null",
|
||||||
|
(char *)"/dev/null", (char *)"/dev/null");
|
||||||
|
if (err != virscan.error) {
|
||||||
|
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
||||||
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
|
/* Possible VIRUS found! */
|
||||||
|
printf("%s\n", (char *) Language(199));
|
||||||
|
Found = TRUE;
|
||||||
|
} else {
|
||||||
|
/* Ok */
|
||||||
|
printf("%s\n", (char *) Language(200));
|
||||||
}
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
Nopper();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ((strcmp(ftype, archiver.name)) || (!archiver.available)) {
|
}
|
||||||
free(temp);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
cwd = getcwd(cwd, 80);
|
system("rm -f -r ./*");
|
||||||
|
chdir(cwd);
|
||||||
|
free(cwd);
|
||||||
|
free(temp);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
|
if (Found)
|
||||||
if (chdir(temp)) {
|
return 2;
|
||||||
WriteError("$Can't chdir(%s)", temp);
|
else
|
||||||
free(temp);
|
return 0;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
|
||||||
/* Unpacking archive */
|
|
||||||
printf("%s %s ", (char *) Language(201), fn);
|
|
||||||
fflush(stdout);
|
|
||||||
sprintf(temp, "%s %s/%s >/dev/null", archiver.funarc, cwd, fn);
|
|
||||||
|
|
||||||
if ((err = system(temp))) {
|
|
||||||
WriteError("$Failed %s", temp);
|
|
||||||
system("rm -f -r *");
|
|
||||||
chdir(cwd);
|
|
||||||
free(cwd);
|
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
|
||||||
/* ERROR */
|
|
||||||
printf("%s\n", (char *) Language(217));
|
|
||||||
fflush(stdout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Ok */
|
|
||||||
printf("%s\n", (char *) Language(200));
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
sprintf(temp, "%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) {
|
|
||||||
sprintf(temp, "%s %s * >/dev/null", virscan.scanner, virscan.options);
|
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
|
||||||
/* Scanning */ /* with */
|
|
||||||
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
if ((err = system(temp))) {
|
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
|
||||||
/* Possible VIRUS found! */
|
|
||||||
printf("%s\n", (char *) Language(199));
|
|
||||||
Found = TRUE;
|
|
||||||
} else
|
|
||||||
/* Ok */
|
|
||||||
printf("%s\n", (char *) Language(200));
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
system("rm -f -r *");
|
|
||||||
chdir(cwd);
|
|
||||||
free(cwd);
|
|
||||||
free(temp);
|
|
||||||
|
|
||||||
if (Found)
|
|
||||||
return 2;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -733,6 +739,7 @@ char *GetFileType(char *fn)
|
|||||||
if (memcmp(buf, "THNL", 4) == 0) return (char *)"ThumbNail";
|
if (memcmp(buf, "THNL", 4) == 0) return (char *)"ThumbNail";
|
||||||
if ((memcmp(buf, "<html>", 6) == 0) ||
|
if ((memcmp(buf, "<html>", 6) == 0) ||
|
||||||
(memcmp(buf, "<HTML>", 6) == 0)) return (char *)"HTML";
|
(memcmp(buf, "<HTML>", 6) == 0)) return (char *)"HTML";
|
||||||
|
if (memcmp(buf, "BZ", 2) == 0) return (char *)"BZIP";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* .COM formats. Should cover about 2/3 of COM files.
|
* .COM formats. Should cover about 2/3 of COM files.
|
||||||
@ -833,8 +840,8 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
|||||||
int Addfile(char *File, int AreaNum, int fileid)
|
int Addfile(char *File, int AreaNum, int fileid)
|
||||||
{
|
{
|
||||||
FILE *id, *pFileDB, *pPrivate;
|
FILE *id, *pFileDB, *pPrivate;
|
||||||
int err, iDesc = 1, iPrivate = FALSE, GotId = FALSE;
|
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE;
|
||||||
char *Filename, *temp1;
|
char *Filename, *temp1, *idname = NULL;
|
||||||
char *Desc[26];
|
char *Desc[26];
|
||||||
struct stat statfile;
|
struct stat statfile;
|
||||||
int i;
|
int i;
|
||||||
@ -899,11 +906,20 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
* The right unarchiver is still in memory,
|
* The right unarchiver is still in memory,
|
||||||
* get the FILE_ID.DIZ if it exists.
|
* get the FILE_ID.DIZ if it exists.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s %s/%s FILE_ID.DIZ >/dev/null", archiver.iunarc, area.Path, File);
|
sprintf(temp, "%s/%s", area.Path, File);
|
||||||
if ((err = system(temp))) {
|
if ((err = execute(archiver.iunarc, temp, (char *)"FILE_ID.DIZ", (char *)"/dev/null",
|
||||||
WriteError("$Unpack error %s", temp);
|
(char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
|
if ((err = execute(archiver.iunarc, temp, (char *)"file_id.diz", (char *)"/dev/null",
|
||||||
|
(char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
|
Syslog('+', "No FILE_ID.DIZ found in %s", File);
|
||||||
|
} else {
|
||||||
|
idname = xstrcpy((char *)"file_id.diz");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "Found FILE_ID.DIZ");
|
idname = xstrcpy((char *)"FILE_ID.DIZ");
|
||||||
|
}
|
||||||
|
if (!err) {
|
||||||
|
Syslog('+', "Found %s", idname);
|
||||||
GotId = TRUE;
|
GotId = TRUE;
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
/* Found FILE_ID.DIZ in */
|
/* Found FILE_ID.DIZ in */
|
||||||
@ -913,7 +929,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GotId) {
|
if (GotId) {
|
||||||
if ((id = fopen("FILE_ID.DIZ", "r")) != NULL) {
|
if ((id = fopen(idname, "r")) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Import FILE_ID.DIZ, format to max. 25
|
* Import FILE_ID.DIZ, format to max. 25
|
||||||
* lines, 48 chars width.
|
* lines, 48 chars width.
|
||||||
@ -928,7 +944,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(id);
|
fclose(id);
|
||||||
unlink("FILE_ID.DIZ");
|
unlink(idname);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Ask the user for a description.
|
* Ask the user for a description.
|
||||||
|
Reference in New Issue
Block a user