clamd-win32 - WIP

This commit is contained in:
aCaB 2010-01-28 23:36:37 +01:00
parent 0380088f32
commit 3b074c7878
22 changed files with 373 additions and 49 deletions

View file

@ -104,7 +104,7 @@ int main(int argc, char **argv)
{
static struct cl_engine *engine = NULL;
const struct optstruct *opt;
#ifndef C_WINDOWS
#ifndef _WIN32
struct passwd *user = NULL;
struct sigaction sa;
#endif

View file

@ -25,13 +25,11 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifndef C_WINDOWS
#ifndef _WIN32
#include <sys/socket.h>
#endif
#include <sys/stat.h>
#ifndef C_WINDOWS
#include <sys/un.h>
#endif
#include <sys/stat.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@ -40,13 +38,13 @@
#include "libclamav/clamav.h"
#include "shared/optparser.h"
#include "shared/output.h"
#include "others.h"
#include "server.h"
#include "output.h"
#include "localserver.h"
#ifdef C_WINDOWS
#ifdef _WIN32
int localserver(const struct optstruct *opts)
{
logg("!Localserver is not supported on this platform");
@ -121,4 +119,4 @@ int localserver(const struct optstruct *opts)
return sockfd;
}
#endif /* C_WINDOWS */
#endif

View file

@ -69,11 +69,11 @@
#include <limits.h>
#include "shared/optparser.h"
#include "shared/output.h"
#include "shared/misc.h"
#include "libclamav/others.h"
#include "session.h"
#include "others.h"
#include "misc.h"
#ifdef _WIN32
void virusaction(const char *filename, const char *virname, const struct optstruct *opts)
@ -551,6 +551,7 @@ int fds_poll_recv(struct fd_data *data, int timeout, int check_signals)
}
} while (retval == -1 && !check_signals && errno == EINTR);
#else
{
fd_set rfds;
struct timeval tv;
int maxfd = -1;
@ -628,6 +629,7 @@ int fds_poll_recv(struct fd_data *data, int timeout, int check_signals)
continue;
}
} while (retval == -1 && !check_signals && errno == EINTR);
}
#endif
if (retval == -1 && errno != EINTR) {

View file

@ -390,7 +390,8 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_engine *en
return -1;
}
snprintf(peer_addr, sizeof(peer_addr), "%s", inet_ntoa(peer.sin_addr));
*peer_addr = '\0';
inet_ntop(peer.sin_family, &peer, peer_addr, sizeof(peer_addr));
logg("*Accepted connection from %s on port %u, fd %d\n", peer_addr, port, acceptd);
if(cli_gentempfd(optget(opts, "TemporaryDirectory")->strarg, &tmpname, &tmpd)) {

View file

@ -40,11 +40,11 @@
#include "shared/optparser.h"
#include "shared/output.h"
#include "shared/misc.h"
#include "others.h"
#include "server.h"
#include "tcpserver.h"
#include "misc.h"
int tcpserver(const struct optstruct *opts)
{

View file

@ -46,6 +46,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LLVMjit", "LLVMjit.vcproj",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LLVMcodegen", "LLVMcodegen.vcproj", "{7472FD2F-DDE7-44B1-91FB-65C0BE81932B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clamd", "clamd.vcproj", "{B3CA73CF-E71E-42F3-95DE-43797A86C798}"
ProjectSection(ProjectDependencies) = postProject
{3AD5B16C-340A-40AC-96AD-6017B941A316} = {3AD5B16C-340A-40AC-96AD-6017B941A316}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -100,6 +105,8 @@ Global
{7472FD2F-DDE7-44B1-91FB-65C0BE81932B}.Debug|Win32.Build.0 = Debug|Win32
{7472FD2F-DDE7-44B1-91FB-65C0BE81932B}.Release|Win32.ActiveCfg = Release|Win32
{7472FD2F-DDE7-44B1-91FB-65C0BE81932B}.Release|Win32.Build.0 = Release|Win32
{B3CA73CF-E71E-42F3-95DE-43797A86C798}.Debug|Win32.ActiveCfg = Debug|Win32
{B3CA73CF-E71E-42F3-95DE-43797A86C798}.Release|Win32.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -269,10 +269,10 @@
#define HAVE_OPENDIR 1
/* Define to 1 if you have the `poll' function. */
#define HAVE_POLL 1
/* #undef HAVE_POLL */
/* Define to 1 if you have the <poll.h> header file. */
#define HAVE_POLL_H 1
/* #undef HAVE_POLL_H */
/* "pragma pack" */
#define HAVE_PRAGMA_PACK 1
@ -493,7 +493,7 @@
/* #undef USE_SYSLOG */
/* Version number of package */
#define VERSION "devel-r5076-703-g0222ee6"
#define VERSION "devel-r5076-706-g0380088"
/* Version suffix for package */
#define VERSION_SUFFIX ""

View file

@ -184,10 +184,6 @@
RelativePath="..\clambc\bcrun.c"
>
</File>
<File
RelativePath="..\shared\getopt.c"
>
</File>
<File
RelativePath="..\shared\misc.c"
>

View file

@ -6,7 +6,7 @@
ProjectType="Visual C++"
RootNamespace="clamconf"
TargetFrameworkVersion="196613"
Version="9.00"
Version="9,00"
>
<Platforms>
<Platform
@ -187,10 +187,6 @@
<Filter
Name="shared"
>
<File
RelativePath="..\shared\getopt.c"
>
</File>
<File
RelativePath="..\shared\misc.c"
>

251
win32/clamd.vcproj Normal file
View file

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
Keyword="Win32Proj"
Name="clamd"
ProjectGUID="{B3CA73CF-E71E-42F3-95DE-43797A86C798}"
ProjectType="Visual C++"
RootNamespace="clamd"
TargetFrameworkVersion="196613"
Version="9,00"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
CharacterSet="2"
ConfigurationType="1"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
BasicRuntimeChecks="3"
CompileAs="1"
DebugInformationFormat="3"
DisableSpecificWarnings="4996;4244"
MinimalRebuild="true"
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
GenerateDebugInformation="true"
LinkIncremental="1"
Name="VCLinkerTool"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
CharacterSet="2"
ConfigurationType="1"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
CompileAs="1"
DebugInformationFormat="3"
DisableSpecificWarnings="4996;4244"
EnableFunctionLevelLinking="true"
EnableIntrinsicFunctions="true"
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
EnableCOMDATFolding="2"
GenerateDebugInformation="true"
LinkIncremental="1"
Name="VCLinkerTool"
OptimizeReferences="2"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
Name="Source Files"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\clamd\clamd.c"
>
</File>
<File
RelativePath="..\clamd\localserver.c"
>
</File>
<File
RelativePath="..\clamd\others.c"
>
</File>
<File
RelativePath="..\clamd\scanner.c"
>
</File>
<File
RelativePath="..\clamd\server-th.c"
>
</File>
<File
RelativePath="..\clamd\session.c"
>
</File>
<File
RelativePath="..\clamd\tcpserver.c"
>
</File>
<File
RelativePath="..\clamd\thrmgr.c"
>
</File>
<Filter
Name="shared"
>
<File
RelativePath="..\shared\misc.c"
>
</File>
<File
RelativePath="..\shared\output.c"
>
</File>
</Filter>
<Filter
Name="compat"
>
<File
RelativePath=".\compat\libgen.c"
>
</File>
<File
RelativePath=".\compat\setargv.c"
>
</File>
</Filter>
</Filter>
<Filter
Filter="h;hpp;hxx;hm;inl;inc;xsd"
Name="Header Files"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
Name="Resource Files"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -208,10 +208,6 @@
RelativePath="..\shared\actions.c"
>
</File>
<File
RelativePath="..\shared\getopt.c"
>
</File>
<File
RelativePath="..\shared\misc.c"
>

View file

@ -324,3 +324,27 @@ int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, s
}
return ret;
}
int w32_accept(int sockfd, const struct sockaddr *addr, socklen_t *addrlen) {
if(accept((SOCKET)sockfd, addr, addrlen)) {
wsock2errno();
return -1;
}
return 0;
}
int w32_listen(int sockfd, int backlog) {
if(listen((SOCKET)sockfd, backlog)) {
wsock2errno();
return -1;
}
return 0;
}
int w32_shutdown(int sockfd, int how) {
if(shutdown((SOCKET)sockfd, how)) {
wsock2errno();
return -1;
}
return 0;
}

