Browse code

improve OS/2 support

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1254 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2005/01/19 08:51:53
Showing 10 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Jan 19 00:48:48 CET 2005 (tk)
2
+---------------------------------
3
+  * improve OS/2 support (patch by Yuri Dario <mc6530*mclink.it>)
4
+
1 5
 Wed Jan 19 00:17:25 CET 2005 (tk)
2 6
 ---------------------------------
3 7
   * zziplib/zzip-zip.c: fix possible small memory leak (thanks to Trog)
... ...
@@ -28,7 +32,7 @@ Wed Jan 12 08:58:29 GMT 2005 (njh)
28 28
 ----------------------------------
29 29
   * clamav-milter:	Fixed DNS resolution error messages which could print
30 30
 		the incorrect hostname that is not being resolved. Patch from
31
-		Yar Tikhiy <yar@comp.chem.msu.su>
31
+		Yar Tikhiy <yar*comp.chem.msu.su>
32 32
 
33 33
 Tue Jan 11 20:24:36 CET 2005 (tk)
34 34
 ---------------------------------
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -197,7 +197,8 @@ void clamd(struct optstruct *opt)
197 197
 	exit(1);
198 198
     }
199 199
 
200
-    /* drop priviledges */
200
+    /* drop privileges */
201
+#ifndef C_OS2
201 202
     if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))) {
202 203
 	if((user = getpwnam(cpt->strarg)) == NULL) {
203 204
 	    fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg);
... ...
@@ -239,6 +240,7 @@ void clamd(struct optstruct *opt)
239 239
 
240 240
 	logg("Running as user %s (UID %d, GID %d)\n", cpt->strarg, user->pw_uid, user->pw_gid);
241 241
     }
242
+#endif
242 243
 
243 244
     /* set the temporary dir */
244 245
     if((cpt = cfgopt(copt, "TemporaryDirectory")))
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -228,7 +228,7 @@ int writen(int fd, void *buff, unsigned int count)
228 228
 
229 229
 /* Submitted by Richard Lyons <frob-clamav*webcentral.com.au> */
230 230
 
231
-#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
231
+#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) && !defined(C_OS2)
232 232
 
233 233
 int readsock(int sockfd, char *buf, size_t size)
234 234
 {
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -31,7 +31,7 @@ int is_fd_connected(int fd);
31 31
 void virusaction(const char *virname, const struct cfgstruct *copt);
32 32
 int writen(int fd, void *buff, unsigned int count);
33 33
 
34
-#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
34
+#if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) && !defined(C_OS2)
35 35
 int readsock(int sockfd, char *buf, size_t size);
36 36
 #else
37 37
 #define	readsock	read
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -66,7 +66,11 @@ int dsresult(int sockd, const struct optstruct *opt)
66 66
 	FILE *fd;
67 67
 
68 68
 
69
+#ifndef C_OS2
69 70
     if((fd = fdopen(dup(sockd), "r")) == NULL) {
71
+#else /* FIXME: accoriding to YD OS/2 does not support dup() for sockets */
72
+    if((fd = fdopen(sockd, "r")) == NULL) {
73
+#endif
70 74
 	mprintf("@Can't open descriptor for reading.\n");
71 75
 	return -1;
72 76
     }
... ...
@@ -102,7 +106,9 @@ int dsresult(int sockd, const struct optstruct *opt)
102 102
 	}
103 103
     }
104 104
 
105
+#ifndef C_OS2 /* Small memory leak under OS/2 (see above) */
105 106
     fclose(fd);
107
+#endif
106 108
 
107 109
     return infected ? infected : (waserror ? -1 : 0);
108 110
 }
... ...
@@ -73,7 +73,7 @@ int scanmanager(const struct optstruct *opt)
73 73
 
74 74
 
75 75
 /* njh@bandsman.co.uk: BeOS */
76
-#if !defined(C_CYGWIN) && !defined(C_BEOS)
76
+#if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS)
77 77
     if(!geteuid()) {
78 78
 	if((user = getpwnam(UNPUSER)) == NULL) {
79 79
 	    mprintf("@Can't get information about user "UNPUSER".\n");
... ...
@@ -1,6 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
3
- *			     Damien Curtain <damien@pagefault.org>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
4 3
  *
5 4
  *  This program is free software; you can redistribute it and/or modify
6 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -98,7 +97,7 @@ int freshclam(struct optstruct *opt)
98 98
 	struct cfgstruct *copt, *cpt;
99 99
 	struct sigaction sigact;
100 100
 	struct sigaction oldact;
101
-#ifndef C_CYGWIN
101
+#if !defined(C_CYGWIN)  && !defined(C_OS2)
102 102
 	char *unpuser;
103 103
 	struct passwd *user;
104 104
 #endif
... ...
@@ -139,7 +138,7 @@ int freshclam(struct optstruct *opt)
139 139
 #endif
140 140
     }
141 141
 
142
-#ifndef C_CYGWIN
142
+#if !defined(C_CYGWIN)  && !defined(C_OS2)
143 143
     /* freshclam shouldn't work with root privileges */
144 144
     if(optc(opt, 'u')) {
145 145
 	unpuser = getargc(opt, 'u');
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -861,13 +861,13 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat)
861 861
 
862 862
 		dbstat->no++;
863 863
 		dbstat->stattab = (struct stat *) realloc(dbstat->stattab, dbstat->no * sizeof(struct stat));
864
-#if defined(CL_INTERIX) || defined(CL_OS2)
864
+#if defined(C_INTERIX) || defined(C_OS2)
865 865
 		dbstat->statdname = (char **) realloc(dbstat->statdname, dbstat->no * sizeof(char *));
866 866
 #endif
867 867
 
868 868
                 fname = cli_calloc(strlen(dirname) + strlen(dent->d_name) + 2, sizeof(char));
869 869
 		sprintf(fname, "%s/%s", dirname, dent->d_name);
870
-#if defined(CL_INTERIX) || defined(CL_OS2)
870
+#if defined(C_INTERIX) || defined(C_OS2)
871 871
 		dbstat->statdname[dbstat->no - 1] = (char *) calloc(strlen(dent->d_name) + 1, sizeof(char));
872 872
 		strcpy(dbstat->statdname[dbstat->no - 1], dent->d_name);
873 873
 #endif
... ...
@@ -934,7 +934,7 @@ int cl_statchkdir(const struct cl_stat *dbstat)
934 934
 
935 935
 		found = 0;
936 936
 		for(i = 0; i < dbstat->no; i++)
937
-#if defined(CL_INTERIX) || defined(CL_OS2)
937
+#if defined(C_INTERIX) || defined(C_OS2)
938 938
 		    if(!strcmp(dbstat->statdname[i], dent->d_name)) {
939 939
 #else
940 940
 		    if(dbstat->stattab[i].st_ino == sb.st_ino) {
... ...
@@ -963,7 +963,7 @@ int cl_statfree(struct cl_stat *dbstat)
963 963
 
964 964
     if(dbstat) {
965 965
 
966
-#if defined(CL_INTERIX) || defined(CL_OS2)
966
+#if defined(C_INTERIX) || defined(C_OS2)
967 967
 	    int i;
968 968
 
969 969
 	for(i = 0;i < dbstat->no; i++) {
... ...
@@ -29,7 +29,7 @@
29 29
 #include <stddef.h> /* size_t and friends */
30 30
 /* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */
31 31
 
32
-#ifdef CL_OS2
32
+#ifdef C_OS2
33 33
 #include <types.h>
34 34
 #endif
35 35