From 75ccac9f29e8f9b4d75a04042c1f886d7bf21cf4 Mon Sep 17 00:00:00 2001 From: Tomasz Kojm Date: Mon, 20 Dec 2004 01:37:36 +0000 Subject: [PATCH] improved OS/2 support git-svn: trunk@1205 --- clamav-devel/AUTHORS | 1 + clamav-devel/ChangeLog | 4 ++++ clamav-devel/clamav-config.h.in | 3 +++ clamav-devel/clamd/clamd.c | 9 +++++--- clamav-devel/clamd/server-th.c | 5 ++++- clamav-devel/clamdscan/client.c | 5 ++++- clamav-devel/clamscan/manager.c | 13 ++++++++---- clamav-devel/configure | 26 ++++++++++++++++++++++++ clamav-devel/configure.in | 14 +++++++++++++ clamav-devel/freshclam/manager.c | 2 +- clamav-devel/libclamav/clamav.h | 1 + clamav-devel/libclamav/ole2_extract.c | 2 +- clamav-devel/libclamav/readdb.c | 25 +++++++++++++++++++++++ clamav-devel/libclamav/zziplib/zziplib.h | 8 ++++++++ clamav-devel/sigtool/Makefile.in | 4 ++-- 15 files changed, 109 insertions(+), 13 deletions(-) diff --git a/clamav-devel/AUTHORS b/clamav-devel/AUTHORS index 110e51327..3573952e5 100644 --- a/clamav-devel/AUTHORS +++ b/clamav-devel/AUTHORS @@ -87,6 +87,7 @@ Tom G. Christensen Eugene Crosser Damien Curtain Michael Dankov +Yuri Dario David Maxim Dounin Alejandro Dubrovsky diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index 7b37af245..38e73e015 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Mon Dec 20 02:32:30 CET 2004 (tk) +--------------------------------- + * improved OS/2 support (thanks to Yuri Dario ) + Sun Dec 19 17:01:56 GMT 2004 (njh) ---------------------------------- * clamav-milter: Correctly warn that --max_childen must be given in SESSION diff --git a/clamav-devel/clamav-config.h.in b/clamav-devel/clamav-config.h.in index 7fac37b5b..93d837d0b 100644 --- a/clamav-devel/clamav-config.h.in +++ b/clamav-devel/clamav-config.h.in @@ -57,6 +57,9 @@ /* target is linux */ #undef C_LINUX +/* os is OS/2 */ +#undef C_OS2 + /* os is solaris */ #undef C_SOLARIS diff --git a/clamav-devel/clamd/clamd.c b/clamav-devel/clamd/clamd.c index f14c01ba5..97979766b 100644 --- a/clamav-devel/clamd/clamd.c +++ b/clamav-devel/clamd/clamd.c @@ -136,7 +136,7 @@ void clamd(struct optstruct *opt) if((cpt = cfgopt(copt, "LogFile"))) { logg_file = cpt->strarg; - if(logg_file[0] != '/') { + if(strlen(logg_file) < 2 || (logg_file[0] != '/' && logg_file[0] != '\\' && logg_file[1] != ':')) { fprintf(stderr, "ERROR: LogFile requires full path.\n"); exit(1); } @@ -274,12 +274,10 @@ void clamd(struct optstruct *opt) exit(1); } - /* fork into background */ if(!cfgopt(copt, "Foreground")) daemonize(); - if(tcpsock) ret = tcpserver(opt, copt, root); else @@ -312,6 +310,10 @@ void daemonize(void) int i; +#ifdef C_OS2 + return; +#else + if((i = open("/dev/null", O_WRONLY)) == -1) { logg("!Cannot open /dev/null. Only use Debug if Foreground is enabled.\n"); for(i = 0; i <= 2; i++) @@ -330,4 +332,5 @@ void daemonize(void) exit(0); setsid(); +#endif } diff --git a/clamav-devel/clamd/server-th.c b/clamav-devel/clamd/server-th.c index 2fd511bd4..fca5fad38 100644 --- a/clamav-devel/clamd/server-th.c +++ b/clamav-devel/clamd/server-th.c @@ -562,12 +562,15 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop shutdown(socketd, 2); logg("*Closing the main socket.\n"); close(socketd); + +#ifndef C_OS2 if((cpt = cfgopt(copt, "LocalSocket"))) { if(unlink(cpt->strarg) == -1) logg("!Can't unlink the socket file %s\n", cpt->strarg); else logg("Socket file removed.\n"); - } + } +#endif if((cpt = cfgopt(copt, "PidFile"))) { if(unlink(cpt->strarg) == -1) diff --git a/clamav-devel/clamdscan/client.c b/clamav-devel/clamdscan/client.c index cb989a913..eba7761b5 100644 --- a/clamav-devel/clamdscan/client.c +++ b/clamav-devel/clamdscan/client.c @@ -312,6 +312,9 @@ int dconnect(const struct optstruct *opt) return -1; } + memset((char *) &server, 0, sizeof(server)); + memset((char *) &server2, 0, sizeof(server2)); + /* Set default address to connect to */ server2.sin_addr.s_addr = inet_addr("127.0.0.1"); @@ -435,7 +438,7 @@ int client(const struct optstruct *opt, int *infected) perror(fullpath); errors++; } else { - if(fullpath[0] != '/') { + if(strlen(fullpath) < 2 || (fullpath[0] != '/' && fullpath[0] != '\\' && fullpath[1] != ':')) { fullpath = abpath(thefilename); free(thefilename); diff --git a/clamav-devel/clamscan/manager.c b/clamav-devel/clamscan/manager.c index 9bf467b88..b6a11f71a 100644 --- a/clamav-devel/clamscan/manager.c +++ b/clamav-devel/clamscan/manager.c @@ -231,7 +231,7 @@ int scanmanager(const struct optstruct *opt) } else { fmode = (mode_t) fmodeint; - if(compression && (thefilename[0] != '/')) { + if(compression && (strlen(thefilename) < 2 || (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':'))) { /* we need to complete the path */ if(!getcwd(cwd, sizeof(cwd))) { mprintf("@Can't get absolute pathname of current working directory.\n"); @@ -263,7 +263,7 @@ int scanmanager(const struct optstruct *opt) ret = 52; } - if(compression && thefilename[0] != '/') { + if(compression && (strlen(thefilename) < 2 || (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':'))) { free(fullpath); fullpath = NULL; } @@ -291,7 +291,7 @@ int match_regex(const char *filename, const char *pattern) #ifdef HAVE_REGEX_H regex_t reg; int match, flags; -#ifndef C_CYGWIN +#if !defined(C_CYGWIN) && !defined(C_OS2) flags = 0; #else flags = REG_ICASE; /* case insensitive on Windows */ @@ -500,9 +500,10 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass exit(63); /* critical */ } +#ifndef C_OS2 if(user) chown(gendir, user->pw_uid, user->pw_gid); - +#endif /* unpack file - as unprivileged user */ if(cli_strbcasestr(filename, ".zip")) { @@ -722,10 +723,12 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * fixperms(gendir); +#ifndef C_OS2 if(user) { chown(gendir, user->pw_uid, user->pw_gid); chown(tmpfile, user->pw_uid, user->pw_gid); } +#endif if((ret = treewalk(gendir, root, user, opt, limits, options)) == 1) { logg("(Real infected archive: %s)\n", filename); @@ -1045,7 +1048,9 @@ void move_infected(const char *filename, const struct optstruct *opt) } chmod(movefilename, fstat.st_mode); +#ifndef C_OS2 chown(movefilename, fstat.st_uid, fstat.st_gid); +#endif ubuf.actime = fstat.st_atime; ubuf.modtime = fstat.st_mtime; diff --git a/clamav-devel/configure b/clamav-devel/configure index 7d5e92f71..0b94be0d9 100755 --- a/clamav-devel/configure +++ b/clamav-devel/configure @@ -11763,6 +11763,32 @@ _ACEOF use_netinfo="yes" disable_gethostbyname_r="yes" + ;; +os2*) + FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog" + CLAMD_LIBS="$CLAMD_LIBS -lsyslog" + CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog" + if test "$have_pthreads" = "yes"; then + LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread" + CLAMD_LIBS="$CLAMD_LIBS -lpthread" + CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread" + TH_SAFE="-thread-safe" + +cat >>confdefs.h <<\_ACEOF +#define CL_THREAD_SAFE 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define _REENTRANT 1 +_ACEOF + + fi + +cat >>confdefs.h <<\_ACEOF +#define C_OS2 1 +_ACEOF + ;; sco*) ;; diff --git a/clamav-devel/configure.in b/clamav-devel/configure.in index e23b50b05..836152151 100644 --- a/clamav-devel/configure.in +++ b/clamav-devel/configure.in @@ -432,6 +432,20 @@ darwin*) use_netinfo="yes" disable_gethostbyname_r="yes" ;; +os2*) + FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsyslog" + CLAMD_LIBS="$CLAMD_LIBS -lsyslog" + CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsyslog" + if test "$have_pthreads" = "yes"; then + LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lpthread" + CLAMD_LIBS="$CLAMD_LIBS -lpthread" + CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lpthread" + TH_SAFE="-thread-safe" + AC_DEFINE(CL_THREAD_SAFE,1,[thread safe]) + AC_DEFINE(_REENTRANT,1,[thread safe]) + fi + AC_DEFINE(C_OS2,1,[os is OS/2]) + ;; sco*) dnl njh@bandsman.sco.uk: SCO Unix port dnl FRESHCLAM_LIBS="-lsocket" diff --git a/clamav-devel/freshclam/manager.c b/clamav-devel/freshclam/manager.c index 10e467c9c..5a8237e05 100644 --- a/clamav-devel/freshclam/manager.c +++ b/clamav-devel/freshclam/manager.c @@ -571,7 +571,7 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char } } -#ifdef C_CYGWIN +#if defined(C_CYGWIN) || defined(C_OS2) if((fd = open(file, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644)) == -1) { #else if((fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0644)) == -1) { diff --git a/clamav-devel/libclamav/clamav.h b/clamav-devel/libclamav/clamav.h index 534e12163..0a630913f 100644 --- a/clamav-devel/libclamav/clamav.h +++ b/clamav-devel/libclamav/clamav.h @@ -151,6 +151,7 @@ struct cl_stat { char *dir; int no; struct stat *stattab; + char **statdname; }; struct cl_cvd { diff --git a/clamav-devel/libclamav/ole2_extract.c b/clamav-devel/libclamav/ole2_extract.c index 083d2d52c..8eb20834d 100644 --- a/clamav-devel/libclamav/ole2_extract.c +++ b/clamav-devel/libclamav/ole2_extract.c @@ -598,7 +598,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const #ifdef C_DARWIN *newname &= '\177'; #endif -#if defined(MSDOS) || defined(C_CYGWIN) || defined(WIN32) +#if defined(MSDOS) || defined(C_CYGWIN) || defined(WIN32) || defined(C_OS2) if(strchr("/*?<>|\"+=,;: ", *newname)) #else if(*newname == '/') diff --git a/clamav-devel/libclamav/readdb.c b/clamav-devel/libclamav/readdb.c index a758eb684..ce6b49fb2 100644 --- a/clamav-devel/libclamav/readdb.c +++ b/clamav-devel/libclamav/readdb.c @@ -826,6 +826,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat) if(dbstat) { dbstat->no = 0; dbstat->stattab = NULL; + dbstat->statdname = NULL; dbstat->dir = strdup(dirname); } else { cli_errmsg("cl_statdbdir(): Null argument passed.\n"); @@ -860,8 +861,16 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat) dbstat->no++; dbstat->stattab = (struct stat *) realloc(dbstat->stattab, dbstat->no * sizeof(struct stat)); +#if defined(CL_INTERIX) || defined(CL_OS2) + dbstat->statdname = (char **) realloc(dbstat->statdname, dbstat->no * sizeof(char *)); +#endif + fname = cli_calloc(strlen(dirname) + strlen(dent->d_name) + 2, sizeof(char)); sprintf(fname, "%s/%s", dirname, dent->d_name); +#if defined(CL_INTERIX) || defined(CL_OS2) + dbstat->statdname[dbstat->no - 1] = (char *) calloc(strlen(dent->d_name) + 1, sizeof(char)); + strcpy(dbstat->statdname[dbstat->no - 1], dent->d_name); +#endif stat(fname, &dbstat->stattab[dbstat->no - 1]); free(fname); } @@ -925,7 +934,11 @@ int cl_statchkdir(const struct cl_stat *dbstat) found = 0; for(i = 0; i < dbstat->no; i++) +#if defined(CL_INTERIX) || defined(CL_OS2) + if(!strcmp(dbstat->statdname[i], dent->d_name)) { +#else if(dbstat->stattab[i].st_ino == sb.st_ino) { +#endif found = 1; if(dbstat->stattab[i].st_mtime != sb.st_mtime) { closedir(dd); @@ -949,6 +962,18 @@ int cl_statfree(struct cl_stat *dbstat) { if(dbstat) { + +#if defined(CL_INTERIX) || defined(CL_OS2) + int i; + + for(i = 0;i < dbstat->no; i++) { + free(dbstat->statdname[i]); + dbstat->statdname[i] = NULL; + } + free(dbstat->statdname); + dbstat->statdname = NULL; +#endif + free(dbstat->stattab); dbstat->stattab = NULL; dbstat->no = 0; diff --git a/clamav-devel/libclamav/zziplib/zziplib.h b/clamav-devel/libclamav/zziplib/zziplib.h index b0b638bda..25652b170 100644 --- a/clamav-devel/libclamav/zziplib/zziplib.h +++ b/clamav-devel/libclamav/zziplib/zziplib.h @@ -16,6 +16,10 @@ * you need to add an include path to the dir containing (!!) the ./zzip/ dir */ +#if HAVE_CONFIG_H +#include "clamav-config.h" +#endif + #ifndef _ZZIP_ZZIP_H /* zziplib.h */ #define _ZZIP_ZZIP_H @@ -25,6 +29,10 @@ #include /* size_t and friends */ /* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */ +#ifdef CL_OS2 +#include +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/clamav-devel/sigtool/Makefile.in b/clamav-devel/sigtool/Makefile.in index ec72169ec..c0e8934b2 100644 --- a/clamav-devel/sigtool/Makefile.in +++ b/clamav-devel/sigtool/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.8.4 from Makefile.am. +# Makefile.in generated by automake 1.8.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -472,7 +472,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -z "$$unique" && unique=$$empty_fix; \ + test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi