Added mbfile import command
This commit is contained in:
parent
8a47a909c2
commit
339bf141b9
19
ChangeLog
19
ChangeLog
@ -4288,6 +4288,10 @@ v0.33.19 26-Oct-2001
|
|||||||
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
|
||||||
bbs user. Should be started by the bbs account.
|
bbs user. Should be started by the bbs account.
|
||||||
|
|
||||||
|
mbcico:
|
||||||
|
Removed IEMSI support since mbsebbs doesn't support it
|
||||||
|
anymore.
|
||||||
|
|
||||||
mbtask:
|
mbtask:
|
||||||
Changed to handle the External Doors flag in the lastcaller
|
Changed to handle the External Doors flag in the lastcaller
|
||||||
information.
|
information.
|
||||||
@ -4315,4 +4319,19 @@ v0.33.19 26-Oct-2001
|
|||||||
mbfile:
|
mbfile:
|
||||||
During check the file databases are reset to filemode 0660.
|
During check the file databases are reset to filemode 0660.
|
||||||
Implemented "mbfile adopt" function.
|
Implemented "mbfile adopt" function.
|
||||||
|
Started working on long filename support. The real name on
|
||||||
|
disk is the long filename, the database records also holds
|
||||||
|
an uppercase 8.3 filename. In most cases this is just the
|
||||||
|
same name in upper and lowercase.
|
||||||
|
Implemented "mbfile import" function, this imports complete
|
||||||
|
areas from files.bbs information.
|
||||||
|
|
||||||
|
mball:
|
||||||
|
The index function now creates the web pages with the use of
|
||||||
|
the long filenames instead of the uppercase dos 8.3 filenames.
|
||||||
|
Fixed html output for Konqueror browser.
|
||||||
|
|
||||||
|
mbfbgen:
|
||||||
|
Obsolete and removed from the distribution. The function is
|
||||||
|
now in mbfile.
|
||||||
|
|
||||||
|
8
Makefile
8
Makefile
@ -1,4 +1,3 @@
|
|||||||
# Copyright (c) M. Broek, 1997-2000
|
|
||||||
# Top-level makefile for MBSE BBS package
|
# Top-level makefile for MBSE BBS package
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
@ -25,6 +24,9 @@ install:
|
|||||||
@if [ "`id -un`" != "root" ] ; then \
|
@if [ "`id -un`" != "root" ] ; then \
|
||||||
echo; echo " Must be root to install!"; echo; exit 3; \
|
echo; echo " Must be root to install!"; echo; exit 3; \
|
||||||
fi
|
fi
|
||||||
|
@if [ -z ${PREFIX} ] ; then \
|
||||||
|
echo; echo "PREFIX is not set!"; echo; exit 3; \
|
||||||
|
fi
|
||||||
@if [ ! -d ${PREFIX}/bin ] ; then \
|
@if [ ! -d ${PREFIX}/bin ] ; then \
|
||||||
mkdir ${PREFIX}/bin ; \
|
mkdir ${PREFIX}/bin ; \
|
||||||
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/bin ; \
|
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/bin ; \
|
||||||
@ -56,8 +58,8 @@ install:
|
|||||||
@if [ ! -d ${PREFIX}/sema ] ; then \
|
@if [ ! -d ${PREFIX}/sema ] ; then \
|
||||||
mkdir ${PREFIX}/sema ; \
|
mkdir ${PREFIX}/sema ; \
|
||||||
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/sema ; \
|
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/sema ; \
|
||||||
chmod 0777 ${PREFIX}/sema ; \
|
|
||||||
fi
|
fi
|
||||||
|
@chmod 0777 ${PREFIX}/sema
|
||||||
@if [ ! -d ${PREFIX}/var ] ; then \
|
@if [ ! -d ${PREFIX}/var ] ; then \
|
||||||
mkdir ${PREFIX}/var ; \
|
mkdir ${PREFIX}/var ; \
|
||||||
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/var ; \
|
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/var ; \
|
||||||
@ -65,8 +67,8 @@ install:
|
|||||||
@if [ ! -d ${PREFIX}/tmp ] ; then \
|
@if [ ! -d ${PREFIX}/tmp ] ; then \
|
||||||
mkdir ${PREFIX}/tmp ; \
|
mkdir ${PREFIX}/tmp ; \
|
||||||
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/tmp ; \
|
${CHOWN} ${OWNER}.${GROUP} ${PREFIX}/tmp ; \
|
||||||
chmod 0777 ${PREFIX}/tmp ; \
|
|
||||||
fi
|
fi
|
||||||
|
@chmod 0775 ${PREFIX}/tmp
|
||||||
@if [ ! -d ${PREFIX}/dutch ] ; then \
|
@if [ ! -d ${PREFIX}/dutch ] ; then \
|
||||||
mkdir ${PREFIX}/dutch ; \
|
mkdir ${PREFIX}/dutch ; \
|
||||||
mkdir ${PREFIX}/dutch/txtfiles ; \
|
mkdir ${PREFIX}/dutch/txtfiles ; \
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* $Id$
|
||||||
* Example stylesheet MBSE BBS file listings.
|
* Example stylesheet MBSE BBS file listings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,5 +23,4 @@ A:active { color: red }
|
|||||||
TABLE { background: #CCCCCC }
|
TABLE { background: #CCCCCC }
|
||||||
TH { background: #99CCFF; font-family: Helvetica }
|
TH { background: #99CCFF; font-family: Helvetica }
|
||||||
TH.head { background: #FF9900; font-family: Helvetica }
|
TH.head { background: #FF9900; font-family: Helvetica }
|
||||||
TD { font-family: Fixed; font-size: 12pt }
|
TD { font-family: Fixed; font-size: 10pt }
|
||||||
|
|
||||||
|
@ -154,7 +154,6 @@ int main(int argc, char *argv[])
|
|||||||
int rc, maxrc, callno = 0, succno = 0;
|
int rc, maxrc, callno = 0, succno = 0;
|
||||||
char *answermode = NULL, *p = NULL, *cmd = NULL;
|
char *answermode = NULL, *p = NULL, *cmd = NULL;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char temp[81];
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
#ifdef MEMWATCH
|
#ifdef MEMWATCH
|
||||||
@ -288,30 +287,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
while (argv[optind]) {
|
while (argv[optind]) {
|
||||||
for (p = argv[optind]; (*p) && (*p == '*'); p++);
|
for (p = argv[optind]; (*p) && (*p == '*'); p++);
|
||||||
|
|
||||||
if (strncasecmp(p, "EMSI_NAKEEC3", 12) == 0) {
|
|
||||||
|
|
||||||
Syslog('+', "Detected IEMSI client, starting BBS");
|
|
||||||
sprintf(temp, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
|
|
||||||
socket_shutdown(mypid);
|
|
||||||
|
|
||||||
if (execl(temp, "mbsebbs", (char *)NULL) == -1)
|
|
||||||
perror("FATAL: Error loading BBS!");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this happens, nothing is logged!
|
|
||||||
*/
|
|
||||||
printf("\n\nFATAL: Loading of the BBS failed!\n\n");
|
|
||||||
sleep(3);
|
|
||||||
free_mem();
|
|
||||||
if (envptr)
|
|
||||||
free(envptr);
|
|
||||||
#ifdef MEMWATCH
|
|
||||||
mwTerm();
|
|
||||||
#endif
|
|
||||||
exit(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strcasecmp(argv[optind],"tsync") == 0) ||
|
if ((strcasecmp(argv[optind],"tsync") == 0) ||
|
||||||
(strcasecmp(argv[optind],"yoohoo") == 0) ||
|
(strcasecmp(argv[optind],"yoohoo") == 0) ||
|
||||||
(strcasecmp(argv[optind],"ibn") == 0) ||
|
(strcasecmp(argv[optind],"ibn") == 0) ||
|
||||||
|
@ -12,7 +12,8 @@ SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.c \
|
|||||||
postecho.c rollover.c tic.c areamgr.c filefind.c grlist.c maketags.c \
|
postecho.c rollover.c tic.c areamgr.c filefind.c grlist.c maketags.c \
|
||||||
mbmsg.c newspost.c postemail.c scan.c toberep.c atoul.c filemgr.c \
|
mbmsg.c newspost.c postemail.c scan.c toberep.c atoul.c filemgr.c \
|
||||||
hash.c mbaff.c mbseq.c notify.c postnetmail.c scannews.c tosspkt.c \
|
hash.c mbaff.c mbseq.c notify.c postnetmail.c scannews.c tosspkt.c \
|
||||||
mbfkill.c mbfutil.c mbfindex.c mbfcheck.c mbfpack.c mbflist.c mbfadopt.c
|
mbfkill.c mbfutil.c mbfindex.c mbfcheck.c mbfpack.c mbflist.c mbfadopt.c \
|
||||||
|
mbfimport.c virscan.c
|
||||||
HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \
|
HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \
|
||||||
postnetmail.h scannews.h tosspkt.h addpkt.h bwrite.h forward.h \
|
postnetmail.h scannews.h tosspkt.h addpkt.h bwrite.h forward.h \
|
||||||
lhash.h mbfido.h mkftnhdr.h paths.h ptic.h sendmail.h tracker.h \
|
lhash.h mbfido.h mkftnhdr.h paths.h ptic.h sendmail.h tracker.h \
|
||||||
@ -21,8 +22,9 @@ HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \
|
|||||||
msgutil.h post.h rnews.h storenet.h utic.h areamgr.h filefind.h \
|
msgutil.h post.h rnews.h storenet.h utic.h areamgr.h filefind.h \
|
||||||
grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h \
|
grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h \
|
||||||
atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \
|
atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \
|
||||||
mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h
|
mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h \
|
||||||
MBFIDO_OBJS = flock.o tosspkt.o mbfido.o hatch.o maketags.o \
|
mbfimport.h virscan.h
|
||||||
|
MBFIDO_OBJS = flock.o tosspkt.o mbfido.o hatch.o maketags.o virscan.o \
|
||||||
tracker.o makestat.o scannews.o lhash.o \
|
tracker.o makestat.o scannews.o lhash.o \
|
||||||
pack.o ulock.o tic.o ptic.o utic.o mover.o hash.o mkftnhdr.o \
|
pack.o ulock.o tic.o ptic.o utic.o mover.o hash.o mkftnhdr.o \
|
||||||
addbbs.o magic.o fsort.o toberep.o ftn2rfc.o atoul.o ping.o \
|
addbbs.o magic.o fsort.o toberep.o ftn2rfc.o atoul.o ping.o \
|
||||||
@ -33,7 +35,8 @@ MBSEQ_OBJS = mbseq.o
|
|||||||
MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o
|
MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o
|
||||||
MBINDEX_OBJS = mbindex.o
|
MBINDEX_OBJS = mbindex.o
|
||||||
MBDIFF_OBJS = mbdiff.o
|
MBDIFF_OBJS = mbdiff.o
|
||||||
MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbflist.o mbfadopt.o
|
MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbflist.o mbfadopt.o \
|
||||||
|
mbfimport.o virscan.o
|
||||||
MBMSG_OBJS = post.o mbmsg.o
|
MBMSG_OBJS = post.o mbmsg.o
|
||||||
MBFIDO_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
|
MBFIDO_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
|
||||||
../lib/libdbase.a ../lib/libmbinet.a
|
../lib/libdbase.a ../lib/libmbinet.a
|
||||||
@ -134,7 +137,7 @@ hatch.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/
|
|||||||
mbdiff.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbdiff.h
|
mbdiff.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbdiff.h
|
||||||
mgrutil.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h sendmail.h mgrutil.h
|
mgrutil.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h sendmail.h mgrutil.h
|
||||||
pack.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ../lib/dbnode.h pack.h
|
pack.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ../lib/dbnode.h pack.h
|
||||||
ptic.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbtic.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbdupe.h ulock.h mover.h toberep.h tic.h utic.h addbbs.h magic.h forward.h rollover.h ptic.h magic.h
|
ptic.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbtic.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbdupe.h ulock.h mover.h toberep.h tic.h utic.h addbbs.h magic.h forward.h rollover.h ptic.h magic.h virscan.h
|
||||||
sendmail.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ../lib/dbmsgs.h addpkt.h rollover.h sendmail.h
|
sendmail.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ../lib/dbmsgs.h addpkt.h rollover.h sendmail.h
|
||||||
tracker.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbftn.h tracker.h
|
tracker.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbftn.h tracker.h
|
||||||
addpkt.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/dbmsgs.h pack.h addpkt.h
|
addpkt.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/dbmsgs.h pack.h addpkt.h
|
||||||
@ -151,7 +154,7 @@ aliasdb.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../li
|
|||||||
cookie.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h cookie.h
|
cookie.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h cookie.h
|
||||||
fsort.o: ../lib/libs.h ../lib/clcomm.h fsort.h
|
fsort.o: ../lib/libs.h ../lib/clcomm.h fsort.h
|
||||||
magic.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbtic.h tic.h utic.h magic.h
|
magic.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbtic.h tic.h utic.h magic.h
|
||||||
mbfile.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfutil.h mbfile.h
|
mbfile.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfadopt.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfimport.h mbfutil.h mbfile.h
|
||||||
mover.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h mover.h
|
mover.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h mover.h
|
||||||
post.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h post.h
|
post.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h post.h
|
||||||
rnews.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h pack.h rfc2ftn.h mbfido.h paths.h rnews.h
|
rnews.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h pack.h rfc2ftn.h mbfido.h paths.h rnews.h
|
||||||
@ -190,4 +193,7 @@ mbfindex.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../l
|
|||||||
mbfcheck.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfcheck.h
|
mbfcheck.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfcheck.h
|
||||||
mbfpack.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfpack.h
|
mbfpack.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfpack.h
|
||||||
mbflist.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbflist.h
|
mbflist.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbflist.h
|
||||||
|
mbfadopt.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h virscan.h mbfutil.h mbflist.h
|
||||||
|
mbfimport.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfimport.h
|
||||||
|
virscan.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h virscan.h
|
||||||
# End of generated dependencies
|
# End of generated dependencies
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "../lib/common.h"
|
#include "../lib/common.h"
|
||||||
#include "../lib/clcomm.h"
|
#include "../lib/clcomm.h"
|
||||||
#include "../lib/dbcfg.h"
|
#include "../lib/dbcfg.h"
|
||||||
|
#include "virscan.h"
|
||||||
#include "mbfutil.h"
|
#include "mbfutil.h"
|
||||||
#include "mbflist.h"
|
#include "mbflist.h"
|
||||||
|
|
||||||
@ -45,13 +46,12 @@ extern int do_quiet; /* Supress screen output */
|
|||||||
|
|
||||||
void AdoptFile(int Area, char *File, char *Description)
|
void AdoptFile(int Area, char *File, char *Description)
|
||||||
{
|
{
|
||||||
FILE *pAreas, *pFile, *fp;
|
FILE *pAreas, *fp;
|
||||||
char *sAreas, *fAreas, *temp, *temp2, *unarc, *cmd, *pwd;
|
char *sAreas, *temp, *temp2, *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;
|
||||||
int i, j, k, lines = 0, File_id_cnt = 0;
|
int i, j, k, lines = 0, File_id_cnt = 0;
|
||||||
int Insert, Done = FALSE, Found = FALSE;
|
|
||||||
struct FILERecord fdb;
|
struct FILERecord fdb;
|
||||||
|
|
||||||
Syslog('-', "Adopt(%d, %s, %s)", Area, MBSE_SS(File), MBSE_SS(Description));
|
Syslog('-', "Adopt(%d, %s, %s)", Area, MBSE_SS(File), MBSE_SS(Description));
|
||||||
@ -89,23 +89,13 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (area.Available) {
|
if (area.Available) {
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
pwd = calloc(PATH_MAX, sizeof(char));
|
pwd = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
|
if (CheckFDB(Area, area.Path))
|
||||||
getcwd(pwd, PATH_MAX);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the file database, create new one if it doesn't excist.
|
|
||||||
*/
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(0);
|
die(0);
|
||||||
}
|
getcwd(pwd, PATH_MAX);
|
||||||
}
|
|
||||||
|
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
printf("Adopt file: %s ", File);
|
printf("Adopt file: %s ", File);
|
||||||
@ -113,96 +103,45 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unarc = unpacker(File)) == NULL)
|
sprintf(temp, "%s/%s", pwd, File);
|
||||||
Syslog('+', "Unknown archive format %s", File);
|
if ((unarc = unpacker(File)) == NULL) {
|
||||||
else {
|
Syslog('+', "No known archive: %s", File);
|
||||||
|
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
|
||||||
|
mkdirs(temp2);
|
||||||
|
if (file_cp(temp, temp2)) {
|
||||||
|
WriteError("Can't copy file to %s", temp2);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Can't copy file to %s\n", temp2);
|
||||||
|
die(0);
|
||||||
|
} else {
|
||||||
|
if (!do_quiet) {
|
||||||
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
IsVirus = VirScan();
|
||||||
|
if (IsVirus) {
|
||||||
|
DeleteVirusWork();
|
||||||
|
chdir(pwd);
|
||||||
|
WriteError("Virus found");
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Virus found\n");
|
||||||
|
die(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
IsArchive = TRUE;
|
IsArchive = TRUE;
|
||||||
if (strlen(area.Archiver) && (strcmp(unarc, area.Archiver) == 0))
|
if (strlen(area.Archiver) && (strcmp(unarc, area.Archiver) == 0))
|
||||||
MustRearc = TRUE;
|
MustRearc = TRUE;
|
||||||
}
|
UnPacked = UnpackFile(temp);
|
||||||
|
if (!UnPacked)
|
||||||
if (IsArchive) {
|
|
||||||
/*
|
|
||||||
* Check if there is a temp directory to unpack the archive.
|
|
||||||
*/
|
|
||||||
sprintf(temp, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
|
||||||
if ((access(temp, R_OK)) != 0) {
|
|
||||||
if (mkdir(temp, 0777)) {
|
|
||||||
WriteError("$Can't create %s", temp);
|
|
||||||
if (!do_quiet)
|
|
||||||
printf("Can't create %s\n", temp);
|
|
||||||
die(0);
|
die(0);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check for stale FILE_ID.DIZ files
|
|
||||||
*/
|
|
||||||
sprintf(temp, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
|
||||||
if (!unlink(temp))
|
|
||||||
Syslog('+', "Removed stale %s", temp);
|
|
||||||
sprintf(temp, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
|
||||||
if (!unlink(temp))
|
|
||||||
Syslog('+', "Removed stale %s", temp);
|
|
||||||
|
|
||||||
if (!getarchiver(unarc)) {
|
|
||||||
WriteError("No archiver available for %s", File);
|
|
||||||
if (!do_quiet)
|
|
||||||
printf("No archiver available for %s\n", File);
|
|
||||||
die(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = xstrcpy(archiver.funarc);
|
|
||||||
if ((cmd == NULL) || (cmd == "")) {
|
|
||||||
WriteError("No unarc command available");
|
|
||||||
if (!do_quiet)
|
|
||||||
printf("No unarc command available\n");
|
|
||||||
die(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(temp, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
|
||||||
if (chdir(temp) != 0) {
|
|
||||||
WriteError("$Can't change to %s", temp);
|
|
||||||
die(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", pwd, File);
|
|
||||||
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
|
||||||
UnPacked = TRUE;
|
|
||||||
} else {
|
|
||||||
chdir(pwd);
|
|
||||||
WriteError("Unpack error, file may be corrupt");
|
|
||||||
DeleteVirusWork();
|
|
||||||
die(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
sprintf(temp, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
|
||||||
WriteError("No virus scanners defined");
|
|
||||||
} else {
|
|
||||||
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
|
|
||||||
|
|
||||||
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
|
||||||
cmd = NULL;
|
|
||||||
if (virscan.available) {
|
|
||||||
cmd = xstrcpy(virscan.scanner);
|
|
||||||
cmd = xstrcat(cmd, (char *)" ");
|
|
||||||
cmd = xstrcat(cmd, virscan.options);
|
|
||||||
if (execute(cmd, (char *)"*", (char *)NULL, (char *)"/dev/null",
|
|
||||||
(char *)"/dev/null", (char *)"/dev/null") != virscan.error) {
|
|
||||||
WriteError("Virus found by %s", virscan.comment);
|
|
||||||
IsVirus = TRUE;
|
|
||||||
}
|
|
||||||
free(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
|
IsVirus = VirScan();
|
||||||
if (IsVirus) {
|
if (IsVirus) {
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(pwd);
|
chdir(pwd);
|
||||||
@ -222,7 +161,10 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
strcpy(fdb.Uploader, CFG.sysop_name);
|
strcpy(fdb.Uploader, CFG.sysop_name);
|
||||||
fdb.UploadDate = time(NULL);
|
fdb.UploadDate = time(NULL);
|
||||||
|
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
if (UnPacked) {
|
||||||
|
/*
|
||||||
|
* Try to get a FILE_ID.DIZ
|
||||||
|
*/
|
||||||
sprintf(temp, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
if (file_cp(temp, temp2) == 0) {
|
if (file_cp(temp, temp2) == 0) {
|
||||||
@ -232,6 +174,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
if (file_cp(temp, temp2) == 0)
|
if (file_cp(temp, temp2) == 0)
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File_Id) {
|
if (File_Id) {
|
||||||
Syslog('-', "FILE_ID.DIZ found");
|
Syslog('-', "FILE_ID.DIZ found");
|
||||||
if ((fp = fopen(temp2, "r"))) {
|
if ((fp = fopen(temp2, "r"))) {
|
||||||
@ -280,21 +223,30 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
Syslog('f', "\"%s\"", fdb.Desc[i]);
|
Syslog('f', "\"%s\"", fdb.Desc[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!File_id_cnt) {
|
if (!File_id_cnt) {
|
||||||
if (Description == NULL) {
|
if (Description == NULL) {
|
||||||
WriteError("No FILE_ID.DIZ and no description on the commandline");
|
WriteError("No FILE_ID.DIZ and no description on the commandline");
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("No FILE_ID.DIZ and no description on the commandline\n");
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
fclose(pFile);
|
|
||||||
die(0);
|
die(0);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Create description from the commandline.
|
* Create description from the commandline.
|
||||||
*/
|
*/
|
||||||
if (strlen(Description) < 48) {
|
if (strlen(Description) < 48) {
|
||||||
|
/*
|
||||||
|
* Less then 48 chars, copy and ready.
|
||||||
|
*/
|
||||||
strcpy(fdb.Desc[0], Description);
|
strcpy(fdb.Desc[0], Description);
|
||||||
File_id_cnt++;
|
File_id_cnt++;
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* More then 48 characters, break into multiple
|
||||||
|
* lines not longer then 48 characters.
|
||||||
|
*/
|
||||||
memset(&TDesc, 0, sizeof(TDesc));
|
memset(&TDesc, 0, sizeof(TDesc));
|
||||||
strcpy(TDesc, Description);
|
strcpy(TDesc, Description);
|
||||||
while (strlen(TDesc) > 48) {
|
while (strlen(TDesc) > 48) {
|
||||||
@ -319,7 +271,16 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
*/
|
*/
|
||||||
chdir(pwd);
|
chdir(pwd);
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
|
if (strlen(File) < 13) {
|
||||||
strcpy(fdb.Name, File);
|
strcpy(fdb.Name, File);
|
||||||
|
for (i = 0; i < strlen(File); i++)
|
||||||
|
fdb.Name[i] = toupper(fdb.Name[i]);
|
||||||
|
} else {
|
||||||
|
WriteError("Long filename conversion not supported");
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Long filename conversion not supported\n");
|
||||||
|
die(0);
|
||||||
|
}
|
||||||
strcpy(fdb.LName, File);
|
strcpy(fdb.LName, File);
|
||||||
fdb.Size = file_size(File);
|
fdb.Size = file_size(File);
|
||||||
fdb.Crc32 = file_crc(File, TRUE);
|
fdb.Crc32 = file_crc(File, TRUE);
|
||||||
@ -331,107 +292,18 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirs(temp2);
|
if (AddFile(fdb, Area, temp2, File) == FALSE) {
|
||||||
if (file_cp(fdb.LName, temp2)) {
|
|
||||||
WriteError("Can't move file in place");
|
|
||||||
fclose(pFile);
|
|
||||||
die(0);
|
die(0);
|
||||||
}
|
}
|
||||||
|
Syslog('+', "File %s added to area %d", File, Area);
|
||||||
sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), Area);
|
|
||||||
fseek(pFile, 0, SEEK_END);
|
|
||||||
if (ftell(pFile) == 0) {
|
|
||||||
/*
|
|
||||||
* No records yet
|
|
||||||
*/
|
|
||||||
fwrite(&fdb, sizeof(fdb), 1, pFile);
|
|
||||||
fclose(pFile);
|
|
||||||
free(temp2);
|
|
||||||
Syslog('+', "Added file in area %d", Area);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Files are already there. Find the right spot.
|
|
||||||
*/
|
|
||||||
fseek(pFile, 0, SEEK_SET);
|
|
||||||
|
|
||||||
Insert = 0;
|
|
||||||
do {
|
|
||||||
if (fread(&file, sizeof(file), 1, pFile) != 1)
|
|
||||||
Done = TRUE;
|
|
||||||
if (!Done) {
|
|
||||||
if (strcmp(fdb.Name, file.Name) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
Insert++;
|
|
||||||
} else {
|
|
||||||
if (strcmp(fdb.Name, file.Name) < 0)
|
|
||||||
Found = TRUE;
|
|
||||||
else
|
|
||||||
Insert++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while ((!Found) && (!Done));
|
|
||||||
|
|
||||||
if (Found) {
|
|
||||||
if ((fp = fopen(temp2, "a+")) == NULL) {
|
|
||||||
WriteError("Can't create %s", temp2);
|
|
||||||
die(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(pFile, 0, SEEK_SET);
|
|
||||||
/*
|
|
||||||
* Copy until the insert point
|
|
||||||
*/
|
|
||||||
for (i = 0; i < Insert; i++) {
|
|
||||||
fread(&file, sizeof(file), 1, pFile);
|
|
||||||
/*
|
|
||||||
* If we are importing a file with the same name,
|
|
||||||
* skip the original record and put the new one in place.
|
|
||||||
*/
|
|
||||||
if (strcmp(file.Name, fdb.Name) != 0)
|
|
||||||
fwrite(&file, sizeof(file), 1, fp);
|
|
||||||
}
|
|
||||||
if (area.AddAlpha)
|
|
||||||
fwrite(&fdb, sizeof(fdb), 1, fp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Append the rest of the records
|
|
||||||
*/
|
|
||||||
while (fread(&file, sizeof(file), 1, fp) == 1) {
|
|
||||||
if (strcmp(file.Name, fdb.Name) != 0)
|
|
||||||
fwrite(&file, sizeof(file), 1, fp);
|
|
||||||
}
|
|
||||||
if (!area.AddAlpha)
|
|
||||||
fwrite(&fdb, sizeof(fdb), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
fclose(pFile);
|
|
||||||
|
|
||||||
if (unlink(fAreas) == 0) {
|
|
||||||
rename(temp2, fAreas);
|
|
||||||
chmod(fAreas, 0660);
|
|
||||||
Syslog('+', "Added file in area %d", Area);
|
|
||||||
} else {
|
|
||||||
WriteError("$Can't unlink %s", fAreas);
|
|
||||||
unlink(temp2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Append file record
|
|
||||||
*/
|
|
||||||
fseek(pFile, 0, SEEK_END);
|
|
||||||
fwrite(&fdb, sizeof(fdb), 1, pFile);
|
|
||||||
fclose(pFile);
|
|
||||||
Syslog('+', "Added file in area %d", Area);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MustRearc) {
|
if (MustRearc) {
|
||||||
/* Here we should call the rearc function */
|
/* Here we should call the rearc function */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
free(pwd);
|
free(pwd);
|
||||||
|
free(temp2);
|
||||||
free(temp);
|
free(temp);
|
||||||
free(fAreas);
|
|
||||||
} else {
|
} else {
|
||||||
WriteError("Area %d is not available", Area);
|
WriteError("Area %d is not available", Area);
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
|
@ -136,7 +136,7 @@ void Check(void)
|
|||||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||||
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
sprintf(newdir, "%s/%s", area.Path, file.Name);
|
sprintf(newdir, "%s/%s", area.Path, file.LName);
|
||||||
|
|
||||||
if (file_exist(newdir, R_OK)) {
|
if (file_exist(newdir, R_OK)) {
|
||||||
Syslog('+', "File %s area %d not on disk.", newdir, i);
|
Syslog('+', "File %s area %d not on disk.", newdir, i);
|
||||||
@ -155,19 +155,19 @@ void Check(void)
|
|||||||
Marker();
|
Marker();
|
||||||
Update = FALSE;
|
Update = FALSE;
|
||||||
if (file_time(newdir) != file.FileDate) {
|
if (file_time(newdir) != file.FileDate) {
|
||||||
Syslog('!', "Date mismatch area %d file %s", i, file.Name);
|
Syslog('!', "Date mismatch area %d file %s", i, file.LName);
|
||||||
file.FileDate = file_time(newdir);
|
file.FileDate = file_time(newdir);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
if (file_size(newdir) != file.Size) {
|
if (file_size(newdir) != file.Size) {
|
||||||
Syslog('!', "Size mismatch area %d file %s", i, file.Name);
|
Syslog('!', "Size mismatch area %d file %s", i, file.LName);
|
||||||
file.Size = file_size(newdir);
|
file.Size = file_size(newdir);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
if (file_crc(newdir, CFG.slow_util && do_quiet) != file.Crc32) {
|
if (file_crc(newdir, CFG.slow_util && do_quiet) != file.Crc32) {
|
||||||
Syslog('!', "CRC error area %d, file %s", i, file.Name);
|
Syslog('!', "CRC error area %d, file %s", i, file.LName);
|
||||||
file.Crc32 = file_crc(newdir, CFG.slow_util && do_quiet);
|
file.Crc32 = file_crc(newdir, CFG.slow_util && do_quiet);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
@ -192,7 +192,7 @@ void Check(void)
|
|||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
rewind(pFile);
|
rewind(pFile);
|
||||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||||
if (strcmp(file.Name, de->d_name) == 0) {
|
if (strcmp(file.LName, de->d_name) == 0) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "mbfcheck.h"
|
#include "mbfcheck.h"
|
||||||
#include "mbfpack.h"
|
#include "mbfpack.h"
|
||||||
#include "mbflist.h"
|
#include "mbflist.h"
|
||||||
|
#include "mbfimport.h"
|
||||||
#include "mbfutil.h"
|
#include "mbfutil.h"
|
||||||
#include "mbfile.h"
|
#include "mbfile.h"
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ int do_pack = FALSE; /* Pack filebase */
|
|||||||
int do_check = FALSE; /* Check filebase */
|
int do_check = FALSE; /* Check filebase */
|
||||||
int do_kill = FALSE; /* Kill/move old files */
|
int do_kill = FALSE; /* Kill/move old files */
|
||||||
int do_index = FALSE; /* Create request index */
|
int do_index = FALSE; /* Create request index */
|
||||||
|
int do_import= FALSE; /* Import files in area */
|
||||||
int do_list = FALSE; /* List fileareas */
|
int do_list = FALSE; /* List fileareas */
|
||||||
extern int e_pid; /* Pid of external process */
|
extern int e_pid; /* Pid of external process */
|
||||||
extern int show_log; /* Show logging */
|
extern int show_log; /* Show logging */
|
||||||
@ -113,6 +115,15 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (!strncmp(argv[i], "in", 2))
|
if (!strncmp(argv[i], "in", 2))
|
||||||
do_index = TRUE;
|
do_index = TRUE;
|
||||||
|
if (!strncmp(argv[i], "im", 2)) {
|
||||||
|
if (argc > (i + 1)) {
|
||||||
|
do_import = TRUE;
|
||||||
|
i++;
|
||||||
|
Area = atoi(argv[i]);
|
||||||
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
|
cmd = xstrcat(cmd, argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!strncmp(argv[i], "l", 1))
|
if (!strncmp(argv[i], "l", 1))
|
||||||
do_list = TRUE;
|
do_list = TRUE;
|
||||||
if (!strncmp(argv[i], "p", 1))
|
if (!strncmp(argv[i], "p", 1))
|
||||||
@ -125,7 +136,7 @@ int main(int argc, char **argv)
|
|||||||
do_quiet = TRUE;
|
do_quiet = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(do_pack || do_check || do_kill || do_index || do_list || do_adopt))
|
if (!(do_pack || do_check || do_kill || do_index || do_import || do_list || do_adopt))
|
||||||
Help();
|
Help();
|
||||||
|
|
||||||
ProgName();
|
ProgName();
|
||||||
@ -146,6 +157,9 @@ int main(int argc, char **argv)
|
|||||||
if (do_adopt)
|
if (do_adopt)
|
||||||
AdoptFile(Area, FileName, Description);
|
AdoptFile(Area, FileName, Description);
|
||||||
|
|
||||||
|
if (do_import)
|
||||||
|
ImportFiles(Area);
|
||||||
|
|
||||||
if (do_kill)
|
if (do_kill)
|
||||||
Kill();
|
Kill();
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ void Index(void)
|
|||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
sIndex = calloc(PATH_MAX, sizeof(char));
|
sIndex = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
IsDoing("Kill files");
|
IsDoing("Index files");
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
colour(3, 0);
|
colour(3, 0);
|
||||||
printf("Create filerequest index...\n");
|
printf("Create filerequest index...\n");
|
||||||
|
@ -40,16 +40,6 @@
|
|||||||
|
|
||||||
|
|
||||||
extern int do_quiet; /* Supress screen output */
|
extern int do_quiet; /* Supress screen output */
|
||||||
//int do_pack = FALSE; /* Pack filebase */
|
|
||||||
//int do_check = FALSE; /* Check filebase */
|
|
||||||
//int do_kill = FALSE; /* Kill/move old files */
|
|
||||||
//int do_index = FALSE; /* Create request index */
|
|
||||||
//int do_list = FALSE; /* List fileareas */
|
|
||||||
//extern int e_pid; /* Pid of external process */
|
|
||||||
//extern int show_log; /* Show logging */
|
|
||||||
//time_t t_start; /* Start time */
|
|
||||||
//time_t t_end; /* End time */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +50,7 @@ extern int do_quiet; /* Supress screen output */
|
|||||||
void PackFileBase(void)
|
void PackFileBase(void)
|
||||||
{
|
{
|
||||||
FILE *fp, *pAreas, *pFile;
|
FILE *fp, *pAreas, *pFile;
|
||||||
int i, iAreas, iAreasNew = 0;
|
int i, iAreas, iAreasNew = 0, rc;
|
||||||
int iTotal = 0, iRemoved = 0;
|
int iTotal = 0, iRemoved = 0;
|
||||||
char *sAreas, *fAreas, *fTmp, fn[PATH_MAX];
|
char *sAreas, *fAreas, *fTmp, fn[PATH_MAX];
|
||||||
|
|
||||||
@ -127,7 +117,9 @@ void PackFileBase(void)
|
|||||||
iRemoved++;
|
iRemoved++;
|
||||||
Syslog('+', "Removed file \"%s\" from area %d", file.Name, i);
|
Syslog('+', "Removed file \"%s\" from area %d", file.Name, i);
|
||||||
sprintf(fn, "%s/%s", area.Path, file.Name);
|
sprintf(fn, "%s/%s", area.Path, file.Name);
|
||||||
Syslog('+', "Unlink %s result %d", fn, unlink(fn));
|
rc = unlink(fn);
|
||||||
|
if (rc)
|
||||||
|
Syslog('+', "Unlink %s result %d", fn, rc);
|
||||||
/*
|
/*
|
||||||
* If a dotted version (thumbnail) exists, remove it silently
|
* If a dotted version (thumbnail) exists, remove it silently
|
||||||
*/
|
*/
|
||||||
|
235
mbfido/mbfutil.c
235
mbfido/mbfutil.c
@ -116,7 +116,7 @@ void Help(void)
|
|||||||
printf(" a adopt <area> <file> [desc] Adopt file to area\n");
|
printf(" a adopt <area> <file> [desc] Adopt file to area\n");
|
||||||
printf(" c check Check filebase\n");
|
printf(" c check Check filebase\n");
|
||||||
// printf(" d delete <area> <file> Mark file in area for deletion\n");
|
// printf(" d delete <area> <file> Mark file in area for deletion\n");
|
||||||
// printf(" im import <area> Import files in current dir to area\n");
|
printf(" im import <area> Import files in current dir to area\n");
|
||||||
printf(" in index Create filerequest index\n");
|
printf(" in index Create filerequest index\n");
|
||||||
printf(" k kill Kill/move old files\n");
|
printf(" k kill Kill/move old files\n");
|
||||||
printf(" l list List file areas\n");
|
printf(" l list List file areas\n");
|
||||||
@ -220,3 +220,236 @@ void DeleteVirusWork()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int UnpackFile(char *File)
|
||||||
|
{
|
||||||
|
char *temp, *pwd, *unarc, *cmd;
|
||||||
|
|
||||||
|
Syslog('f', "UnpackFile(%s)", File);
|
||||||
|
|
||||||
|
if ((unarc = unpacker(File)) == NULL) {
|
||||||
|
Syslog('+', "Unknown archive format %s", File);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
pwd = calloc(PATH_MAX, sizeof(char));
|
||||||
|
getcwd(pwd, PATH_MAX);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if there is a temp directory to unpack the archive.
|
||||||
|
*/
|
||||||
|
sprintf(temp, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
|
if ((access(temp, R_OK)) != 0) {
|
||||||
|
if (mkdir(temp, 0777)) {
|
||||||
|
WriteError("$Can't create %s", temp);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Can't create %s\n", temp);
|
||||||
|
die(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for stale FILE_ID.DIZ files
|
||||||
|
*/
|
||||||
|
sprintf(temp, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
|
if (!unlink(temp))
|
||||||
|
Syslog('+', "Removed stale %s", temp);
|
||||||
|
sprintf(temp, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
|
if (!unlink(temp))
|
||||||
|
Syslog('+', "Removed stale %s", temp);
|
||||||
|
|
||||||
|
if (!getarchiver(unarc)) {
|
||||||
|
WriteError("No archiver available for %s", File);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("No archiver available for %s\n", File);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = xstrcpy(archiver.funarc);
|
||||||
|
if ((cmd == NULL) || (cmd == "")) {
|
||||||
|
WriteError("No unarc command available");
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("No unarc command available\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(temp, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
|
if (chdir(temp) != 0) {
|
||||||
|
WriteError("$Can't change to %s", temp);
|
||||||
|
die(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (execute(cmd, File, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
|
chdir(pwd);
|
||||||
|
free(temp);
|
||||||
|
free(pwd);
|
||||||
|
free(cmd);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
chdir(pwd);
|
||||||
|
WriteError("Unpack error, file may be corrupt");
|
||||||
|
DeleteVirusWork();
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add file to the BBS. The file is in the current
|
||||||
|
* directory. The fdb record already has all needed
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
|
int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
|
||||||
|
{
|
||||||
|
char *temp1, *temp2;
|
||||||
|
FILE *fp1, *fp2;
|
||||||
|
int i, Insert, Done = FALSE, Found = FALSE;
|
||||||
|
|
||||||
|
mkdirs(DestPath);
|
||||||
|
if (file_cp(FromPath, DestPath)) {
|
||||||
|
WriteError("Can't move file in place");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||||
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(temp1, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
|
||||||
|
sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), Area);
|
||||||
|
|
||||||
|
fp1 = fopen(temp1, "r+");
|
||||||
|
fseek(fp1, 0, SEEK_END);
|
||||||
|
if (ftell(fp1) == 0) {
|
||||||
|
/*
|
||||||
|
* No records yet
|
||||||
|
*/
|
||||||
|
fwrite(&fdb, sizeof(fdb), 1, fp1);
|
||||||
|
fclose(fp1);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Files are already there. Find the right spot.
|
||||||
|
*/
|
||||||
|
fseek(fp1, 0, SEEK_SET);
|
||||||
|
|
||||||
|
Insert = 0;
|
||||||
|
do {
|
||||||
|
if (fread(&file, sizeof(file), 1, fp1) != 1)
|
||||||
|
Done = TRUE;
|
||||||
|
if (!Done) {
|
||||||
|
if (strcmp(fdb.Name, file.Name) == 0) {
|
||||||
|
Found = TRUE;
|
||||||
|
Insert++;
|
||||||
|
} else {
|
||||||
|
if (strcmp(fdb.Name, file.Name) < 0)
|
||||||
|
Found = TRUE;
|
||||||
|
else
|
||||||
|
Insert++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ((!Found) && (!Done));
|
||||||
|
|
||||||
|
if (Found) {
|
||||||
|
if ((fp2 = fopen(temp2, "a+")) == NULL) {
|
||||||
|
WriteError("Can't create %s", temp2);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(fp1, 0, SEEK_SET);
|
||||||
|
/*
|
||||||
|
* Copy until the insert point
|
||||||
|
*/
|
||||||
|
for (i = 0; i < Insert; i++) {
|
||||||
|
fread(&file, sizeof(file), 1, fp1);
|
||||||
|
/*
|
||||||
|
* If we are importing a file with the same name,
|
||||||
|
* skip the original record and put the new one in place.
|
||||||
|
*/
|
||||||
|
if (strcmp(file.Name, fdb.Name) != 0)
|
||||||
|
fwrite(&file, sizeof(file), 1, fp2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (area.AddAlpha)
|
||||||
|
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Append the rest of the records
|
||||||
|
*/
|
||||||
|
while (fread(&file, sizeof(file), 1, fp1) == 1) {
|
||||||
|
if (strcmp(file.Name, fdb.Name) != 0)
|
||||||
|
fwrite(&file, sizeof(file), 1, fp2);
|
||||||
|
}
|
||||||
|
if (!area.AddAlpha)
|
||||||
|
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||||
|
fclose(fp1);
|
||||||
|
fclose(fp2);
|
||||||
|
|
||||||
|
if (unlink(temp1) == 0) {
|
||||||
|
rename(temp2, temp1);
|
||||||
|
chmod(temp1, 0660);
|
||||||
|
} else {
|
||||||
|
WriteError("$Can't unlink %s", temp1);
|
||||||
|
unlink(temp2);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else { /* if (Found) */
|
||||||
|
/*
|
||||||
|
* Append file record
|
||||||
|
*/
|
||||||
|
fseek(fp1, 0, SEEK_END);
|
||||||
|
fwrite(&fdb, sizeof(fdb), 1, fp1);
|
||||||
|
fclose(fp1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(temp1);
|
||||||
|
free(temp2);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CheckFDB(int Area, char *Path)
|
||||||
|
{
|
||||||
|
char *temp;
|
||||||
|
FILE *fp;
|
||||||
|
int rc = FALSE;
|
||||||
|
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(temp, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open the file database, create new one if it doesn't excist.
|
||||||
|
*/
|
||||||
|
if ((fp = fopen(temp, "r+")) == NULL) {
|
||||||
|
Syslog('!', "Creating new %s", temp);
|
||||||
|
if ((fp = fopen(temp, "a+")) == NULL) {
|
||||||
|
WriteError("$Can't create %s", temp);
|
||||||
|
rc = TRUE;
|
||||||
|
} else {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the right attributes
|
||||||
|
*/
|
||||||
|
chmod(temp, 0660);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now check the download directory
|
||||||
|
*/
|
||||||
|
if (access(Path, W_OK) == -1) {
|
||||||
|
sprintf(temp, "%s/foobar", Path);
|
||||||
|
if (mkdirs(temp))
|
||||||
|
Syslog('+', "Created directory %s", Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(temp);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,5 +8,8 @@ void die(int onsig); /* Shutdown and cleanup */
|
|||||||
void Help(void); /* Show help screen */
|
void Help(void); /* Show help screen */
|
||||||
void Marker(void); /* Eyecatcher */
|
void Marker(void); /* Eyecatcher */
|
||||||
void DeleteVirusWork(void); /* Delete unarc directory */
|
void DeleteVirusWork(void); /* Delete unarc directory */
|
||||||
|
int UnpackFile(char *File); /* Unpack archive */
|
||||||
|
int AddFile(struct FILERecord, int, char *, char *);
|
||||||
|
int CheckFDB(int, char *); /* Check FDB of area */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* File ..................: mbfido/ptic.c
|
* $Id$
|
||||||
* Purpose ...............: Process 1 .tic file
|
* Purpose ...............: Process 1 .tic file
|
||||||
* Last modification date : 31-Jul-2001
|
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2001
|
* Copyright (C) 1997-2001
|
||||||
@ -48,6 +47,7 @@
|
|||||||
#include "rollover.h"
|
#include "rollover.h"
|
||||||
#include "ptic.h"
|
#include "ptic.h"
|
||||||
#include "magic.h"
|
#include "magic.h"
|
||||||
|
#include "virscan.h"
|
||||||
|
|
||||||
|
|
||||||
#define UNPACK_FACTOR 300
|
#define UNPACK_FACTOR 300
|
||||||
@ -501,28 +501,8 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
|||||||
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);
|
||||||
}
|
}
|
||||||
sprintf(temp2, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
|
|
||||||
|
|
||||||
if ((fp = fopen(temp2, "r")) == NULL) {
|
|
||||||
WriteError("No virus scanners defined");
|
|
||||||
} else {
|
|
||||||
fread(&virscanhdr, sizeof(virscanhdr), 1, fp);
|
|
||||||
|
|
||||||
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
|
|
||||||
cmd = NULL;
|
|
||||||
if (virscan.available) {
|
|
||||||
cmd = xstrcpy(virscan.scanner);
|
|
||||||
cmd = xstrcat(cmd, (char *)" ");
|
|
||||||
cmd = xstrcat(cmd, virscan.options);
|
|
||||||
if (execute(cmd, (char *)"*", (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") != virscan.error) {
|
|
||||||
Syslog('!', "Virus found by %s", virscan.comment);
|
|
||||||
IsVirus = TRUE;
|
|
||||||
}
|
|
||||||
free(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
|
IsVirus = VirScan();
|
||||||
if (IsVirus) {
|
if (IsVirus) {
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(TIC.Inbound);
|
chdir(TIC.Inbound);
|
||||||
@ -530,7 +510,6 @@ int ProcessTic(fa_list *sbl, char *Realname)
|
|||||||
free(Temp);
|
free(Temp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
printf("Checking \b\b\b\b\b\b\b\b\b\b");
|
printf("Checking \b\b\b\b\b\b\b\b\b\b");
|
||||||
|
@ -163,7 +163,7 @@ void E_F(long areanr)
|
|||||||
set_color(WHITE, BLACK);
|
set_color(WHITE, BLACK);
|
||||||
mvprintw(y, 1, (char *)"%4d.", o + i);
|
mvprintw(y, 1, (char *)"%4d.", o + i);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", area.Path, file.Name);
|
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||||
Ondisk = ((stat(temp, &statfile)) != -1);
|
Ondisk = ((stat(temp, &statfile)) != -1);
|
||||||
|
|
||||||
if (Ondisk)
|
if (Ondisk)
|
||||||
@ -240,7 +240,7 @@ void E_F(long areanr)
|
|||||||
crc = 0xffffffff;
|
crc = 0xffffffff;
|
||||||
crc = upd_crc32((char *)&file, crc, sizeof(file));
|
crc = upd_crc32((char *)&file, crc, sizeof(file));
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", area.Path, file.Name);
|
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||||
if (stat(temp, &statfile) == -1)
|
if (stat(temp, &statfile) == -1)
|
||||||
file.Missing = TRUE;
|
file.Missing = TRUE;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user