Browse code

remove some dazuko/clamuko code - to be replaced with fanotify

Tomasz Kojm authored on 2011/11/05 02:32:50
Showing 18 changed files
... ...
@@ -44,18 +44,6 @@ clamd_SOURCES = \
44 44
     scanner.h \
45 45
     others.c \
46 46
     others.h \
47
-    clamuko.c \
48
-    clamuko.h \
49
-    clamukofs.c \
50
-    clamukofs.h \
51
-    dazukoio_compat12.c \
52
-    dazukoio_compat12.h \
53
-    dazukoio.c \
54
-    dazukoio.h \
55
-    dazuko_xp.h \
56
-    dazukoio_xp.h \
57
-    dazukofs.c \
58
-    dazukofs.h \
59 47
     shared.h
60 48
 
61 49
 AM_CFLAGS=@WERR_CFLAGS@
... ...
@@ -83,19 +83,14 @@ am__clamd_SOURCES_DIST = $(top_srcdir)/shared/output.c \
83 83
 	$(top_srcdir)/shared/misc.h clamd.c tcpserver.c tcpserver.h \
84 84
 	localserver.c localserver.h session.c session.h thrmgr.c \
85 85
 	thrmgr.h server-th.c server.h scanner.c scanner.h others.c \
86
-	others.h clamuko.c clamuko.h clamukofs.c clamukofs.h \
87
-	dazukoio_compat12.c dazukoio_compat12.h dazukoio.c dazukoio.h \
88
-	dazuko_xp.h dazukoio_xp.h dazukofs.c dazukofs.h shared.h
86
+	others.h shared.h
89 87
 @BUILD_CLAMD_TRUE@am_clamd_OBJECTS = output.$(OBJEXT) \
90 88
 @BUILD_CLAMD_TRUE@	optparser.$(OBJEXT) getopt.$(OBJEXT) \
91 89
 @BUILD_CLAMD_TRUE@	misc.$(OBJEXT) clamd.$(OBJEXT) \
92 90
 @BUILD_CLAMD_TRUE@	tcpserver.$(OBJEXT) localserver.$(OBJEXT) \
93 91
 @BUILD_CLAMD_TRUE@	session.$(OBJEXT) thrmgr.$(OBJEXT) \
94 92
 @BUILD_CLAMD_TRUE@	server-th.$(OBJEXT) scanner.$(OBJEXT) \
95
-@BUILD_CLAMD_TRUE@	others.$(OBJEXT) clamuko.$(OBJEXT) \
96
-@BUILD_CLAMD_TRUE@	clamukofs.$(OBJEXT) \
97
-@BUILD_CLAMD_TRUE@	dazukoio_compat12.$(OBJEXT) \
98
-@BUILD_CLAMD_TRUE@	dazukoio.$(OBJEXT) dazukofs.$(OBJEXT)
93
+@BUILD_CLAMD_TRUE@	others.$(OBJEXT)
99 94
 clamd_OBJECTS = $(am_clamd_OBJECTS)
100 95
 clamd_LDADD = $(LDADD)
101 96
 AM_V_lt = $(am__v_lt_$(V))
... ...
@@ -321,18 +316,6 @@ top_srcdir = @top_srcdir@
321 321
 @BUILD_CLAMD_TRUE@    scanner.h \
322 322
 @BUILD_CLAMD_TRUE@    others.c \
323 323
 @BUILD_CLAMD_TRUE@    others.h \
324
-@BUILD_CLAMD_TRUE@    clamuko.c \
325
-@BUILD_CLAMD_TRUE@    clamuko.h \
326
-@BUILD_CLAMD_TRUE@    clamukofs.c \
327
-@BUILD_CLAMD_TRUE@    clamukofs.h \
328
-@BUILD_CLAMD_TRUE@    dazukoio_compat12.c \
329
-@BUILD_CLAMD_TRUE@    dazukoio_compat12.h \
330
-@BUILD_CLAMD_TRUE@    dazukoio.c \
331
-@BUILD_CLAMD_TRUE@    dazukoio.h \
332
-@BUILD_CLAMD_TRUE@    dazuko_xp.h \
333
-@BUILD_CLAMD_TRUE@    dazukoio_xp.h \
334
-@BUILD_CLAMD_TRUE@    dazukofs.c \
335
-@BUILD_CLAMD_TRUE@    dazukofs.h \
336 324
 @BUILD_CLAMD_TRUE@    shared.h
337 325
 
338 326
 @BUILD_CLAMD_TRUE@AM_CFLAGS = @WERR_CFLAGS@
... ...
@@ -446,11 +429,6 @@ distclean-compile:
446 446
 	-rm -f *.tab.c
447 447
 
