This patch adds the same canonicalization support for Win32 to POSIX paths
that the shared patch provided for clamscan. Interix 5.2 (the Subsytsem for
Unix Applcations or SUA on Window Server 2003 R2) adds recvmsg() but it
desn't work properly. Therefore, I've also added some #ifdef to continue to
redefine readsock() to read() until the defect can be rectified by the
Interix dev team.


diff -ru clamav-devel/clamd/others.c clamav-devel-interix/clamd/others.c
--- clamav-devel/clamd/others.c Mon Apr 10 05:59:51 2006
+++ clamav-devel-interix/clamd/others.c Wed Jun  7 15:17:12 2006
@@ -51,14 +51,14 @@
 #include <sys/uio.h>
 #endif
 
-/* submitted by [EMAIL PROTECTED]: do not use poll(2) on Interix */
+/* submitted by [EMAIL PROTECTED]: do not use poll(3) on Interix */
 #ifdef C_INTERIX
 #undef HAVE_POLL
 #undef HAVE_POLL_H
 #endif
 
-#if HAVE_POLL
-#if HAVE_POLL_H
+#ifdef HAVE_POLL
+#ifdef HAVE_POLL_H
 #include <poll.h>
 #else /* HAVE_POLL_H */
 #undef HAVE_POLL
@@ -302,7 +302,10 @@
  
     return count;
 }
-
+/* [EMAIL PROTECTED]: recvmsg() is new in Interix 5.2 but doesn't
work properly. It
+always returns -1 with errno 41 for some reason. we need to continue to
redefine readsock to read()
+for now. */
+#ifndef __INTERIX
 /* Submitted by Richard Lyons <frob-clamav*webcentral.com.au> */
 
 #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) ||
defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) && !defined(C_OS2) &&
!defined(INCOMPLETE_CMSG)
@@ -365,3 +368,4 @@
     return n;
 }
 #endif
+#endif /*interix*/
\ No newline at end of file
diff -ru clamav-devel/clamd/others.h clamav-devel-interix/clamd/others.h
--- clamav-devel/clamd/others.h Sun Apr  9 15:59:26 2006
+++ clamav-devel-interix/clamd/others.h Wed Jun  7 16:20:36 2006
@@ -22,6 +22,10 @@
 
 #if HAVE_CONFIG_H
 #include "clamav-config.h"
+# ifdef __INTERIX
+#  undef HAVE_POLL_H
+#  undef HAVE_POLL
+# endif
 #endif
 
 #include <stdlib.h>
@@ -33,7 +37,10 @@
 void virusaction(const char *filename, const char *virname, const struct
cfgstruct *copt);
 int writen(int fd, void *buff, unsigned int count);
 
-#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) ||
defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) && !defined(C_OS2) &&
!defined(INCOMPLETE_CMSG)
+/* [EMAIL PROTECTED]: recvmsg() is new in Interix 5.2 but doesn't
work properly. It
+always returns -1 with errno 41 for some reason. we need to continue to
redefine readsock to read()
+for now. */
+#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) ||
defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) && !defined(C_OS2) &&
!defined(INCOMPLETE_CMSG) && !defined(__INTERIX)
 int readsock(int sockfd, char *buf, size_t size);
 #else
 #define        readsock        read
diff -ru clamav-devel/clamd/scanner.c clamav-devel-interix/clamd/scanner.c
--- clamav-devel/clamd/scanner.c        Sun Apr  9 15:59:26 2006
+++ clamav-devel-interix/clamd/scanner.c        Wed Jun  7 16:19:59 2006
@@ -44,6 +44,16 @@
 #include <stddef.h>
 #endif
 
+#ifdef __INTERIX
+# include <interix/interix.h>
+# ifndef TRUE
+#  define TRUE  1
+# endif
+# ifndef FALSE
+#  define FALSE 0
+# endif
+#endif
+
 #include "cfgparser.h"
 #include "others.h"
 #include "scanner.h"
@@ -198,6 +208,34 @@
        struct stat sb;
        int ret = 0, reclev = 0;
        const char *virname;
+
+       #ifdef __INTERIX
+       /* Need these to canonicalize win32-style paths to POSIX paths
passed to the Interix subsystem on NT 5.x+*/
+       int iswinpath = FALSE;
+       char c;
+       char *srch = filename, *winfilename = filename;
+               
+       /* This block is to handle convertint win32-style paths to POSIX
paths
+       on the Interix subsystem on NT 5.x+. */
+       while( (c = *srch++) != '\0' )
+       {
+         if( c == '\\' || c == ':' )
+         {
+                 iswinpath = TRUE;
+                 break;
+         }
+       }
+       if( iswinpath )
+       {
+               char buff[PATH_MAX];
+               if ( winpath2unix( winfilename, 0, buff, sizeof(buff) ) != 0
)
+               {
+                       mdprintf( odesc, "\"%s\": winpath2unix() failed.
ERROR\n", filename );
+                       return -1;
+               }
+               filename = buff;
+       }
+       #endif
 
 
     /* stat file */

Brian A. Reiter
WolfeReiter, LLC : Thoughtful Computing
[http://www.thoughtfulcomputing.com]

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to