improved OS/2 support

git-svn: trunk@1205
This commit is contained in:
Tomasz Kojm 2004-12-20 01:37:36 +00:00
parent 4ab382c3ad
commit 75ccac9f29
15 changed files with 109 additions and 13 deletions

View file

@ -87,6 +87,7 @@ Tom G. Christensen <tgc*statsbiblioteket.dk>
Eugene Crosser <crosser*rol.ru>
Damien Curtain <damien*pagefault.org>
Michael Dankov <misha*btrc.ru>
Yuri Dario <mc6530*mclink.it>
David <djgardner*users.sourceforge.net>
Maxim Dounin <mdounin*rambler-co.ru>
Alejandro Dubrovsky <s328940*student.uq.edu.au>

View file

@ -1,3 +1,7 @@
Mon Dec 20 02:32:30 CET 2004 (tk)
---------------------------------
* improved OS/2 support (thanks to Yuri Dario <mc6530*mclink.it>)
Sun Dec 19 17:01:56 GMT 2004 (njh)
----------------------------------
* clamav-milter: Correctly warn that --max_childen must be given in SESSION

View file

@ -57,6 +57,9 @@
/* target is linux */
#undef C_LINUX
/* os is OS/2 */
#undef C_OS2
/* os is solaris */
#undef C_SOLARIS

View file

@ -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
}

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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*)
;;

View file

@ -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"

View file

@ -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) {

View file

@ -151,6 +151,7 @@ struct cl_stat {
char *dir;
int no;
struct stat *stattab;
char **statdname;
};
struct cl_cvd {

View file

@ -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 == '/')

View file

@ -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;

View file

@ -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 <stddef.h> /* size_t and friends */
/* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */
#ifdef CL_OS2
#include <types.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -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