View file

@ -39,5 +39,8 @@ void w32_freeaddrinfo(struct addrinfo *res);
const char *w32_inet_ntop(int af, const void *src, char *dst, socklen_t size);
struct hostent *w32_gethostbyname(const char *name);
int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
int w32_accept(int sockfd, const struct sockaddr *addr, socklen_t *addrlen);
int w32_listen(int sockfd, int backlog);
int w32_shutdown(int sockfd, int how);
#endif

View file

@ -43,7 +43,7 @@ for pippo in `cat "$INFILE"`; do
value=$((value+1000))
[ $value -gt $maxerr ] && maxerr=$value
descr=`echo $pippo | cut -d'|' -f3`
git grep $symbol > /dev/null
git grep $symbol | egrep -v '(referrno|w32_errno_defs)' > /dev/null
used=$?
[ $used -ne 0 ] && echo "#ifdef __ERRNO_INCLUDE_UNUSED" >> "$OUTFILE"
echo -e "#ifndef $symbol\n#define $symbol $value\n#endif\n{ $symbol, \"$descr\" }," >> "$OUTFILE"

View file

@ -46,7 +46,7 @@ int glob_add(const char *path, int *argc, char ***argv);
int _setargv() {
char *cur = GetCommandLineA(), *begparm = NULL, *endparm = NULL;
char **argv = NULL, c;
int argc = 0, i, in_sq = 0, in_dq = 0, need_glob = 0, allarglen = 0;
int argc = 0, in_sq = 0, in_dq = 0, need_glob = 0, allarglen = 0;
int *g_argc = __p___argc();
char ***g_argv = __p___argv();

View file

@ -18,11 +18,20 @@
* MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <string.h>
#include "w32_errno.h"
char *w32_strerror(int errnum) {
int i;
for(i=0; i<sizeof(w32_errnos) / sizeof(w32_errnos[0]); i++) {
if(w32_errnos[i].err == errnum)
return w32_errnos[i].strerr;
}
return "Unknown error";
}
int w32_strerror_r(int errnum, char *buf, size_t buflen) {
strncpy(buf, w32_strerror(errnum), buflen);
if(buflen) buf[buflen-1] = '\0';
return 0;
}

View file

@ -24,4 +24,7 @@
#include <errno.h>
#include "w32_errno_defs.c"
char *w32_strerror(int errnum);
int w32_strerror_r(int errnum, char *buf, size_t buflen);
#endif

View file

@ -1,4 +1,4 @@
/* Automatically generated on Wed Oct 14 14:49:39 GMT 2009 */
/* Automatically generated on Thu Jan 28 23:51:23 CET 2010 */
#include <errno.h>
@ -336,12 +336,10 @@ static const struct errno_struct {
#endif
{ ESRMNT, "Srmount error" },
#endif /* __ERRNO_INCLUDE_UNUSED */
#ifdef __ERRNO_INCLUDE_UNUSED
#ifndef ECOMM
#define ECOMM 1070
#endif
{ ECOMM, "Communication error on send" },
#endif /* __ERRNO_INCLUDE_UNUSED */
#ifndef EPROTO
#define EPROTO 1071
#endif

View file

@ -214,10 +214,6 @@
RelativePath="..\shared\cdiff.c"
>
</File>
<File
RelativePath="..\shared\getopt.c"
>
</File>
<File
RelativePath="..\shared\misc.c"
>

View file

@ -7,6 +7,10 @@ EXPORTS cl_engine_set_num
EXPORTS cl_engine_set_str
EXPORTS cl_engine_free
EXPORTS cl_engine_new
EXPORTS cl_engine_settings_copy
EXPORTS cl_engine_settings_free
EXPORTS cl_engine_settings_apply
EXPORTS cl_engine_get_num
EXPORTS cl_strerror
EXPORTS cl_init
EXPORTS cl_retdbdir
@ -18,9 +22,14 @@ EXPORTS cl_retflevel
EXPORTS cl_cvdparse
EXPORTS cl_cvdverify
EXPORTS cl_retver
EXPORTS cl_engine_addref
EXPORTS cl_statinidir
EXPORTS cl_statchkdir
EXPORTS cl_statfree
; cli_stuff - should be mangled or exported by ordinal only
EXPORTS cli_gentemp
EXPORTS cli_gentempfd
EXPORTS cli_gettmpdir
EXPORTS cli_regcomp
EXPORTS cli_regexec
@ -33,6 +42,11 @@ EXPORTS cli_cvdunpack
EXPORTS cli_chomp
EXPORTS cli_strtokenize
EXPORTS cli_versig2
EXPORTS cli_strerror
EXPORTS cli_rndnum
EXPORTS cli_unlink
EXPORTS cli_writen
EXPORTS cli_ftw
EXPORTS have_rar
EXPORTS have_clamjit
@ -88,16 +102,37 @@ EXPORTS CONFDIR_MILTER DATA
; winsock - bridging for now
EXPORTS htonl
EXPORTS htons
EXPORTS ntohl
EXPORTS ntohs
EXPORTS gettimeofday
EXPORTS pthread_mutex_lock
EXPORTS pthread_mutex_unlock
EXPORTS pthread_mutex_destroy
EXPORTS pthread_once
EXPORTS pthread_getspecific
EXPORTS pthread_setspecific
EXPORTS pthread_create
EXPORTS pthread_cond_timedwait
EXPORTS pthread_cond_init
EXPORTS pthread_cond_broadcast
EXPORTS pthread_cond_signal
EXPORTS pthread_cond_destroy
EXPORTS pthread_join
EXPORTS pthread_key_create
EXPORTS pthread_cond_wait
EXPORTS pthread_attr_init
EXPORTS pthread_attr_setdetachstate
EXPORTS pthread_attr_destroy
EXPORTS pthread_mutex_init
EXPORTS w32_socket
EXPORTS w32_getsockopt
EXPORTS w32_setsockopt
EXPORTS w32_bind
EXPORTS w32_listen
EXPORTS w32_accept
EXPORTS w32_connect
EXPORTS w32_shutdown
EXPORTS w32_send
EXPORTS w32_recv
EXPORTS w32_closesocket
@ -107,5 +142,6 @@ EXPORTS w32_freeaddrinfo
EXPORTS w32_inet_ntop
EXPORTS w32_gethostbyname
EXPORTS w32_select
EXPORTS w32_stat
EXPORTS w32_strerror
EXPORTS w32_strerror_r

View file

@ -33,7 +33,10 @@ char *strptime(const char *s, const char *format, struct tm *tm);
#define getsockopt w32_getsockopt
#define setsockopt w32_setsockopt
#define bind w32_bind
#define listen w32_listen
#define accept w32_accept
#define connect w32_connect
#define shutdown w32_shutdown
#define send w32_send
#define recv w32_recv
#define closesocket w32_closesocket
@ -43,6 +46,8 @@ char *strptime(const char *s, const char *format, struct tm *tm);
#define inet_ntop w32_inet_ntop
#define gethostbyname w32_gethostbyname
#define select w32_select
#define strerror w32_strerror
#define strerror_r w32_strerror_r
#define ftruncate _chsize
#define getpid GetCurrentProcessId

View file

@ -104,8 +104,8 @@ my %CONF = (
'HAVE_MMAP' => -1,
'HAVE_NDIR_H' => -1,
'HAVE_OPENDIR' => '1',
'HAVE_POLL' => '1',
'HAVE_POLL_H' => '1',
'HAVE_POLL' => -1,
'HAVE_POLL_H' => -1,
'HAVE_PRAGMA_PACK' => '1',
'HAVE_PRAGMA_PACK_HPPA' => -1,
'HAVE_PRELOADED_SYMBOLS' => -1,
@ -215,16 +215,19 @@ my @PROJECTS = (
{makefile => 'libclamav/c++', sections => ['libclamavcxx'], output => 'win32/libclamavcxx.vcproj'},
# CLAMSCAN #
{makefile => 'clamscan', sections => ['clamscan'], output => 'win32/clamscan.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'},
{makefile => 'clamscan', sections => ['clamscan'], output => 'win32/clamscan.vcproj', makefile_only => '(optparser\\.c|getopt\\.c)$', vcproj_only => 'compat\\\\'},
# CLAMD #
{makefile => 'clamd', sections => ['clamd'], output => 'win32/clamd.vcproj', makefile_only => '(optparser\\.c|getopt\\.c|(daz|clam)uko.*)$', vcproj_only => 'compat\\\\'},
# FRESHCLAM #
{makefile => 'freshclam', sections => ['freshclam'], output => 'win32/freshclam.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'},
{makefile => 'freshclam', sections => ['freshclam'], output => 'win32/freshclam.vcproj', makefile_only => '(optparser\\.c|getopt\\.c)$', vcproj_only => 'compat\\\\'},
# CLAMCONF #
{makefile => 'clamconf', sections => ['clamconf'], output => 'win32/clamconf.vcproj', makefile_only => 'optparser\\.c$'},
{makefile => 'clamconf', sections => ['clamconf'], output => 'win32/clamconf.vcproj', makefile_only => '(optparser\\.c$|getopt\\.c)$'},
# CLAMBC #
{makefile => 'clambc', sections => ['clambc'], output => 'win32/clambc.vcproj', makefile_only => 'optparser\\.c$'},
{makefile => 'clambc', sections => ['clambc'], output => 'win32/clambc.vcproj', makefile_only => '(optparser\\.c|getopt\\.c)$'},
# LLVMsystem #
{makefile => 'libclamav/c++', sections => ['libllvmsystem'], output => 'win32/LLVMsystem.vcproj'},
@ -232,7 +235,7 @@ my @PROJECTS = (
# LLVMcodgen #
{makefile => 'libclamav/c++', sections => ['libllvmcodegen'], output => 'win32/LLVMcodegen.vcproj'},
# LLVMcodgen #
# LLVMx86codgen #
{makefile => 'libclamav/c++', sections => ['libllvmx86codegen'], output => 'win32/LLVMx86codegen.vcproj'},
# LLVMjit #