Browse code

drop support for direct fd passing (not maintained)

git-svn: trunk@3520

Tomasz Kojm authored on 2008/01/22 17:38:24
Showing 6 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Jan 22 09:16:24 CET 2008 (tk)
2
+---------------------------------
3
+  * clamd, clamdscan: drop support for direct fd passing (not maintained)
4
+
1 5
 Mon Jan 21 19:59:41 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
   * libclamav/entconv.c: fix EOF handling, bug introduced in r3515.
... ...
@@ -374,40 +374,6 @@ int scan(const char *filename, unsigned long int *scanned, const struct cl_engin
374 374
     return ret;
375 375
 }
376 376
 
377
-int scanfd(const int fd, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc)
378
-{
379
-	int ret;
380
-	const char *virname;
381
-	struct stat statbuf;
382
-	char fdstr[32];      
383
-
384
-
385
-    if(fstat(fd, &statbuf) == -1)
386
-	return -1;
387
-
388
-    if(!S_ISREG(statbuf.st_mode))
389
-	return -1;
390
-
391
-    snprintf(fdstr, sizeof(fdstr), "fd[%d]", fd);
392
-
393
-    ret = cl_scandesc(fd, &virname, scanned, engine, limits, options);
394
-
395
-    if(ret == CL_VIRUS) {
396
-	mdprintf(odesc, "%s: %s FOUND\n", fdstr, virname);
397
-	logg("%s: %s FOUND\n", fdstr, virname);
398
-	virusaction(fdstr, virname, copt);
399
-    } else if(ret != CL_CLEAN) {
400
-	mdprintf(odesc, "%s: %s ERROR\n", fdstr, cl_strerror(ret));
401
-	logg("%s: %s ERROR\n", fdstr, cl_strerror(ret));
402
-    } else {
403
-	mdprintf(odesc, "%s: OK\n", fdstr);
404
-        if(logok)
405
-	    logg("%s: OK\n", fdstr); 
406
-    }
407
-
408
-    return ret;
409
-}
410
-
411 377
 int scanstream(int odesc, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt)
412 378
 {
413 379
 	int ret, sockfd, acceptd;
... ...
@@ -28,8 +28,6 @@
28 28
 
29 29
 int scan(const char *filename, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, unsigned int type);
30 30
 
31
-int scanfd(const int fd, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc);
32
-
33 31
 int scanstream(int odesc, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt);
34 32
 
35 33
 #endif
... ...
@@ -143,12 +143,6 @@ int command(int desc, const struct cl_engine *engine, const struct cl_limits *li
143 143
     } else if(!strncmp(buff, CMD11, strlen(CMD11))) { /* SHUTDOWN */
144 144
 	return COMMAND_SHUTDOWN;
145 145
 
146
-    } else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* FD */
147
-	    int fd = atoi(buff + strlen(CMD12) + 1);
148
-
149
-	scanfd(fd, NULL, engine, limits, options, copt, desc);
150
-	close(fd); /* FIXME: should we close it here? */
151
-
152 146
     } else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* MULTISCAN */
153 147
 	if(scan(buff + strlen(CMD13) + 1, NULL, engine, limits, options, copt, desc, TYPE_MULTISCAN) == -2)
154 148
 	    if(cfgopt(copt, "ExitOnOOM")->enabled)
... ...
@@ -35,7 +35,7 @@
35 35
 #define CMD9 "SESSION"
36 36
 #define CMD10 "END"
37 37
 #define CMD11 "SHUTDOWN"
38
-#define CMD12 "FD"
38
+/* #define CMD12 "FD" */
39 39
 #define CMD13 "MULTISCAN"
40 40
 
41 41
 #include "libclamav/clamav.h"
... ...
@@ -52,8 +52,6 @@
52 52
 # define SOCKET_INET	AF_INET
53 53
 #endif
54 54
 
55
-/* #define ENABLE_FD_PASSING	    FIXME: Doesn't work yet */
56
-
57 55
 void move_infected(const char *filename, const struct optstruct *opt);
58 56
 int notremoved = 0, notmoved = 0;
59 57
 
... ...
@@ -141,50 +139,6 @@ static int dsfile(int sockd, const char *scantype, const char *filename, const s
141 141
     return ret;
142 142
 }
143 143
 
144
-#if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
145
-
146
-/* Submitted by Richard Lyons <frob-clamav*webcentral.com.au> */
147
-static int dsfd(int sockfd, int fd, const struct optstruct *opt)
148
-{
149
-	struct iovec iov[1];
150
-	struct msghdr msg;
151
-#ifdef HAVE_CONTROL_IN_MSGHDR
152
-#ifndef CMSG_SPACE
153
-#define CMSG_SPACE(len)	    (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
154
-#endif
155
-#ifndef CMSG_LEN
156
-#define CMSG_LEN(len)	    (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
157
-#endif
158
-	struct cmsghdr *cmsg;
159
-	char tmp[CMSG_SPACE(sizeof(fd))];
160
-#endif
161
-
162
-    iov[0].iov_base = "";
163
-    iov[0].iov_len = 1;
164
-    memset(&msg, 0, sizeof(msg));
165
-    msg.msg_iov = iov;
166
-    msg.msg_iovlen = 1;
167
-#ifdef HAVE_CONTROL_IN_MSGHDR
168
-    msg.msg_control = tmp;
169
-    msg.msg_controllen = sizeof(tmp);
170
-    cmsg = CMSG_FIRSTHDR(&msg);
171
-    cmsg->cmsg_level = SOL_SOCKET;
172
-    cmsg->cmsg_type = SCM_RIGHTS;
173
-    cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
174
-    *(int *)CMSG_DATA(cmsg) = fd;
175
-#endif
176
-#ifdef HAVE_ACCRIGHTS_IN_MSGHDR
177
-    msg.msg_accrights = (caddr_t)&fd;
178
-    msg.msg_accrightslen = sizeof(fd);
179
-#endif
180
-    if (sendmsg(sockfd, &msg, 0) != iov[0].iov_len) {
181
-	logg("^Can't write to the socket.\n");
182
-	return -1;
183
-    }
184
-    return dsresult(sockfd, opt);
185
-}
186
-#endif
187
-
188 144
 static int dsstream(int sockd, const struct optstruct *opt)
189 145
 {
190 146
 	int wsockd, loopw = 60, bread, port, infected = 0;
... ...
@@ -444,18 +398,6 @@ int client(const struct optstruct *opt, int *infected)
444 444
 
445 445
 	close(sockd);
446 446
 
447
-#if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN)
448
-    } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
449
-	if((sockd = dconnect(opt)) < 0)
450
-	    return 2;
451
-
452
-	if((ret = dsfd(sockd, 0, opt)) >= 0)
453
-	    *infected += ret;
454
-	else
455
-	    errors++;
456
-
457
-	close(sockd);
458
-#else
459 447
     } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
460 448
 	if((sockd = dconnect(opt)) < 0)
461 449
 	    return 2;
... ...
@@ -466,7 +408,6 @@ int client(const struct optstruct *opt, int *infected)
466 466
 	    errors++;
467 467
 
468 468
 	close(sockd);
469
-#endif
470 469
 
471 470
     } else {
472 471
 	int x;