Searching FILE_ID.DIZ in uploads is now case insensitive

This commit is contained in:
Michiel Broek 2007-06-11 19:32:24 +00:00
parent b6fd1d28bc
commit d423fd141b
2 changed files with 35 additions and 21 deletions

View File

@ -16,6 +16,8 @@ v0.91.9 16-May-2007
mbsebbs: mbsebbs:
The filelist now displays long filenames (finally). The filelist now displays long filenames (finally).
Searching FILE_ID.DIZ in uploads is now case insensitive.
Improved cleaning users tmp dir after virus scan.
mbpasswd: mbpasswd:
Added check for FreeBSD > 6.0 and use sysctl for security check. Added check for FreeBSD > 6.0 and use sysctl for security check.

View File

@ -565,8 +565,7 @@ int ScanArchive(char *fn, char *ftype)
FILE *fp, *lp; FILE *fp, *lp;
int err = 0, Found = FALSE; int err = 0, Found = FALSE;
char *temp, *stdlog, *errlog, buf[256], msg[81]; char *temp, *stdlog, *errlog, buf[256], msg[81];
char *cwd = NULL; char *cwd = NULL, *fid;
/* /*
* First search for the right archiver program * First search for the right archiver program
@ -576,8 +575,6 @@ int ScanArchive(char *fn, char *ftype)
errlog = 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"));
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(temp, "r")) == NULL) { if ((fp = fopen(temp, "r")) == NULL) {
free(temp); free(temp);
@ -629,6 +626,22 @@ int ScanArchive(char *fn, char *ftype)
PUTSTR((char *) Language(200)); PUTSTR((char *) Language(200));
Enter(1); Enter(1);
/*
* While we are here, see if there is a FILE_ID.DIZ
*/
fid = xstrcpy((char *)"FILE_ID.DIZ");
snprintf(temp, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
if (getfilecase(temp, 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);
if (file_cp(temp, stdlog) == 0) {
Syslog('b', "Copied %s", temp);
}
}
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")); snprintf(temp, PATH_MAX, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) != NULL) { if ((fp = fopen(temp, "r")) != NULL) {
@ -679,7 +692,14 @@ int ScanArchive(char *fn, char *ftype)
fclose(fp); fclose(fp);
} }
execute_pth((char *)"rm", (char *)"-r -f ./*", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); /*
* Remove and recreate tmp directory if it was used (or not)
*/
snprintf(temp, PATH_MAX, "%s/%s", CFG.bbs_usersdir, exitinfo.Name);
chdir(temp);
snprintf(temp, PATH_MAX, "-r -f %s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
execute_pth((char *)"mkdir", (char *)"tmp", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
chdir(cwd); chdir(cwd);
free(cwd); free(cwd);
free(temp); free(temp);
@ -836,7 +856,7 @@ int ImportFile(char *fn, int Area, int fileid, off_t Size)
int Addfile(char *File, int AreaNum, int fileid) int Addfile(char *File, int AreaNum, int fileid)
{ {
FILE *id, *pPrivate; FILE *id, *pPrivate;
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j; int iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j;
char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[PATH_MAX], msg[81]; char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[PATH_MAX], msg[81];
struct stat statfile; struct stat statfile;
struct _fdbarea *fdb_area = NULL; struct _fdbarea *fdb_area = NULL;
@ -920,22 +940,14 @@ int Addfile(char *File, int AreaNum, int fileid)
if (fileid && strlen(archiver.iunarc)) { if (fileid && strlen(archiver.iunarc)) {
/* /*
* The right unarchiver is still in memory, * During Virus scan, a possible FILE_ID.DIZ is in the users work directory.
* get the FILE_ID.DIZ if it exists.
*/ */
snprintf(temp, PATH_MAX, "%s/%s", area.Path, File); idname = xstrcpy(CFG.bbs_usersdir);
if ((err = execute_str(archiver.iunarc, temp, (char *)"FILE_ID.DIZ", (char *)"/dev/null", idname = xstrcat(idname, (char *)"/");
(char *)"/dev/null", (char *)"/dev/null"))) { idname = xstrcat(idname, exitinfo.Name);
if ((err = execute_str(archiver.iunarc, temp, (char *)"file_id.diz", (char *)"/dev/null", idname = xstrcat(idname, (char *)"/wrk/FILE_ID.DIZ");
(char *)"/dev/null", (char *)"/dev/null"))) {
Syslog('+', "No FILE_ID.DIZ found in %s", File); if (file_exist(idname, R_OK) == 0) {
} else {
idname = xstrcpy((char *)"file_id.diz");
}
} else {
idname = xstrcpy((char *)"FILE_ID.DIZ");
}
if (!err) {
Syslog('+', "Found %s", idname); Syslog('+', "Found %s", idname);
GotId = TRUE; GotId = TRUE;
} }