448 448
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamd.Po@am__quote@
449
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamuko.Po@am__quote@
450
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamukofs.Po@am__quote@
451
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dazukofs.Po@am__quote@
452
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dazukoio.Po@am__quote@
453
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dazukoio_compat12.Po@am__quote@
454 449
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
455 450
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localserver.Po@am__quote@
456 451
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
457 452
deleted file mode 100644
... ...
@@ -1,234 +0,0 @@
1
-/*
2
- *  Copyright (C) 2007-2009 Sourcefire, Inc.
3
- *
4
- *  Authors: Tomasz Kojm
5
- *
6
- *  This program is free software; you can redistribute it and/or modify
7
- *  it under the terms of the GNU General Public License version 2 as
8
- *  published by the Free Software Foundation.
9
- *
10
- *  This program is distributed in the hope that it will be useful,
11
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- *  GNU General Public License for more details.
14
- *
15
- *  You should have received a copy of the GNU General Public License
16
- *  along with this program; if not, write to the Free Software
17
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
- *  MA 02110-1301, USA.
19
- */
20
-
21
-#if HAVE_CONFIG_H
22
-#include "clamav-config.h"
23
-#endif
24
-
25
-#ifdef CLAMUKO
26
-
27
-#include <stdio.h>
28
-#include <unistd.h>
29
-#include <sys/types.h>
30
-#include <sys/stat.h>
31
-#include <signal.h>
32
-#include <pthread.h>
33
-#include <string.h>
34
-
35
-#include "libclamav/clamav.h"
36
-#include "libclamav/scanners.h"
37
-
38
-#include "shared/optparser.h"
39
-#include "shared/output.h"
40
-
41
-#include "server.h"
42
-#include "others.h"
43
-#include "dazukoio.h"
44
-#include "clamukofs.h"
45
-#include "clamuko.h"
46
-#include "scanner.h"
47
-
48
-struct dazuko_access *acc;
49
-short int clamuko_scanning;
50
-static void clamuko_exit(int sig)
51
-{
52
-
53
-    logg("*Clamuko: clamuko_exit(), signal %d\n", sig);
54
-
55
-    if(clamuko_scanning) {
56
-	logg("*Clamuko: stopped while scanning %s\n", acc->filename);
57
-	acc->deny = 0;
58
-	dazukoReturnAccess(&acc); /* is it needed ? */
59
-    }
60
-
61
-    if(dazukoUnregister())
62
-	logg("!Can't unregister with Dazuko\n");
63
-
64
-    logg("Clamuko stopped.\n");
65
-
66
-    pthread_exit(NULL);
67
-}
68
-
69
-static void *clamukolegacyth(void *arg)
70
-{
71
-	struct thrarg *tharg = (struct thrarg *) arg;
72
-	sigset_t sigset;
73
-	const char *virname;
74
-        struct sigaction act;
75
-	unsigned long mask = 0;
76
-	const struct optstruct *pt;
77
-	short int scan;
78
-	int sizelimit = 0, extinfo;
79
-	struct stat sb;
80
-	struct cb_context context;
81
-
82
-
83
-    clamuko_scanning = 0;
84
-
85
-    /* ignore all signals except SIGUSR1 */
86
-    sigfillset(&sigset);
87
-    sigdelset(&sigset, SIGUSR1);
88
-    /* The behavior of a process is undefined after it ignores a 
89
-     * SIGFPE, SIGILL, SIGSEGV, or SIGBUS signal */
90
-    sigdelset(&sigset, SIGFPE);
91
-    sigdelset(&sigset, SIGILL);
92
-    sigdelset(&sigset, SIGSEGV);
93
-#ifdef SIGBUS    
94
-    sigdelset(&sigset, SIGBUS);
95
-#endif
96
-    pthread_sigmask(SIG_SETMASK, &sigset, NULL);
97
-    memset(&act, 0, sizeof(struct sigaction));
98
-    act.sa_handler = clamuko_exit;
99
-    sigfillset(&(act.sa_mask));
100
-    sigaction(SIGUSR1, &act, NULL);
101
-    sigaction(SIGSEGV, &act, NULL);
102
-
103
-    /* register */
104
-    if(dazukoRegister("ClamAV", "r+")) {
105
-	logg("!Clamuko: Can't register with Dazuko\n");
106
-	return NULL;
107
-    } else
108
-	logg("Clamuko: Correctly registered with Dazuko.\n");
109
-
110
-    /* access mask */
111
-    if(optget(tharg->opts, "ClamukoScanOnOpen")->enabled) {
112
-	logg("Clamuko: Scan-on-open mode activated.\n");
113
-	mask |= DAZUKO_ON_OPEN;
114
-    }
115
-    if(optget(tharg->opts, "ClamukoScanOnClose")->enabled) {
116
-	logg("Clamuko: Scan-on-close mode activated.\n");
117
-	mask |= DAZUKO_ON_CLOSE;
118
-    }
119
-    if(optget(tharg->opts, "ClamukoScanOnExec")->enabled) {
120
-	logg("Clamuko: Scan-on-exec mode activated.\n");
121
-	mask |= DAZUKO_ON_EXEC;
122
-    }
123
-
124
-    if(!mask) {
125
-	logg("!Access mask is not configured properly.\n");
126
-	dazukoUnregister();
127
-	return NULL;
128
-    }
129
-
130
-    if(dazukoSetAccessMask(mask)) {
131
-	logg("!Clamuko: Can't set access mask in Dazuko.\n");
132
-	dazukoUnregister();
133
-	return NULL;
134
-    }
135
-
136
-    if((pt = optget(tharg->opts, "ClamukoIncludePath"))->enabled) {
137
-	while(pt) {
138
-	    if((dazukoAddIncludePath(pt->strarg))) {
139
-		logg("!Clamuko: Dazuko -> Can't include path %s\n", pt->strarg);
140
-		dazukoUnregister();
141
-		return NULL;
142
-	    } else
143
-		logg("Clamuko: Included path %s\n", pt->strarg);
144
-
145
-	    pt = (struct optstruct *) pt->nextarg;
146
-	}
147
-    } else {
148
-	logg("!Clamuko: please include at least one path.\n");
149
-	dazukoUnregister();
150
-	return NULL;
151
-    }
152
-
153
-    if((pt = optget(tharg->opts, "ClamukoExcludePath"))->enabled) {
154
-	while(pt) {
155
-	    if((dazukoAddExcludePath(pt->strarg))) {
156
-		logg("!Clamuko: Dazuko -> Can't exclude path %s\n", pt->strarg);
157
-		dazukoUnregister();
158
-		return NULL;
159
-	    } else
160
-		logg("Clamuko: Excluded path %s\n", pt->strarg);
161
-
162
-	    pt = (struct optstruct *) pt->nextarg;
163
-	}
164
-    }
165
-
166
-    sizelimit = optget(tharg->opts, "ClamukoMaxFileSize")->numarg;
167
-    if(sizelimit)
168
-	logg("Clamuko: Max file size limited to %d bytes.\n", sizelimit);
169
-    else
170
-	logg("Clamuko: File size limit disabled.\n");
171
-
172
-    extinfo = optget(tharg->opts, "ExtendedDetectionInfo")->enabled;
173
-
174
-    while(1) {
175
-
176
-	if(dazukoGetAccess(&acc) == 0) {
177
-	    clamuko_scanning = 1;
178
-	    scan = 1;
179
-
180
-	    if(sizelimit) {
181
-		stat(acc->filename, &sb);
182
-		if(sb.st_size > sizelimit) {
183
-		    scan = 0;
184
-		    logg("*Clamuko: %s skipped (too big)\n", acc->filename);
185
-		}
186
-	    }
187
-
188
-	    if(clamuko_checkowner(acc->pid, tharg->opts)) {
189
-		scan = 0;
190
-		logg("*Clamuko: %s skipped (excluded UID)\n", acc->filename);
191
-	    }
192
-
193
-	    context.filename = acc->filename;
194
-	    context.virsize = 0;
195
-	    if(scan && cl_scanfile_callback(acc->filename, &virname, NULL, tharg->engine, tharg->options, &context) == CL_VIRUS) {
196
-		if(context.virsize)
197
-		    detstats_add(virname, acc->filename, context.virsize, context.virhash);
198
-		if(extinfo && context.virsize)
199
-		    logg("Clamuko: %s: %s(%s:%llu) FOUND\n", acc->filename, virname, context.virhash, context.virsize);
200
-		else
201
-		    logg("Clamuko: %s: %s FOUND\n", acc->filename, virname);
202
-		virusaction(acc->filename, virname, tharg->opts);
203
-		acc->deny = 1;
204
-	    } else
205
-		acc->deny = 0;
206
-
207
-	    if(dazukoReturnAccess(&acc)) {
208
-		logg("!Can't return access to Dazuko.\n");
209
-		logg("Clamuko stopped.\n");
210
-		dazukoUnregister();
211
-		clamuko_scanning = 0;
212
-		return NULL;
213
-	    }
214
-
215
-	    clamuko_scanning = 0;
216
-	}
217
-    }
218
-
219
-    /* can't be ;) */
220
-    return NULL;
221
-}
222
-
223
-void *clamukoth(void *arg)
224
-{
225
-	struct stat s;
226
-
227
-    /* we use DazukoFS if /dev/dazukofs.ctrl exists and it is a
228
-     * character device, otherwise we use Dazuko */
229
-    if(stat("/dev/dazukofs.ctrl", &s) != 0) return clamukolegacyth(arg);
230
-    if(!S_ISCHR(s.st_mode)) return clamukolegacyth(arg);
231
-    return clamukofsth(arg);
232
-}
233
-
234
-#endif
235 1
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-/*
2
- *  Copyright (C) 2007-2009 Sourcefire, Inc.
3
- *
4
- *  Authors: Tomasz Kojm
5
- *
6
- *  This program is free software; you can redistribute it and/or modify
7
- *  it under the terms of the GNU General Public License version 2 as
8
- *  published by the Free Software Foundation.
9
- *
10
- *  This program is distributed in the hope that it will be useful,
11
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- *  GNU General Public License for more details.
14
- *
15
- *  You should have received a copy of the GNU General Public License
16
- *  along with this program; if not, write to the Free Software
17
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
- *  MA 02110-1301, USA.
19
- */
20
-
21
-#ifdef CLAMUKO
22
-
23
-#ifndef __CLAMUKO_H
24
-#define __CLAMUKO_H
25
-
26
-extern short int clamuko_scanning;
27
-void *clamukoth(void *arg);
28
-
29
-#endif
30
-#endif
31 1
deleted file mode 100644
... ...
@@ -1,266 +0,0 @@
1
-/*
2
- *  Copyright (C) 2007-2009 Sourcefire, Inc.
3
- *    Author: Tomasz Kojm
4
- *    Author: John Ogness <dazukocode@ogness.net>
5
- *
6
- *  This program is free software; you can redistribute it and/or modify
7
- *  it under the terms of the GNU General Public License version 2 as
8
- *  published by the Free Software Foundation.
9
- *
10
- *  This program is distributed in the hope that it will be useful,
11
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- *  GNU General Public License for more details.
14
- *
15
- *  You should have received a copy of the GNU General Public License
16
- *  along with this program; if not, write to the Free Software
17
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
- *  MA 02110-1301, USA.
19
- */
20
-
21
-#if HAVE_CONFIG_H
22
-#include "clamav-config.h"
23
-#endif
24
-
25
-#ifdef CLAMUKO
26
-
27
-#include <stdio.h>
28
-#include <unistd.h>
29
-#include <sys/types.h>
30
-#include <sys/stat.h>
31
-#include <signal.h>
32
-#include <pthread.h>
33
-
34
-#include "libclamav/clamav.h"
35
-#include "libclamav/scanners.h"
36
-
37
-#include "shared/optparser.h"
38
-#include "shared/output.h"
39
-
40
-#include "server.h"
41
-#include "others.h"
42
-#include "dazukofs.h"
43
-#include "clamuko.h"
44
-#include "scanner.h"
45
-
46
-static pthread_mutex_t running_mutex = PTHREAD_MUTEX_INITIALIZER;
47
-static dazukofs_handle_t shutdown_hndl;
48
-static pthread_cond_t shutdown_cond;
49
-
50
-static void clamuko_exit(int sig)
51
-{
52
-    pthread_cond_signal(&shutdown_cond);
53
-}
54
-
55
-static int setup_shutdown_handle(const char *groupname)
56
-{
57
-    /* is another server thread is already running? */
58
-    if(shutdown_hndl) return -1;
59
-
60
-    if(pthread_cond_init(&shutdown_cond, NULL)) return -1;
61
-
62
-    /* handle used for shutdown by signal */
63
-    shutdown_hndl = dazukofs_open(groupname, DAZUKOFS_TRACK_GROUP);
64
-    if(!shutdown_hndl) {
65
-	logg("!Clamuko: Can't register with DazukoFS\n");
66
-	return -1;
67
-    }
68
-    return 0;
69
-}
70
-
71
-static void shutdown_clamuko(void)
72
-{
73
-	dazukofs_handle_t hndl = shutdown_hndl;
74
-
75
-    /* Set shutdown_hndl before closing because the close will
76
-     * immediately cause the scan threads to be interrupted.
77
-     * But they will only abort if shutdown_hndl is NULL. */
78
-    shutdown_hndl = NULL;
79
-
80
-    if(hndl) dazukofs_close(hndl, DAZUKOFS_REMOVE_GROUP);
81
-}
82
-
83
-static void *clamuko_scanth(void *arg)
84
-{
85
-	struct thrarg *tharg = (struct thrarg *) arg;
86
-	sigset_t sigset;
87
-	unsigned int sizelimit = 0;
88
-	struct stat sb;
89
-	dazukofs_handle_t scan_hndl;
90
-	struct dazukofs_access acc;
91
-	const char *groupname = "ClamAV";
92
-	int skip_scan = 0, extinfo;
93
-	const char *virname;
94
-	char filename[4096];
95
-	struct cb_context context;
96
-
97
-    /* ignore all signals */
98
-    sigfillset(&sigset);
99
-    /* The behavior of a process is undefined after it ignores a
100
-     * SIGFPE, SIGILL, SIGSEGV, or SIGBUS signal */
101
-    sigdelset(&sigset, SIGFPE);
102
-    sigdelset(&sigset, SIGILL);
103
-    sigdelset(&sigset, SIGSEGV);
104
-#ifdef SIGBUS
105
-    sigdelset(&sigset, SIGBUS);
106
-#endif
107
-    pthread_sigmask(SIG_SETMASK, &sigset, NULL);
108
-
109
-    /* register */
110
-    scan_hndl = dazukofs_open(groupname, DAZUKOFS_TRACK_GROUP);
111
-    if(!scan_hndl) {
112
-	logg("!Clamuko: Can't register with DazukoFS\n");
113
-	return NULL;
114
-    } else {
115
-	logg("Clamuko: Correctly registered with DazukoFS.\n");
116
-    }
117
-
118
-    /* access mask (not used by DazukoFS) */
119
-    if(optget(tharg->opts, "ClamukoScanOnOpen")->enabled)
120
-	logg("!Clamuko: ClamukoScanOnOpen ignored when using DazukoFS.\n");
121
-    if(optget(tharg->opts, "ClamukoScanOnClose")->enabled)
122
-	logg("!Clamuko: ClamukoScanOnClose ignored when using DazukoFS.\n");
123
-    if(optget(tharg->opts, "ClamukoScanOnExec")->enabled)
124
-	logg("!Clamuko: ClamukoScanOnExec ignored when using DazukoFS.\n");
125
-    if(optget(tharg->opts, "ClamukoIncludePath")->enabled)
126
-	logg("!Clamuko: ClamukoIncludePath ignored when using DazukoFS.\n");
127
-    if(optget(tharg->opts, "ClamukoExcludePath")->enabled)
128
-	logg("!Clamuko: ClamukoExcludePath ignored when using DazukoFS.\n");
129
-
130
-    sizelimit = optget(tharg->opts, "ClamukoMaxFileSize")->numarg;
131
-    if(sizelimit)
132
-	logg("Clamuko: Max file size limited to %u bytes.\n", sizelimit);
133
-    else
134
-	logg("Clamuko: File size limit disabled.\n");
135
-
136
-    extinfo = optget(tharg->opts, "ExtendedDetectionInfo")->enabled;
137
-
138
-    while(1) {
139
-	if(dazukofs_get_access(scan_hndl, &acc)) {
140
-	    if(!shutdown_hndl)
141
-		break;
142
-	    continue;
143
-	}
144
-
145
-	if(!fstat(acc.fd, &sb)) {
146
-	    if(S_ISDIR(sb.st_mode)) {
147
-		/* don't try to scan directories */
148
-		skip_scan = 1;
149
-	    } else if(sb.st_size > sizelimit) {
150
-		dazukofs_get_filename(&acc, filename, sizeof(filename));
151
-		logg("*Clamuko: %s skipped (too big)\n", filename);
152
-		skip_scan = 1;
153
-	    }
154
-	}
155
-
156
-	if(clamuko_checkowner(acc.pid, tharg->opts)) {
157
-	    dazukofs_get_filename(&acc, filename, sizeof(filename));
158
-	    logg("*Clamuko: %s skipped (excluded UID)\n", filename);
159
-	    skip_scan = 1;
160
-	}
161
-
162
-	context.filename = NULL;
163
-	context.virsize = 0;
164
-	if(skip_scan) {
165
-	    acc.deny = 0;
166
-	    /* reset skip flag */
167
-	    skip_scan = 0;
168
-	} else if(cl_scandesc_callback(acc.fd, &virname, NULL, tharg->engine,
169
-			      tharg->options, &context) == CL_VIRUS) {
170
-	    dazukofs_get_filename(&acc, filename, sizeof(filename));
171
-	    if(context.virsize)
172
-		detstats_add(virname, filename, context.virsize, context.virhash);
173
-	    if(extinfo && context.virsize)
174
-		logg("Clamuko: %s: %s(%s:%llu) FOUND\n", filename, virname, context.virhash, context.virsize);
175
-	    else
176
-		logg("Clamuko: %s: %s FOUND\n", filename, virname);
177
-	    /* we can not perform any special action because it will
178
-	     * trigger DazukoFS recursively */
179
-	    acc.deny = 1;
180
-	} else {
181
-	    acc.deny = 0;
182
-	}
183
-
184
-	if(dazukofs_return_access(scan_hndl, &acc)) {
185
-	    if(shutdown_hndl)
186
-	        logg("!Clamuko: Can't return access to DazukoFS.\n");
187
-	    break;
188
-	}
189
-    }
190
-
191
-    dazukofs_close(scan_hndl, 0);
192
-
193
-    if(shutdown_hndl)
194
-        logg("!Clamuko: A scanner thread has unexpectedly shutdown.\n");
195
-
196
-    return NULL;
197
-}
198
-
199
-void *clamukofsth(void *arg)
200
-{
201
-	struct thrarg *tharg = (struct thrarg *) arg;
202
-	sigset_t sigset;
203
-        struct sigaction act;
204
-	pthread_t *clamuko_pids = NULL;
205
-	const char *groupname = "ClamAV";
206
-	int count;
207
-	int started;
208
-
209
-    /* is another server thread already working? */
210
-    if(pthread_mutex_trylock(&running_mutex))
211
-	return NULL;
212
-
213
-    /* ignore all signals except SIGUSR1 */
214
-    sigfillset(&sigset);
215
-    sigdelset(&sigset, SIGUSR1);
216
-    /* The behavior of a process is undefined after it ignores a
217
-     * SIGFPE, SIGILL, SIGSEGV, or SIGBUS signal */
218
-    sigdelset(&sigset, SIGFPE);
219
-    sigdelset(&sigset, SIGILL);
220
-    sigdelset(&sigset, SIGSEGV);
221
-#ifdef SIGBUS
222
-    sigdelset(&sigset, SIGBUS);
223
-#endif
224
-    pthread_sigmask(SIG_SETMASK, &sigset, NULL);
225
-
226
-    count = optget(tharg->opts, "ClamukoScannerCount")->numarg;
227
-    if(count < 1) goto out;
228
-
229
-    clamuko_pids = calloc(count, sizeof(pthread_t));
230
-    if(!clamuko_pids) goto out;
231
-
232
-    if(setup_shutdown_handle(groupname)) goto out;
233
-
234
-    act.sa_handler = clamuko_exit;
235
-    sigfillset(&(act.sa_mask));
236
-    sigaction(SIGUSR1, &act, NULL);
237
-    sigaction(SIGSEGV, &act, NULL);
238
-
239
-    for(started = 0; started < count; started++) {
240
-	pthread_attr_t clamuko_attr;
241
-
242
-	if(pthread_attr_init(&clamuko_attr)) break;
243
-	pthread_attr_setdetachstate(&clamuko_attr, PTHREAD_CREATE_JOINABLE);
244
-	if(pthread_create(&clamuko_pids[started], &clamuko_attr,
245
-			  clamuko_scanth, tharg)) break;
246
-	logg("Clamuko: Started scanner thread %d.\n", started);
247
-    }
248
-
249
-    pthread_cond_wait(&shutdown_cond, &running_mutex);
250
-    logg("Clamuko: Stop signal received.\n");
251
-
252
-    shutdown_clamuko();
253
-
254
-    for(started-- ; started >= 0; started--) {
255
-	logg("Clamuko: Waiting for scanner thread %d to finish.\n", started);
256
-	pthread_join(clamuko_pids[started], NULL);
257
-    }
258
-
259
-    logg("Clamuko: Stopped.\n");
260
-out:
261
-    if(clamuko_pids) free(clamuko_pids);
262
-    pthread_mutex_unlock(&running_mutex);
263
-    return NULL;
264
-}
265
-
266
-#endif
267 1
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-/*
2
- *  Copyright (C) 2009 Sourcefire, Inc.
3
- *    Author: John Ogness <dazukocode@ogness.net>
4
- *
5
- *  This program is free software; you can redistribute it and/or modify
6
- *  it under the terms of the GNU General Public License version 2 as
7
- *  published by the Free Software Foundation.
8
- *
9
- *  This program is distributed in the hope that it will be useful,
10
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
- *  GNU General Public License for more details.
13
- *
14
- *  You should have received a copy of the GNU General Public License
15
- *  along with this program; if not, write to the Free Software
16
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
- *  MA 02110-1301, USA.
18
- */
19
-
20
-#ifdef CLAMUKO
21
-
22
-#ifndef __CLAMUKOFS_H
23
-#define __CLAMUKOFS_H
24
-
25
-extern void *clamukofsth(void *arg);
26
-
27
-#endif
28
-#endif
29 1
deleted file mode 100644
... ...
@@ -1,232 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* DazukoXP. Allow cross platform file access control for 3rd-party applications.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#ifndef DAZUKO_XP_H
41
-#define DAZUKO_XP_H
42
-
43
-#define VERSION	"2.0.4-pre3"
44
-
45
-#include "dazukoio_xp.h"
46
-
47
-/* various requests */
48
-#define SET_ACCESS_MASK		0
49
-#define ADD_INCLUDE_PATH	1
50
-#define ADD_EXCLUDE_PATH	2
51
-#define REGISTER		3
52
-#define REMOVE_ALL_PATHS	4
53
-#define UNREGISTER		5
54
-#define GET_AN_ACCESS		6
55
-#define RETURN_AN_ACCESS	7
56
-
57
-/* slot states */
58
-#define	DAZUKO_FREE	0	/* the daemon is not ready */
59
-#define	DAZUKO_READY	1	/* a daemon waits for something to do */
60
-#define	DAZUKO_WAITING	2	/* a request is waiting to be served */
61
-#define	DAZUKO_WORKING	3	/* daemon is currently in action */
62
-#define	DAZUKO_DONE	4	/* daemon response is available */
63
-#define	DAZUKO_BROKEN	5	/* invalid state (interrupt from ready,waiting) */
64
-
65
-/* file types */
66
-#define DAZUKO_NONE		0
67
-#define DAZUKO_REGULAR		1
68
-#define DAZUKO_DIRECTORY	2
69
-#define DAZUKO_LINK		3
70
-
71
-
72
-/*********************************************************
73
- * structures that MUST be implemented by platform-layer *
74
- *********************************************************/
75
-
76
-/*
77
-struct xp_file;
78
-struct xp_mutex;
79
-struct xp_atomic;
80
-struct xp_file_struct;
81
-struct xp_queue;
82
-struct xp_rwlock;
83
-struct xp_daemon_id;
84
-*/
85
-
86
-
87
-/******************************************
88
- * structures available to platform-layer *
89
- ******************************************/
90
-
91
-struct event_properties
92
-{
93
-	int	thrown;
94
-
95
-	int	flags;
96
-	char	set_flags;
97
-	int	mode;
98
-	char	set_mode;
99
-	int	uid;
100
-	char	set_uid;
101
-	int	pid;
102
-	char	set_pid;
103
-};
104
-
105
-struct file_properties
106
-{
107
-	unsigned long	size;
108
-	char		set_size;
109
-	int		uid;
110
-	char		set_uid;
111
-	int		gid;
112
-	char		set_gid;
113
-	int		mode;
114
-	char		set_mode;
115
-	int		device_type;
116
-	char		set_device_type;
117
-	int		type;
118
-	char		set_type;
119
-};
120
-
121
-struct dazuko_file_listnode
122
-{
123
-	char				*filename;
124
-	int				filename_length;
125
-	struct dazuko_file_listnode	*next;
126
-};
127
-
128
-struct dazuko_file_struct
129
-{
130
-	/* A structure designed for simple and
131
-	 * intelligent memory management when
132
-	 * doing filename lookups in the kernel. */
133
-
134
-	int				should_scan;		/* already know we need to scan? */
135
-	char				*filename;		/* filename to report (pointer in alias list) */
136
-	int				filename_length;	/* length of filename reported */
137
-	struct dazuko_file_listnode	*aliases;		/* list of file names (alias names) */
138
-	struct file_properties		file_p;			/* properties of file */
139
-	struct xp_file_struct		*extra_data;		/* extra platform-dependant data */
140
-};
141
-
142
-
143
-/********************************************************
144
- * functions that MUST be implemented by platform-layer *
145
- ********************************************************/
146
-
147
-/* mutex */
148
-int xp_init_mutex(struct xp_mutex *mutex);
149
-int xp_down(struct xp_mutex *mutex);
150
-int xp_up(struct xp_mutex *mutex);
151
-int xp_destroy_mutex(struct xp_mutex *mutex);
152
-
153
-/* read-write lock */
154
-int xp_init_rwlock(struct xp_rwlock *rwlock);
155
-int xp_write_lock(struct xp_rwlock *rwlock);
156
-int xp_write_unlock(struct xp_rwlock *rwlock);
157
-int xp_read_lock(struct xp_rwlock *rlock);
158
-int xp_read_unlock(struct xp_rwlock *rlock);
159
-int xp_destroy_rwlock(struct xp_rwlock *rwlock);
160
-
161
-/* wait-notify queue */
162
-int xp_init_queue(struct xp_queue *queue);
163
-int xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt);
164
-int xp_notify(struct xp_queue *queue);
165
-int xp_destroy_queue(struct xp_queue *queue);
166
-
167
-/* memory */
168
-void* xp_malloc(size_t size);
169
-int xp_free(void *ptr);
170
-int xp_copyin(const void *user_src, void *kernel_dest, size_t size);
171
-int xp_copyout(const void *kernel_src, void *user_dest, size_t size);
172
-int xp_verify_user_writable(const void *user_ptr, size_t size);
173
-int xp_verify_user_readable(const void *user_ptr, size_t size);
174
-
175
-/* path attribute */
176
-int xp_is_absolute_path(const char *path);
177
-
178
-/* atomic */
179
-int xp_atomic_set(struct xp_atomic *atomic, int value);
180
-int xp_atomic_inc(struct xp_atomic *atomic);
181
-int xp_atomic_dec(struct xp_atomic *atomic);
182
-int xp_atomic_read(struct xp_atomic *atomic);
183
-
184
-/* file descriptor */
185
-int xp_copy_file(struct xp_file *dest, struct xp_file *src);
186
-int xp_compare_file(struct xp_file *file1, struct xp_file *file2);
187
-
188
-/* system hook */
189
-int xp_sys_hook(void);
190
-int xp_sys_unhook(void);
191
-
192
-/* file structure */
193
-int xp_file_struct_check(struct dazuko_file_struct *dfs);
194
-int xp_file_struct_check_cleanup(struct dazuko_file_struct *dfs);
195
-
196
-/* daemon id */
197
-int xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2);
198
-int xp_id_free(struct xp_daemon_id *id);
199
-struct xp_daemon_id* xp_id_copy(struct xp_daemon_id *id);
200
-
201
-/* output */
202
-int xp_print(const char *fmt, ...);
203
-
204
-/* debug */
205
-#ifdef DEBUG
206
-#define DPRINT(fmt) xp_print fmt
207
-#else
208
-#define DPRINT(fmt)
209
-#endif
210
-
211
-
212
-/*****************************************
213
- * functions available to platform-layer *
214
- *****************************************/
215
-
216
-int dazuko_vsnprintf(char *str, size_t size, const char *format, va_list ap);
217
-int dazuko_snprintf(char *str, size_t size, const char *format, ...);
218
-int dazuko_is_our_daemon(struct xp_daemon_id *xp_id);
219
-int dazuko_get_value(const char *key, const char *string, char **value);
220
-int dazuko_unregister_daemon(struct xp_daemon_id *xp_id);
221
-int dazuko_handle_user_request(struct dazuko_request *user_request, struct xp_daemon_id *xp_id);
222
-int dazuko_handle_user_request_compat12(void *ptr, int cmd, struct xp_daemon_id *xp_id);
223
-int dazuko_get_filename_length(char *filename);
224
-void dazuko_bzero(void *p, int len);
225
-int dazuko_sys_check(unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id);
226
-int dazuko_sys_pre(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
227
-int dazuko_sys_post(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
228
-int dazuko_init(void);
229
-int dazuko_exit(void);
230
-
231
-#endif
232
-#endif
233 1
deleted file mode 100644
... ...
@@ -1,238 +0,0 @@
1
-/* userspace library to interface with dazukofs
2
-
3
-   Copyright (C) 2008-2009 John Ogness
4
-     Author: John Ogness <dazukocode@ogness.net>
5
-
6
-   This library is free software; you can redistribute it and/or
7
-   modify it under the terms of the GNU Lesser General Public
8
-   License as published by the Free Software Foundation; either
9
-   version 2.1 of the License, or (at your option) any later version.
10
-
11
-   This library is distributed in the hope that it will be useful,
12
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
-   GNU Lesser General Public License for more details.
15
-
16
-   You should have received a copy of the GNU Lesser General Public
17
-   License along with this library; if not, write to the Free Software
18
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
-*/
20
-
21
-#include <stdio.h>
22
-#include <stdlib.h>
23
-#include <string.h>
24
-#include <fcntl.h>
25
-#include <unistd.h>
26
-
27
-#include <sys/types.h>
28
-#include <sys/stat.h>
29
-
30
-#include "dazukofs.h"
31
-
32
-struct dazukofs_handle
33
-{
34
-	int dev_fd;
35
-	unsigned long event_id;
36
-	char *group_name;
37
-};
38
-
39
-#define DAZUKOFS_ALLOWED_GROUPCHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
40
-static int check_group_name(const char *gname)
41
-{
42
-	size_t len = strlen(gname);
43
-	const char *p;
44
-
45
-	if (len > 20)
46
-		return -1;
47
-
48
-	for (p = gname; *p; p++) {
49
-		if (strchr(DAZUKOFS_ALLOWED_GROUPCHARS, *p) == NULL)
50
-			return -1;
51
-	}
52
-
53
-	return 0;
54
-}
55
-
56
-dazukofs_handle_t dazukofs_open(const char *gname, int flags)
57
-{
58
-	struct dazukofs_handle *hndl = NULL;
59
-	char key[25];
60
-	char buf[256];
61
-	char *p;
62
-	int gid;
63
-	int fd;
64
-
65
-	if (check_group_name(gname) != 0)
66
-		goto error_out;
67
-
68
-	fd = open("/dev/dazukofs.ctrl", O_RDWR);
69
-	if (fd == -1) {
70
-		/* try to read at least
71
-		 * (maybe the group already exists) */
72
-		fd = open("/dev/dazukofs.ctrl", O_RDONLY);
73
-		if (fd == -1)
74
-			goto error_out;
75
-	} else {
76
-		memset(buf, 0, sizeof(buf));
77
-
78
-		if (flags & DAZUKOFS_TRACK_GROUP)
79
-			snprintf(buf, sizeof(buf) - 1, "addtrack=%s", gname);
80
-		else
81
-			snprintf(buf, sizeof(buf) - 1, "add=%s", gname);
82
-
83
-		if (write(fd, buf, strlen(buf)) == -1)
84
-			goto error_out_close;
85
-
86
-		lseek(fd, 0, SEEK_SET);
87
-	}
88
-
89
-	memset(buf, 0, sizeof(buf));
90
-	if (read(fd, buf, sizeof(buf)-1) == -1)
91
-		goto error_out_close;
92
-
93
-	memset(key, 0, sizeof(key));
94
-	snprintf(key, sizeof(key) - 1, ":%s\n", gname);
95
-
96
-	p = strstr(buf, key);
97
-	if (!p || p == buf)
98
-		goto error_out_close;
99
-
100
-	p--;
101
-	gid = *p - '0';
102
-	if (gid < 0 || gid > 9)
103
-		goto error_out_close;
104
-
105
-	hndl = malloc(sizeof(struct dazukofs_handle));
106
-	if (!hndl)
107
-		goto error_out_close;
108
-	memset(hndl, 0, sizeof(struct dazukofs_handle));
109
-
110
-	hndl->group_name = strdup(gname);
111
-	if (!hndl->group_name)
112
-		goto error_out_free;
113
-
114
-	memset(key, 0, sizeof(key));
115
-	snprintf(key, sizeof(key) - 1, "/dev/dazukofs.%d", gid);
116
-
117
-	hndl->dev_fd = open(key, O_RDWR);
118
-	if (hndl->dev_fd == -1)
119
-		goto error_out_free;
120
-
121
-	close(fd);
122
-
123
-	return hndl;
124
-
125
-error_out_free:
126
-	if (hndl->group_name)
127
-		free(hndl->group_name);
128
-	free(hndl);
129
-	hndl = NULL;
130
-error_out_close:
131
-	close(fd);
132
-error_out:
133
-	return hndl;
134
-}
135
-
136
-int dazukofs_close(dazukofs_handle_t hndl, int flags)
137
-{
138
-	char buf[48];
139
-	int fd;
140
-	int ret = -1;
141
-
142
-	if (flags & DAZUKOFS_REMOVE_GROUP) {
143
-		fd = open("/dev/dazukofs.ctrl", O_WRONLY);
144
-		if (fd == -1)
145
-			goto error_out;
146
-
147
-		memset(buf, 0, sizeof(buf));
148
-		snprintf(buf, sizeof(buf) - 1, "del=%s", hndl->group_name);
149
-
150
-		if (write(fd, buf, strlen(buf)) == -1) {
151
-			close(fd);
152
-			goto error_out;
153
-		}
154
-
155
-		close(fd);
156
-	}
157
-
158
-	ret = close(hndl->dev_fd);
159
-	if (ret != 0)
160
-		goto error_out;
161
-
162
-	free(hndl->group_name);
163
-	free(hndl);
164
-
165
-	return 0;
166
-
167
-error_out:
168
-	return ret;
169
-}
170
-
171
-int dazukofs_get_access(dazukofs_handle_t hndl, struct dazukofs_access *acc)
172
-{
173
-	char buf[48];
174
-	char *p;
175
-	int err = -1;
176
-
177
-	memset(buf, 0, sizeof(buf));
178
-	if (read(hndl->dev_fd, buf, sizeof(buf)-1) == -1)
179
-		goto out;
180
-
181
-	p = strstr(buf, "id=");
182
-	if (!p)
183
-		goto out;
184
-	p += 3;
185
-	hndl->event_id = strtoul(p, &p, 10);
186
-
187
-	p = strstr(p, "fd=");
188
-	if (!p)
189
-		goto out;
190
-	p += 3;
191
-	acc->fd = (int)strtol(p, &p, 10);
192
-
193
-	p = strstr(p, "pid=");
194
-	if (!p)
195
-		goto out;
196
-	p += 4;
197
-	acc->pid = strtoul(p, NULL, 10);
198
-
199
-	acc->deny = 0;
200
-
201
-	err = 0;
202
-out:
203
-	return err;
204
-}
205
-
206
-int dazukofs_return_access(dazukofs_handle_t hndl, struct dazukofs_access *acc)
207
-{
208
-	char buf[48];
209
-	int err = -1;
210
-
211
-	if (close(acc->fd) != 0)
212
-		goto out;
213
-	snprintf(buf, sizeof(buf)-1, "id=%lu r=%d", hndl->event_id,
214
-		 acc->deny ? 1 : 0);
215
-	buf[sizeof(buf)-1] = 0;
216
-
217
-	if (write(hndl->dev_fd, buf, strlen(buf)) == -1)
218
-		goto out;
219
-	lseek(hndl->dev_fd, 0, SEEK_SET);
220
-	err = 0;
221
-out:
222
-	return err;
223
-}
224
-
225
-int dazukofs_get_filename(struct dazukofs_access *acc, char *buf, size_t bufsiz)
226
-{
227
-	char proc[48];
228
-	int ret;
229
-
230
-	memset(proc, 0, sizeof(proc));
231
-	snprintf(proc, sizeof(proc) - 1, "/proc/self/fd/%d", acc->fd);
232
-	ret = readlink(proc, buf, bufsiz - 1);
233
-	buf[bufsiz - 1] = 0;
234
-	if (ret > 0)
235
-		buf[ret] = 0;
236
-
237
-	return ret;
238
-}
239 1
deleted file mode 100644
... ...
@@ -1,48 +0,0 @@
1
-/* userspace library to interface with dazukofs
2
-
3
-   Copyright (C) 2008 John Ogness
4
-     Author: John Ogness <dazukocode@ogness.net>
5
-
6
-   This library is free software; you can redistribute it and/or
7
-   modify it under the terms of the GNU Lesser General Public
8
-   License as published by the Free Software Foundation; either
9
-   version 2.1 of the License, or (at your option) any later version.
10
-
11
-   This library is distributed in the hope that it will be useful,
12
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
-   GNU Lesser General Public License for more details.
15
-
16
-   You should have received a copy of the GNU Lesser General Public
17
-   License along with this library; if not, write to the Free Software
18
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
-*/
20
-
21
-#ifndef __DAZUKOFS_H
22
-#define __DAZUKOFS_H
23
-
24
-#include <stdio.h>
25
-
26
-/* dazukofs_open() flags */
27
-#define DAZUKOFS_TRACK_GROUP 1
28
-
29
-/* dazukofs_close() flags */
30
-#define DAZUKOFS_REMOVE_GROUP 1
31
-
32
-struct dazukofs_handle;
33
-typedef struct dazukofs_handle * dazukofs_handle_t;
34
-
35
-struct dazukofs_access
36
-{
37
-	int fd;
38
-	int deny;
39
-	unsigned long pid;
40
-};
41
-
42
-dazukofs_handle_t dazukofs_open(const char *gname, int flags);
43
-int dazukofs_get_access(dazukofs_handle_t hndl, struct dazukofs_access *acc);
44
-int dazukofs_return_access(dazukofs_handle_t hndl, struct dazukofs_access *acc);
45
-int dazukofs_close(dazukofs_handle_t hndl, int flags);
46
-int dazukofs_get_filename(struct dazukofs_access *acc, char *buf, size_t bufsiz);
47
-
48
-#endif /* __DAZUKOFS_H */
49 1
deleted file mode 100644
... ...
@@ -1,905 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* Dazuko Interface. Interace with Dazuko for file access control.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#include <stdio.h>
41
-#include <stdlib.h>
42
-#include <sys/types.h>
43
-#include <fcntl.h>
44
-#include <string.h>
45
-#ifdef HAVE_STRINGS_H
46
-#include <strings.h>
47
-#endif
48
-#include <unistd.h>
49
-#include "dazukoio_xp.h"
50
-#include "dazukoio.h"
51
-
52
-#if !defined(NO_COMPAT12)
53
-#include "dazukoio_compat12.h"
54
-#endif
55
-
56
-#define ITOA_SIZE	32
57
-
58
-dazuko_id_t	*_GLOBAL_DAZUKO = NULL;
59
-
60
-#if !defined(NO_COMPAT12)
61
-char		_GLOBAL_DAZUKO_COMPAT12 = 0;
62
-#endif
63
-
64
-static inline char char_to_hex(char c)
65
-{
66
-	/* ugly, but fast */
67
-
68
-	switch (c)
69
-	{
70
-		case '1': return 1;
71
-		case '2': return 2;
72
-		case '3': return 3;
73
-		case '4': return 4;
74
-		case '5': return 5;
75
-		case '6': return 6;
76
-		case '7': return 7;
77
-		case '8': return 8;
78
-		case '9': return 9;
79
-		case 'a': case 'A': return 10;
80
-		case 'b': case 'B': return 11;
81
-		case 'c': case 'C': return 12;
82
-		case 'd': case 'D': return 13;
83
-		case 'e': case 'E': return 14;
84
-		case 'f': case 'F': return 15;
85
-	}
86
-
87
-	return 0;
88
-}
89
-
90
-static void unescape_string(char *string)
91
-{
92
-	char	*p;
93
-
94
-	for (p=string ; *p ; p++)
95
-	{
96
-		/* check if we have \x */
97
-		if ((*p == '\\') && (*(p+1) == 'x'))
98
-		{
99
-			/* this is not cheap, but it should not occur often */
100
-
101
-			/* check if we have two more values following \x */
102
-			if (*(p+2) && *(p+3))
103
-			{
104
-				*p = char_to_hex(*(p+2));
105
-				*p <<= 4;
106
-				*p |= char_to_hex(*(p+3));
107
-
108
-				memmove(p + 1, p + 4, strlen(p+4) + 1);
109
-			}
110
-		}
111
-	}
112
-}
113
-
114
-static int get_value(const char *key, const char *string, char *buffer, size_t buffer_size)
115
-{
116
-	const char	*p1;
117
-	const char	*p2;
118
-	size_t		size;
119
-
120
-	if (buffer == NULL || buffer_size < 1)
121
-		return -1;
122
-
123
-	buffer[0] = 0;
124
-
125
-	if (key == NULL || string == NULL)
126
-		return -1;
127
-
128
-	p1 = strstr(string, key);
129
-	if (p1 == NULL)
130
-		return -1;
131
-
132
-	p1 += strlen(key);
133
-
134
-	for (p2=p1 ; *p2 && *p2!='\n' ; p2++)
135
-		continue;
136
-
137
-	size = p2 - p1;
138
-	if (size >= buffer_size)
139
-		size = buffer_size - 1;
140
-
141
-	memcpy(buffer, p1, size);
142
-
143
-	buffer[size] = 0;
144
-
145
-	return 0;
146
-}
147
-
148
-int dazukoRegister(const char *groupName, const char *mode)
149
-{
150
-	return dazukoRegister_TS(&_GLOBAL_DAZUKO, groupName, mode);
151
-}
152
-
153
-int dazukoRegister_TS(dazuko_id_t **dazuko_id, const char *groupName, const char *mode)
154
-{
155
-	struct dazuko_request	*request;
156
-	char			buffer[ITOA_SIZE];
157
-	char			regMode[3];
158
-	dazuko_id_t		*temp_id;
159
-	ssize_t			size;
160
-	int			write_mode = 0;
161
-#if !defined(NO_COMPAT12)
162
-	int			compat12_ret;
163
-#endif
164
-
165
-	if (dazuko_id == NULL)
166
-		return -1;
167
-
168
-	/* set default group name if one was not given */
169
-	if (groupName == NULL)
170
-		groupName = "_GENERIC";
171
-
172
-	/* set default mode if one was not given */
173
-	if (mode == NULL)
174
-		mode = "r";
175
-
176
-	if (strcasecmp(mode, "r") == 0)
177
-	{
178
-		strncpy(regMode, "R", sizeof(regMode));
179
-		regMode[sizeof(regMode)-1]='\0';
180
-		write_mode = 0;
181
-	}
182
-	else if (strcasecmp(mode, "r+") == 0 || strcasecmp(mode, "rw") == 0)
183
-	{
184
-		strncpy(regMode, "RW", sizeof(regMode));
185
-		regMode[sizeof(regMode)-1]='\0';
186
-		write_mode = 1;
187
-	}
188
-	else
189
-	{
190
-		return -1;
191
-	}
192
-	regMode[sizeof(regMode) - 1] = 0;
193
-
194
-#if !defined(NO_COMPAT12)
195
-	if (_GLOBAL_DAZUKO_COMPAT12)
196
-	{
197
-		compat12_ret = dazukoRegister_TS_compat12_wrapper(dazuko_id, groupName);
198
-
199
-		if (compat12_ret == 0)
200
-			(*dazuko_id)->write_mode = write_mode;
201
-
202
-		return compat12_ret;
203
-	}
204
-#endif
205
-
206
-	/* create temporary id */
207
-	temp_id = (dazuko_id_t *)malloc(sizeof(*temp_id));
208
-	if (temp_id == NULL)
209
-		return -1;
210
-
211
-	memset(temp_id, 0, sizeof(*temp_id));
212
-
213
-	/* open device */
214
-	temp_id->device = open("/dev/dazuko", O_RDWR);
215
-	if (temp_id->device < 0)
216
-	{
217
-		free(temp_id);
218
-		return -1;
219
-	}
220
-
221
-	/* read device major number */
222
-	memset(buffer, 0, sizeof(buffer));
223
-	if (read(temp_id->device, buffer, sizeof(buffer)-1) < 1)
224
-	{
225
-		close(temp_id->device);
226
-		free(temp_id);
227
-		return -1;
228
-	}
229
-
230
-	temp_id->dev_major = atoi(buffer);
231
-	if (temp_id->dev_major < 0)
232
-	{
233
-		close(temp_id->device);
234
-		free(temp_id);
235
-		return -1;
236
-	}
237
-
238
-	request = (struct dazuko_request *)malloc(sizeof(*request));
239
-	if (request == NULL)
240
-	{
241
-		close(temp_id->device);
242
-		free(temp_id);
243
-		return -1;
244
-	}
245
-
246
-	memset(request, 0, sizeof(*request));
247
-
248
-	request->type[0] = REGISTER;
249
-
250
-	size = 1 + 2 + 1 + strlen(regMode); /* \nRM=mode */
251
-	size += 1 + 2 + 1 + strlen(groupName); /* \nGN=groupName */
252
-	size += 1; /* \0 */
253
-
254
-	request->buffer = (char *)malloc(size);
255
-	if (request->buffer == NULL)
256
-	{
257
-		close(temp_id->device);
258
-		free(temp_id);
259
-		free(request);
260
-		return -1;
261
-	}
262
-	snprintf(request->buffer, size, "\nRM=%s\nGN=%s", regMode, groupName);
263
-	request->buffer[size - 1] = 0;
264
-
265
-	request->buffer_size = strlen(request->buffer) + 1;
266
-
267
-	size = 4096;
268
-	request->reply_buffer = (char *)malloc(size);
269
-	if (request->reply_buffer == NULL)
270
-	{
271
-		close(temp_id->device);
272
-		free(temp_id);
273
-		free(request->buffer);
274
-		free(request);
275
-		return -1;
276
-	}
277
-	memset(request->reply_buffer, 0, size);
278
-	request->reply_buffer_size = size;
279
-
280
-	snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
281
-	buffer[sizeof(buffer)-1] = 0;
282
-	size = strlen(buffer) + 1;
283
-
284
-	if (write(temp_id->device, buffer, size) != size)
285
-	{
286
-		close(temp_id->device);
287
-		free(temp_id);
288
-		free(request->buffer);
289
-		free(request->reply_buffer);
290
-		free(request);
291
-
292
-#if !defined(NO_COMPAT12)
293
-		/* we try compat12 mode */
294
-		compat12_ret = dazukoRegister_TS_compat12_wrapper(dazuko_id, groupName);
295
-		if (compat12_ret == 0)
296
-		{
297
-			(*dazuko_id)->write_mode = write_mode;
298
-			_GLOBAL_DAZUKO_COMPAT12 = 1;
299
-		}
300
-
301
-		return compat12_ret;
302
-#else
303
-		return -1;
304
-#endif
305
-	}
306
-
307
-	if (get_value("\nID=", request->reply_buffer, buffer, sizeof(buffer)) != 0)
308
-	{
309
-		close(temp_id->device);
310
-		free(temp_id);
311
-		free(request->buffer);
312
-		free(request->reply_buffer);
313
-		free(request);
314
-
315
-#if !defined(NO_COMPAT12)
316
-		/* we try compat12 mode */
317
-		compat12_ret = dazukoRegister_TS_compat12_wrapper(dazuko_id, groupName);
318
-		if (compat12_ret == 0)
319
-		{
320
-			(*dazuko_id)->write_mode = write_mode;
321
-			_GLOBAL_DAZUKO_COMPAT12 = 1;
322
-		}
323
-
324
-		return compat12_ret;
325
-#else
326
-		return -1;
327
-#endif
328
-	}
329
-
330
-	temp_id->id = atoi(buffer);
331
-
332
-	if (temp_id->id < 0)
333
-	{
334
-		close(temp_id->device);
335
-		free(temp_id);
336
-		free(request->buffer);
337
-		free(request->reply_buffer);
338
-		free(request);
339
-
340
-		return -1;
341
-	}
342
-
343
-	temp_id->write_mode = write_mode;
344
-
345
-	free(request->buffer);
346
-	free(request->reply_buffer);
347
-	free(request);
348
-
349
-	*dazuko_id = temp_id;
350
-
351
-	return 0;
352
-}
353
-
354
-int dazukoSetAccessMask(unsigned long accessMask)
355
-{
356
-	return dazukoSetAccessMask_TS(_GLOBAL_DAZUKO, accessMask);
357
-}
358
-
359
-int dazukoSetAccessMask_TS(dazuko_id_t *dazuko_id, unsigned long accessMask)
360
-{
361
-	struct dazuko_request	*request;
362
-	ssize_t			size;
363
-	char			buffer[ITOA_SIZE];
364
-
365
-	if (dazuko_id == NULL)
366
-		return -1;
367
-
368
-#if !defined(NO_COMPAT12)
369
-	if (_GLOBAL_DAZUKO_COMPAT12)
370
-		return dazukoSetAccessMask_TS_compat12(dazuko_id, accessMask);
371
-#endif
372
-
373
-	if (dazuko_id->device < 0 || dazuko_id->dev_major < 0 || dazuko_id->id < 0)
374
-		return -1;
375
-
376
-	request = (struct dazuko_request *)malloc(sizeof(*request));
377
-	if (request == NULL)
378
-		return -1;
379
-
380
-	memset(request, 0, sizeof(*request));
381
-
382
-	request->type[0] = SET_ACCESS_MASK;
383
-
384
-	size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
385
-	size += 1 + 2 + 1 + ITOA_SIZE; /* \nAM=accessMask */
386
-	size += 1; /* \0 */
387
-
388
-	request->buffer = (char *)malloc(size);
389
-	if (request->buffer == NULL)
390
-	{
391
-		free(request);
392
-		return -1;
393
-	}
394
-	snprintf(request->buffer, size, "\nID=%d\nAM=%lu", dazuko_id->id, accessMask);
395
-	request->buffer[size - 1] = 0;
396
-
397
-	request->buffer_size = strlen(request->buffer) + 1;
398
-
399
-	snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
400
-	buffer[sizeof(buffer)-1] = 0;
401
-	size = strlen(buffer) + 1;
402
-
403
-	if (write(dazuko_id->device, buffer, size) != size)
404
-	{
405
-		free(request->buffer);
406
-		free(request);
407
-		return -1;
408
-	}
409
-
410
-	free(request->buffer);
411
-	free(request);
412
-
413
-	return 0;
414
-}
415
-
416
-static int dazuko_set_path(dazuko_id_t *dazuko_id, const char *path, int type)
417
-{
418
-	struct dazuko_request	*request;
419
-	ssize_t			size;
420
-	char			buffer[ITOA_SIZE];
421
-
422
-	if (dazuko_id == NULL)
423
-		return -1;
424
-
425
-	if (dazuko_id->device < 0 || dazuko_id->dev_major < 0 || dazuko_id->id < 0)
426
-		return -1;
427
-
428
-	if (path == NULL)
429
-		return -1;
430
-
431
-	request = (struct dazuko_request *)malloc(sizeof(*request));
432
-	if (request == NULL)
433
-		return -1;
434
-
435
-	memset(request, 0, sizeof(*request));
436
-
437
-	request->type[0] = type;
438
-
439
-	size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
440
-	size += 1 + 2 + 1 + strlen(path); /* \nPT=path */
441
-	size += 1; /* \0 */
442
-
443
-	request->buffer = (char *)malloc(size);
444
-	if (request->buffer == NULL)
445
-	{
446
-		free(request);
447
-		return -1;
448
-	}
449
-	snprintf(request->buffer, size, "\nID=%d\nPT=%s", dazuko_id->id, path);
450
-	request->buffer[size - 1] = 0;
451
-
452
-	request->buffer_size = strlen(request->buffer) + 1;
453
-
454
-	snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
455
-	buffer[sizeof(buffer)-1] = 0;
456
-	size = strlen(buffer) + 1;
457
-
458
-	if (write(dazuko_id->device, buffer, size) != size)
459
-	{
460
-		free(request->buffer);
461
-		free(request);
462
-		return -1;
463
-	}
464
-
465
-	free(request->buffer);
466
-	free(request);
467
-
468
-	return 0;
469
-}
470
-
471
-int dazukoAddIncludePath(const char *path)
472
-{
473
-	return dazukoAddIncludePath_TS(_GLOBAL_DAZUKO, path);
474
-}
475
-
476
-int dazukoAddIncludePath_TS(dazuko_id_t *dazuko_id, const char *path)
477
-{
478
-#if !defined(NO_COMPAT12)
479
-	if (_GLOBAL_DAZUKO_COMPAT12)
480
-		return dazukoAddIncludePath_TS_compat12(dazuko_id, path);
481
-#endif
482
-
483
-	return dazuko_set_path(dazuko_id, path, ADD_INCLUDE_PATH);
484
-}
485
-
486
-int dazukoAddExcludePath(const char *path)
487
-{
488
-	return dazukoAddExcludePath_TS(_GLOBAL_DAZUKO, path);
489
-}
490
-
491
-int dazukoAddExcludePath_TS(dazuko_id_t *dazuko_id, const char *path)
492
-{
493
-#if !defined(NO_COMPAT12)
494
-	if (_GLOBAL_DAZUKO_COMPAT12)
495
-		return dazukoAddExcludePath_TS_compat12(dazuko_id, path);
496
-#endif
497
-
498
-	return dazuko_set_path(dazuko_id, path, ADD_EXCLUDE_PATH);
499
-}
500
-
501
-int dazukoRemoveAllPaths(void)
502
-{
503
-	return dazukoRemoveAllPaths_TS(_GLOBAL_DAZUKO);
504
-}
505
-
506
-int dazukoRemoveAllPaths_TS(dazuko_id_t *dazuko_id)
507
-{
508
-	struct dazuko_request	*request;
509
-	ssize_t			size;
510
-	char			buffer[ITOA_SIZE];
511
-
512
-	if (dazuko_id == NULL)
513
-		return -1;
514
-
515
-#if !defined(NO_COMPAT12)
516
-	if (_GLOBAL_DAZUKO_COMPAT12)
517
-		return dazukoRemoveAllPaths_TS_compat12(dazuko_id);
518
-#endif
519
-
520
-	if (dazuko_id->device < 0 || dazuko_id->dev_major < 0 || dazuko_id->id < 0)
521
-		return -1;
522
-
523
-	request = (struct dazuko_request *)malloc(sizeof(*request));
524
-	if (request == NULL)
525
-		return -1;
526
-
527
-	memset(request, 0, sizeof(*request));
528
-
529
-	request->type[0] = REMOVE_ALL_PATHS;
530
-
531
-	size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
532
-	size += 1; /* \0 */
533
-
534
-	request->buffer = (char *)malloc(size);
535
-	if (request->buffer == NULL)
536
-	{
537
-		free(request);
538
-		return -1;
539
-	}
540
-	snprintf(request->buffer, size, "\nID=%d", dazuko_id->id);
541
-	request->buffer[size - 1] = 0;
542
-
543
-	request->buffer_size = strlen(request->buffer) + 1;
544
-
545
-	snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
546
-	buffer[sizeof(buffer)-1] = 0;
547
-	size = strlen(buffer) + 1;
548
-
549
-	if (write(dazuko_id->device, buffer, size) != size)
550
-	{
551
-		free(request->buffer);
552
-		free(request);
553
-		return -1;
554
-	}
555
-
556
-	free(request->buffer);
557
-	free(request);
558
-
559
-	return 0;
560
-}
561
-
562
-int dazukoGetAccess(struct dazuko_access **acc)
563
-{
564
-	return dazukoGetAccess_TS(_GLOBAL_DAZUKO, acc);
565
-}
566
-
567
-int dazukoGetAccess_TS(dazuko_id_t *dazuko_id, struct dazuko_access **acc)
568
-{
569
-	struct dazuko_request	*request;
570
-	struct dazuko_access	*temp_acc;
571
-	ssize_t			size;
572
-	size_t			filename_size;
573
-	char			buffer[ITOA_SIZE];
574
-#if !defined(NO_COMPAT12)
575
-	int			compat12_ret;
576
-#endif
577
-
578
-	if (dazuko_id == NULL)
579
-		return -1;
580
-
581
-#if !defined(NO_COMPAT12)
582
-	if (_GLOBAL_DAZUKO_COMPAT12)
583
-	{
584
-		compat12_ret = dazukoGetAccess_TS_compat12_wrapper(dazuko_id, acc);
585
-
586
-		if (compat12_ret == 0 && !(dazuko_id->write_mode))
587
-		{
588
-			/* we are in read_only mode so we return the access immediately */
589
-
590
-			dazukoReturnAccess_TS_compat12_wrapper(dazuko_id, acc, 1, 0);
591
-
592
-			/* this could be dangerous, we do not check if the return was successfull! */
593
-		}
594
-
595
-		return compat12_ret;
596
-	}
597
-#endif
598
-
599
-	if (dazuko_id->device < 0 || dazuko_id->dev_major < 0 || dazuko_id->id < 0)
600
-		return -1;
601
-
602
-	if (acc == NULL)
603
-		return -1;
604
-
605
-	request = (struct dazuko_request *)malloc(sizeof(*request));
606
-	if (request == NULL)
607
-		return -1;
608
-
609
-	memset(request, 0, sizeof(*request));
610
-
611
-	request->type[0] = GET_AN_ACCESS;
612
-
613
-	size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
614
-	size += 1; /* \0 */
615
-
616
-	request->buffer = (char *)malloc(size);
617
-	if (request->buffer == NULL)
618
-	{
619
-		free(request);
620
-		return -1;
621
-	}
622
-	snprintf(request->buffer, size, "\nID=%d", dazuko_id->id);
623
-	request->buffer[size - 1] = 0;
624
-
625
-	request->buffer_size = strlen(request->buffer) + 1;
626
-
627
-	size = 1 + 2 + 1 + DAZUKO_FILENAME_MAX_LENGTH; /* \nFN=filename */
628
-	size += 1024; /* miscellaneous access attributes */
629
-	size += 1; /* \0 */
630
-	request->reply_buffer = (char *)malloc(size);
631
-	if (request->reply_buffer == NULL)
632
-	{
633
-		free(request->buffer);
634
-		free(request);
635
-		return -1;
636
-	}
637
-	memset(request->reply_buffer, 0, size);
638
-	request->reply_buffer_size = size;
639
-
640
-	temp_acc = (struct dazuko_access *)malloc(sizeof(*temp_acc));
641
-	if (temp_acc == NULL)
642
-	{
643
-		free(request->reply_buffer);
644
-		free(request->buffer);
645
-		free(request);
646
-		return -1;
647
-	}
648
-
649
-	memset(temp_acc, 0, sizeof(*temp_acc));
650
-
651
-	filename_size = DAZUKO_FILENAME_MAX_LENGTH + 1;
652
-	temp_acc->filename = (char *)malloc(filename_size);
653
-	if (temp_acc->filename == NULL)
654
-	{
655
-		free(temp_acc);
656
-		free(request->reply_buffer);
657
-		free(request->buffer);
658
-		free(request);
659
-		return -1;
660
-	}
661
-
662
-	snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
663
-	buffer[sizeof(buffer)-1] = 0;
664
-	size = strlen(buffer) + 1;
665
-
666
-	if (write(dazuko_id->device, buffer, size) != size)
667
-	{
668
-		free(temp_acc->filename);
669
-		free(temp_acc);
670
-		free(request->reply_buffer);
671
-		free(request->buffer);
672
-		free(request);
673
-		return -1;
674
-	}
675
-
676
-	if (request->reply_buffer_size_used > 0)
677
-	{
678
-		if (get_value("\nFN=", request->reply_buffer, temp_acc->filename, filename_size) == 0)
679
-		{
680
-			temp_acc->set_filename = 1;
681
-			unescape_string(temp_acc->filename);
682
-		}
683
-
684
-		if (get_value("\nEV=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
685
-		{
686
-			temp_acc->event = atoi(buffer);
687
-			temp_acc->set_event = 1;
688
-		}
689
-
690
-		if (get_value("\nFL=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
691
-		{
692
-			temp_acc->flags = atoi(buffer);
693
-			temp_acc->set_flags = 1;
694
-		}
695
-
696
-		if (get_value("\nMD=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
697
-		{
698
-			temp_acc->mode = atoi(buffer);
699
-			temp_acc->set_mode = 1;
700
-		}
701
-
702
-		if (get_value("\nUI=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
703
-		{
704
-			temp_acc->uid = atoi(buffer);
705
-			temp_acc->set_uid = 1;
706
-		}
707
-
708
-		if (get_value("\nPI=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
709
-		{
710
-			temp_acc->pid = atoi(buffer);
711
-			temp_acc->set_pid = 1;
712
-		}
713
-
714
-		if (get_value("\nFS=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
715
-		{
716
-			temp_acc->file_size = atol(buffer);
717
-			temp_acc->set_file_size = 1;
718
-		}
719
-
720
-		if (get_value("\nFU=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
721
-		{
722
-			temp_acc->file_uid = atoi(buffer);
723
-			temp_acc->set_file_uid = 1;
724
-		}
725
-
726
-		if (get_value("\nFG=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
727
-		{
728
-			temp_acc->file_gid = atoi(buffer);
729
-			temp_acc->set_file_gid = 1;
730
-		}
731
-
732
-		if (get_value("\nDT=", request->reply_buffer, buffer, sizeof(buffer)) == 0)
733
-		{
734
-			temp_acc->file_device = atoi(buffer);
735
-			temp_acc->set_file_device = 1;
736
-		}
737
-	}
738
-
739
-	free(request->reply_buffer);
740
-	free(request->buffer);
741
-	free(request);
742
-
743
-	*acc = temp_acc;
744
-
745
-	return 0;
746
-}
747
-
748
-int dazukoReturnAccess(struct dazuko_access **acc)
749
-{
750
-	return dazukoReturnAccess_TS(_GLOBAL_DAZUKO, acc);
751
-}
752
-
753
-int dazukoReturnAccess_TS(dazuko_id_t *dazuko_id, struct dazuko_access **acc)
754
-{
755
-	struct dazuko_request	*request;
756
-	ssize_t			size;
757
-	char			buffer[ITOA_SIZE];
758
-
759
-	if (dazuko_id == NULL)
760
-		return -1;
761
-
762
-#if !defined(NO_COMPAT12)
763
-	if (_GLOBAL_DAZUKO_COMPAT12)
764
-		return dazukoReturnAccess_TS_compat12_wrapper(dazuko_id, acc, dazuko_id->write_mode, 1);
765
-#endif
766
-
767
-	if (dazuko_id->device < 0 || dazuko_id->dev_major < 0 || dazuko_id->id < 0)
768
-		return -1;
769
-
770
-	if (acc == NULL)
771
-		return -1;
772
-
773
-	if (*acc == NULL)
774
-		return -1;
775
-
776
-	if (dazuko_id->write_mode)
777
-	{
778
-		request = (struct dazuko_request *)malloc(sizeof(*request));
779
-		if (request == NULL)
780
-			return -1;
781
-
782
-		memset(request, 0, sizeof(*request));
783
-
784
-		request->type[0] = RETURN_AN_ACCESS;
785
-
786
-		size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
787
-		size += 1 + 2 + 1 + ITOA_SIZE; /* \nDN=deny */
788
-		size += 1; /* \0 */
789
-
790
-		request->buffer = (char *)malloc(size);
791
-		if (request->buffer == NULL)
792
-		{
793
-			free(request);
794
-			return -1;
795
-		}
796
-		snprintf(request->buffer, size, "\nID=%d\nDN=%d", dazuko_id->id, (*acc)->deny == 0 ? 0 : 1);
797
-		request->buffer[size - 1] = 0;
798
-
799
-		request->buffer_size = strlen(request->buffer) + 1;
800
-
801
-		snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
802
-		buffer[sizeof(buffer)-1] = 0;
803
-		size = strlen(buffer) + 1;
804
-
805
-		if (write(dazuko_id->device, buffer, size) != size)
806
-		{
807
-			/* there could be big problems if this happens */
808
-
809
-			if ((*acc)->filename != NULL)
810
-				free((*acc)->filename);
811
-			free(*acc);
812
-			*acc = NULL;
813
-			free(request->buffer);
814
-			free(request);
815
-			return -1;
816
-		}
817
-
818
-		free(request->buffer);
819
-		free(request);
820
-	}
821
-
822
-	if ((*acc)->filename != NULL)
823
-		free((*acc)->filename);
824
-	free(*acc);
825
-	*acc = NULL;
826
-
827
-	return 0;
828
-}
829
-
830
-int dazukoUnregister(void)
831
-{
832
-	return dazukoUnregister_TS(&_GLOBAL_DAZUKO);
833
-}
834
-
835
-int dazukoUnregister_TS(dazuko_id_t **dazuko_id)
836
-{
837
-	struct dazuko_request	*request;
838
-	ssize_t			size;
839
-	char			buffer[ITOA_SIZE];
840
-
841
-	if (dazuko_id == NULL)
842
-		return -1;
843
-
844
-#if !defined(NO_COMPAT12)
845
-	if (_GLOBAL_DAZUKO_COMPAT12)
846
-		return dazukoUnregister_TS_compat12_wrapper(dazuko_id);
847
-#endif
848
-
849
-	if (*dazuko_id == NULL)
850
-		return -1;
851
-
852
-	if ((*dazuko_id)->device < 0)
853
-		return -1;
854
-
855
-	if ((*dazuko_id)->dev_major >= 0 && (*dazuko_id)->id >= 0)
856
-	{
857
-		request = (struct dazuko_request *)malloc(sizeof(*request));
858
-		if (request == NULL)
859
-			return -1;
860
-
861
-		memset(request, 0, sizeof(*request));
862
-
863
-		request->type[0] = UNREGISTER;
864
-
865
-		size = 1 + 2 + 1 + ITOA_SIZE; /* \nID=id */
866
-		size += 1; /* \0 */
867
-
868
-		request->buffer = (char *)malloc(size);
869
-		if (request->buffer == NULL)
870
-		{
871
-			free(request);
872
-			return -1;
873
-		}
874
-		snprintf(request->buffer, size, "\nID=%d", (*dazuko_id)->id);
875
-		request->buffer[size - 1] = 0;
876
-
877
-		request->buffer_size = strlen(request->buffer) + 1;
878
-
879
-		snprintf(buffer, sizeof(buffer), "\nRA=%lu", (unsigned long)request);
880
-		buffer[sizeof(buffer)-1] = 0;
881
-		size = strlen(buffer) + 1;
882
-
883
-		if (write((*dazuko_id)->device, buffer, size) != size)
884
-		{
885
-			/* there could be big problems if this happens */
886
-
887
-			close((*dazuko_id)->device);
888
-			free(*dazuko_id);
889
-			*dazuko_id = NULL;
890
-			free(request->buffer);
891
-			free(request);
892
-			return -1;
893
-		}
894
-
895
-		free(request->buffer);
896
-		free(request);
897
-	}
898
-
899
-	close((*dazuko_id)->device);
900
-	free(*dazuko_id);
901
-	*dazuko_id = NULL;
902
-
903
-	return 0;
904
-}
905
-#endif
906 1
deleted file mode 100644
... ...
@@ -1,102 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* Dazuko Interface. Interace with Dazuko for file access control.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#ifndef DAZUKOIO_H
41
-#define DAZUKOIO_H
42
-
43
-/* event types */
44
-#define	DAZUKO_ON_OPEN			1
45
-#define	DAZUKO_ON_CLOSE			2
46
-#define	DAZUKO_ON_EXEC 			4
47
-#define	DAZUKO_ON_CLOSE_MODIFIED	8
48
-#define	DAZUKO_ON_UNLINK		16
49
-#define	DAZUKO_ON_RMDIR			32
50
-
51
-struct dazuko_access
52
-{
53
-	int		deny;
54
-	int		event;
55
-	char		set_event;
56
-	int		flags;
57
-	char		set_flags;
58
-	int		mode;
59
-	char		set_mode;
60
-	int 		uid;
61
-	char		set_uid;
62
-	int		pid;
63
-	char		set_pid;
64
-	char		*filename;
65
-	char		set_filename;
66
-	unsigned long	file_size;
67
-	char		set_file_size;
68
-	int		file_uid;
69
-	char		set_file_uid;
70
-	int		file_gid;
71
-	char		set_file_gid;
72
-	int		file_mode;
73
-	char		set_file_mode;
74
-	int		file_device;
75
-	char		set_file_device;
76
-};
77
-
78
-struct dazuko_id;
79
-typedef struct dazuko_id dazuko_id_t;
80
-
81
-/* single-threaded API */
82
-int dazukoRegister(const char *groupName, const char *mode);
83
-int dazukoSetAccessMask(unsigned long accessMask);
84
-int dazukoAddIncludePath(const char *path);
85
-int dazukoAddExcludePath(const char *path);
86
-int dazukoRemoveAllPaths(void);
87
-int dazukoGetAccess(struct dazuko_access **acc);
88
-int dazukoReturnAccess(struct dazuko_access **acc);
89
-int dazukoUnregister(void);
90
-
91
-/* thread-safe API (as long as each thread has its own "dazuko_id_t") */
92
-int dazukoRegister_TS(dazuko_id_t **dazuko, const char *groupName, const char *mode);
93
-int dazukoSetAccessMask_TS(dazuko_id_t *dazuko, unsigned long accessMask);
94
-int dazukoAddIncludePath_TS(dazuko_id_t *dazuko, const char *path);
95
-int dazukoAddExcludePath_TS(dazuko_id_t *dazuko, const char *path);
96
-int dazukoRemoveAllPaths_TS(dazuko_id_t *dazuko);
97
-int dazukoGetAccess_TS(dazuko_id_t *dazuko, struct dazuko_access **acc);
98
-int dazukoReturnAccess_TS(dazuko_id_t *dazuko, struct dazuko_access **acc);
99
-int dazukoUnregister_TS(dazuko_id_t **dazuko);
100
-
101
-#endif
102
-#endif
103 1
deleted file mode 100644
... ...
@@ -1,395 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* Dazuko Interface. Interace with Dazuko 1.x for file access control.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#include <stdio.h>
41
-#include <stdlib.h>
42
-#include <sys/types.h>
43
-#include <sys/stat.h>
44
-#include <fcntl.h>
45
-#include <string.h>
46
-#include <unistd.h>
47
-#include <sys/ioctl.h>
48
-#include "dazukoio_compat12.h"
49
-
50
-int dazukoRegister_TS_compat12_wrapper(struct dazuko_id **dazuko_id, const char *groupName)
51
-{
52
-	int			ret;
53
-	struct dazuko_id	*temp_id;
54
-
55
-	if (dazuko_id == NULL)
56
-		return -1;
57
-
58
-	temp_id = (struct dazuko_id *)malloc(sizeof(*temp_id));
59
-	if (temp_id == NULL)
60
-		return -1;
61
-
62
-	memset(temp_id, 0, sizeof(*temp_id));
63
-
64
-	temp_id->device = -1;
65
-	temp_id->dev_major = -1;
66
-
67
-	ret = dazukoRegister_TS_compat12(temp_id, groupName);
68
-
69
-	if (ret == 0)
70
-		*dazuko_id = temp_id;
71
-	else
72
-		free(temp_id);
73
-
74
-	return ret;
75
-}
76
-
77
-int dazukoRegister_TS_compat12(struct dazuko_id *dazuko, const char *groupName)
78
-{
79
-	struct option_compat12	*opt;
80
-	char			buffer[10];
81
-	int			err = 0;
82
-
83
-	if (dazuko == NULL)
84
-		return -1;
85
-
86
-	if (groupName == NULL)
87
-		groupName = "_GENERIC";
88
-
89
-	if (dazuko->device < 0)
90
-	{
91
-
92
-		dazuko->device = open("/dev/dazuko", 0);
93
-		if (dazuko->device < 0)
94
-			return -1;
95
-
96
-		memset(buffer, 0, sizeof(buffer));
97
-		if (read(dazuko->device, buffer, sizeof(buffer)-1) < 1)
98
-		{
99
-			close(dazuko->device);
100
-			dazuko->device = -1;
101
-			return -1;
102
-		}
103
-		dazuko->dev_major = atoi(buffer);
104
-	}
105
-
106
-	opt = (struct option_compat12 *)malloc(sizeof(struct option_compat12));
107
-	if (opt == NULL)
108
-	{
109
-		close(dazuko->device);
110
-		dazuko->device = -1;
111
-		dazuko->dev_major = -1;
112
-		return -1;
113
-	}
114
-
115
-	memset(opt, 0, sizeof(struct option_compat12));
116
-
117
-	opt->command = REGISTER;
118
-	strncpy(opt->buffer, groupName, sizeof(opt->buffer) - 1);
119
-	opt->buffer[sizeof(opt->buffer)-1]='\0';
120
-	opt->buffer_length = strlen(opt->buffer) + 1;
121
-
122
-	if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0)
123
-	{
124
-		/* if this fails, it could be a really old version */
125
-
126
-		/*
127
-		close(dazuko->device);
128
-		dazuko->device = -1;
129
-		dazuko->dev_major = -1;
130
-		err = -1;
131
-		*/
132
-	}
133
-
134
-	free(opt);
135
-
136
-	return err;
137
-}
138
-
139
-int dazukoSetAccessMask_TS_compat12(struct dazuko_id *dazuko, unsigned long accessMask)
140
-{
141
-	struct option_compat12	*opt;
142
-	int			err = 0;
143
-
144
-	if (dazuko == NULL)
145
-		return -1;
146
-
147
-	if (dazuko->device < 0 || dazuko->dev_major < 0)
148
-		return -1;
149
-
150
-	opt = (struct option_compat12 *)malloc(sizeof(struct option_compat12));
151
-	if (opt == NULL)
152
-		return -1;
153
-
154
-	memset(opt, 0, sizeof(struct option_compat12));
155
-
156
-	opt->command = SET_ACCESS_MASK;
157
-	opt->buffer[0] = (char)accessMask;
158
-	opt->buffer_length = 1;
159
-
160
-	if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0)
161
-		err = -1;
162
-
163
-	free(opt);
164
-
165
-	return err;
166
-}
167
-
168
-int dazuko_set_path_compat12(struct dazuko_id *dazuko, const char *path, int command)
169
-{
170
-	struct option_compat12	*opt;
171
-	int			err = 0;
172
-
173
-	if (dazuko == NULL)
174
-		return -1;
175
-
176
-	if (path == NULL)
177
-		return -1;
178
-
179
-	if (dazuko->device < 0 || dazuko->dev_major < 0)
180
-		return -1;
181
-
182
-	opt = (struct option_compat12 *)malloc(sizeof(struct option_compat12));
183
-	if (opt == NULL)
184
-		return -1;
185
-
186
-	memset(opt, 0, sizeof(struct option_compat12));
187
-
188
-	opt->command = command;
189
-	strncpy(opt->buffer, path, sizeof(opt->buffer) - 1);
190
-	opt->buffer[sizeof(opt->buffer)-1]='\0';
191
-	opt->buffer_length = strlen(opt->buffer) + 1;
192
-
193
-	if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0)
194
-		err = -1;
195
-
196
-	free(opt);
197
-
198
-	return err;
199
-}
200
-
201
-int dazukoAddIncludePath_TS_compat12(struct dazuko_id *dazuko, const char *path)
202
-{
203
-	return dazuko_set_path_compat12(dazuko, path, ADD_INCLUDE_PATH);
204
-}
205
-
206
-int dazukoAddExcludePath_TS_compat12(struct dazuko_id *dazuko, const char *path)
207
-{
208
-	return dazuko_set_path_compat12(dazuko, path, ADD_EXCLUDE_PATH);
209
-}
210
-
211
-int dazukoRemoveAllPaths_TS_compat12(struct dazuko_id *dazuko)
212
-{
213
-	struct option_compat12	*opt;
214
-	int			err = 0;
215
-
216
-	if (dazuko == NULL)
217
-		return -1;
218
-
219
-	if (dazuko->device < 0 || dazuko->dev_major < 0)
220
-		return -1;
221
-
222
-	opt = (struct option_compat12 *)malloc(sizeof(struct option_compat12));
223
-	if (opt == NULL)
224
-		return -1;
225
-
226
-	memset(opt, 0, sizeof(struct option_compat12));
227
-
228
-	opt->command = REMOVE_ALL_PATHS;
229
-	opt->buffer_length = 0;
230
-
231
-	if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0)
232
-		err = -1;
233
-
234
-	free(opt);
235
-
236
-	return err;
237
-
238
-}
239
-
240
-int dazukoGetAccess_TS_compat12_wrapper(struct dazuko_id *dazuko, struct dazuko_access **acc)
241
-{
242
-	struct access_compat12	acc_compat12;
243
-	struct dazuko_access	*temp_acc;
244
-	int			ret;
245
-
246
-	if (acc == NULL)
247
-		return -1;
248
-
249
-	*acc = NULL;
250
-
251
-	temp_acc = (struct dazuko_access *)malloc(sizeof(*temp_acc));
252
-	if (temp_acc == NULL)
253
-		return -1;
254
-
255
-	memset(temp_acc, 0, sizeof(*temp_acc));
256
-
257
-	ret = dazukoGetAccess_TS_compat12(dazuko, &acc_compat12);
258
-
259
-	if (ret == 0)
260
-	{
261
-		temp_acc->deny = acc_compat12.deny;
262
-		temp_acc->event = acc_compat12.event;
263
-		temp_acc->set_event = 1;
264
-		temp_acc->flags = acc_compat12.o_flags;
265
-		temp_acc->set_flags = 1;
266
-		temp_acc->mode = acc_compat12.o_mode;
267
-		temp_acc->set_mode = 1;
268
-		temp_acc->uid = acc_compat12.uid;
269
-		temp_acc->set_uid = 1;
270
-		temp_acc->pid = acc_compat12.pid;
271
-		temp_acc->set_pid = 1;
272
-		temp_acc->filename = strdup(acc_compat12.filename);
273
-		temp_acc->set_filename = 1;
274
-
275
-		*acc = temp_acc;
276
-	}
277
-	else
278
-	{
279
-		free(temp_acc);
280
-	}
281
-
282
-	return ret;
283
-}
284
-
285
-int dazukoGetAccess_TS_compat12(struct dazuko_id *dazuko, struct access_compat12 *acc)
286
-{
287
-	if (dazuko == NULL)
288
-		return -1;
289
-
290
-	if (acc == NULL)
291
-		return -1;
292
-
293
-	if (dazuko->device < 0 || dazuko->dev_major < 0)
294
-		return -1;
295
-
296
-	memset(acc, 0, sizeof(struct access_compat12));
297
-
298
-	if (ioctl(dazuko->device, _IOR(dazuko->dev_major, IOCTL_GET_AN_ACCESS, struct access_compat12 *), acc) != 0)
299
-		return -1;
300
-
301
-	return 0;
302
-}
303
-
304
-int dazukoReturnAccess_TS_compat12_wrapper(struct dazuko_id *dazuko, struct dazuko_access **acc, int return_access, int free_access)
305
-{
306
-	struct access_compat12	acc_compat12;
307
-	int			ret = 0;
308
-
309
-	if (acc == NULL)
310
-		return -1;
311
-
312
-	if (*acc == NULL)
313
-		return -1;
314
-
315
-	if (return_access)
316
-	{
317
-		memset(&acc_compat12, 0, sizeof(acc_compat12));
318
-
319
-		acc_compat12.deny = (*acc)->deny;
320
-		acc_compat12.event = (*acc)->event;
321
-		acc_compat12.o_flags = (*acc)->flags;
322
-		acc_compat12.o_mode = (*acc)->mode;
323
-		acc_compat12.uid = (*acc)->uid;
324
-		acc_compat12.pid = (*acc)->pid;
325
-		if ((*acc)->filename != NULL)
326
-		{
327
-			strncpy(acc_compat12.filename, (*acc)->filename, sizeof(acc_compat12.filename) - 1);
328
-			acc_compat12.filename[sizeof(acc_compat12.filename) - 1] = 0;
329
-		}
330
-
331
-		ret = dazukoReturnAccess_TS_compat12(dazuko, &acc_compat12);
332
-	}
333
-
334
-	if (free_access && ret == 0)
335
-	{
336
-		if ((*acc)->filename != NULL)
337
-			free((*acc)->filename);
338
-		free(*acc);
339
-		*acc = NULL;
340
-	}
341
-
342
-	return ret;
343
-}
344
-
345
-int dazukoReturnAccess_TS_compat12(struct dazuko_id *dazuko, struct access_compat12 *acc)
346
-{
347
-	if (dazuko == NULL)
348
-		return -1;
349
-
350
-	if (acc == NULL)
351
-		return -1;
352
-
353
-	if (dazuko->device < 0 || dazuko->dev_major < 0)
354
-		return -1;
355
-
356
-	if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_RETURN_ACCESS, struct access_compat12 *), acc) != 0)
357
-		return -1;
358
-
359
-	return 0;
360
-}
361
-
362
-int dazukoUnregister_TS_compat12_wrapper(struct dazuko_id **dazuko_id)
363
-{
364
-	int	ret;
365
-
366
-	if (dazuko_id == NULL)
367
-		return -1;
368
-
369
-	ret = dazukoUnregister_TS_compat12(*dazuko_id);
370
-
371
-	if (ret == 0)
372
-	{
373
-		free(*dazuko_id);
374
-		*dazuko_id = NULL;
375
-	}
376
-
377
-	return ret;
378
-}
379
-
380
-int dazukoUnregister_TS_compat12(struct dazuko_id *dazuko)
381
-{
382
-	int		error = -1;
383
-
384
-	if (dazuko == NULL)
385
-		return -1;
386
-
387
-	if (dazuko->device >= 0)
388
-		error = close(dazuko->device);
389
-
390
-	dazuko->device = -1;
391
-	dazuko->dev_major = -1;
392
-
393
-	return error;
394
-}
395
-#endif
396 1
deleted file mode 100644
... ...
@@ -1,61 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* Dazuko Interface. Interace with Dazuko 1.x for file access control.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#ifndef DAZUKOIO_COMPAT12_H
41
-#define DAZUKOIO_COMPAT12_H
42
-
43
-#include "dazukoio_xp.h"
44
-#include "dazukoio.h"
45
-
46
-int dazukoRegister_TS_compat12_wrapper(struct dazuko_id **dazuko_id, const char *groupName);
47
-int dazukoRegister_TS_compat12(struct dazuko_id *dazuko, const char *groupName);
48
-int dazukoSetAccessMask_TS_compat12(struct dazuko_id *dazuko, unsigned long accessMask);
49
-int dazuko_set_path_compat12(struct dazuko_id *dazuko, const char *path, int command);
50
-int dazukoAddIncludePath_TS_compat12(struct dazuko_id *dazuko, const char *path);
51
-int dazukoAddExcludePath_TS_compat12(struct dazuko_id *dazuko, const char *path);
52
-int dazukoRemoveAllPaths_TS_compat12(struct dazuko_id *dazuko);
53
-int dazukoGetAccess_TS_compat12_wrapper(struct dazuko_id *dazuko, struct dazuko_access **acc);
54
-int dazukoGetAccess_TS_compat12(struct dazuko_id *dazuko, struct access_compat12 *acc);
55
-int dazukoReturnAccess_TS_compat12_wrapper(struct dazuko_id *dazuko, struct dazuko_access **acc, int return_access, int free_access);
56
-int dazukoReturnAccess_TS_compat12(struct dazuko_id *dazuko, struct access_compat12 *acc);
57
-int dazukoUnregister_TS_compat12_wrapper(struct dazuko_id **dazuko_id);
58
-int dazukoUnregister_TS_compat12(struct dazuko_id *dazuko);
59
-
60
-#endif
61
-#endif
62 1
deleted file mode 100644
... ...
@@ -1,106 +0,0 @@
1
-#if HAVE_CONFIG_H
2
-#include "clamav-config.h"
3
-#endif
4
-
5
-#ifdef CLAMUKO
6
-/* DazukoXP Interface. Interace with Dazuko for file access control.
7
-   Written by John Ogness <jogness@antivir.de>
8
-
9
-   Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
10
-   All rights reserved.
11
-
12
-   Redistribution and use in source and binary forms, with or without
13
-   modification, are permitted provided that the following conditions
14
-   are met:
15
-
16
-   1. Redistributions of source code must retain the above copyright notice,
17
-   this list of conditions and the following disclaimer.
18
-
19
-   2. Redistributions in binary form must reproduce the above copyright notice,
20
-   this list of conditions and the following disclaimer in the documentation
21
-   and/or other materials provided with the distribution.
22
-
23
-   3. Neither the name of Dazuko nor the names of its contributors may be used
24
-   to endorse or promote products derived from this software without specific
25
-   prior written permission.
26
-
27
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
-   POSSIBILITY OF SUCH DAMAGE.
38
-*/
39
-
40
-#ifndef DAZUKOIO_XP_H
41
-#define DAZUKOIO_XP_H
42
-
43
-/* various requests */
44
-#define SET_ACCESS_MASK		0
45
-#define ADD_INCLUDE_PATH	1
46
-#define ADD_EXCLUDE_PATH	2
47
-#define REGISTER		3
48
-#define REMOVE_ALL_PATHS	4
49
-#define UNREGISTER		5
50
-#define GET_AN_ACCESS		6
51
-#define RETURN_AN_ACCESS	7
52
-
53
-/* this is just a large number to "guarentee"
54
-   to contain the full filename */
55
-#define DAZUKO_FILENAME_MAX_LENGTH	6144
56
-
57
-/* this is the hard-limit file length restriction from
58
-   the 1.x series */
59
-#define DAZUKO_FILENAME_MAX_LENGTH_COMPAT12	4095
60
-
61
-struct dazuko_request
62
-{
63
-	char	type[2];
64
-	int	buffer_size;
65
-	char	*buffer;
66
-	int	reply_buffer_size;
67
-	char	*reply_buffer;
68
-	int	reply_buffer_size_used;
69
-};
70
-
71
-struct dazuko_id
72
-{
73
-	int	device;
74
-	int	dev_major;
75
-	int	id;
76
-	int	write_mode;
77
-};
78
-
79
-/* compat12 ioctls */
80
-
81
-#define	IOCTL_SET_OPTION	0
82
-#define	IOCTL_GET_AN_ACCESS	1
83
-#define	IOCTL_RETURN_ACCESS	2
84
-
85
-/* compat12 structures */
86
-
87
-struct access_compat12
88
-{
89
-	int	deny;		/* set to deny file access */
90
-	int	event;		/* ON_OPEN, etc */
91
-	int	o_flags;	/* access flags */
92
-	int	o_mode;		/* access mode */
93
-	int	uid;		/* user id */
94
-	int	pid;		/* user process id */
95
-	char	filename[DAZUKO_FILENAME_MAX_LENGTH_COMPAT12];	/* accessed file */
96
-};
97
-
98
-struct option_compat12
99
-{
100
-	int	command;
101
-	int	buffer_length;
102
-	char	buffer[DAZUKO_FILENAME_MAX_LENGTH_COMPAT12];
103
-};
104
-
105
-#endif
106
-#endif
... ...
@@ -723,7 +723,7 @@ void detstats_print(int desc, char term)
723 723
     pthread_mutex_unlock(&detstats_lock);
724 724
 }
725 725
 
726
-#ifdef CLAMUKO
726
+#if 0 /* CLAMUKO */
727 727
 int clamuko_checkowner(int pid, const struct optstruct *opts)
728 728
 {
729 729
 	char path[32];
... ...
@@ -86,7 +86,7 @@ void detstats_clear(void);
86 86
 void detstats_add(const char *virname, const char *fname, unsigned int fsize, const char *md5);
87 87
 void detstats_print(int desc, char term);
88 88
 
89
-#ifdef CLAMUKO
89
+#if 0 /* CLAMUKO */
90 90
 int clamuko_checkowner(int pid, const struct optstruct *opts);
91 91
 #endif
92 92
 
... ...
@@ -52,7 +52,6 @@
52 52
 #include "server.h"
53 53
 #include "thrmgr.h"
54 54
 #include "session.h"
55
-#include "clamuko.h"
56 55
 #include "others.h"
57 56
 #include "shared.h"
58 57
 #include "libclamav/others.h"
... ...
@@ -61,6 +60,8 @@
61 61
 
62 62
 #define BUFFSIZE 1024
63 63
 
64
+#undef CLAMUKO /* FIXME */
65
+
64 66
 int progexit = 0;
65 67
 pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER;
66 68
 int reload = 0;
... ...
@@ -55,7 +55,7 @@ host_triplet = @host@
55 55
 target_triplet = @target@
56 56
 bin_PROGRAMS = sigtool$(EXEEXT)
57 57
 subdir = sigtool
58
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
58
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in COPYING
59 59
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
60 60
 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
61 61
 	$(top_srcdir)/m4/argz.m4 \