Browse code

autojunk'd

Mickey Sola authored on 2019/05/17 05:05:48
Showing 4 changed files
... ...
@@ -106,14 +106,14 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
106 106
 	$(top_srcdir)/config/depcomp
107 107
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
108 108
 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
109
+	$(top_srcdir)/m4/argz.m4 \
109 110
 	$(top_srcdir)/m4/ax_check_uname_syscall.m4 \
110 111
 	$(top_srcdir)/m4/fdpassing.m4 $(top_srcdir)/m4/lib-ld.m4 \
111 112
 	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
112 113
 	$(top_srcdir)/m4/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \
113
-	$(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \
114
-	$(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
115
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
116
-	$(top_srcdir)/m4/lt~obsolete.m4 \
114
+	$(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltdl.m4 \
115
+	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
116
+	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
117 117
 	$(top_srcdir)/m4/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \
118 118
 	$(top_srcdir)/m4/reorganization/version.m4 \
119 119
 	$(top_srcdir)/m4/reorganization/build_tools.m4 \
... ...
@@ -204,7 +204,9 @@ am__clamonacc_SOURCES_DIST = $(top_srcdir)/shared/output.c \
204 204
 	./fanotif/onaccess_fan.h ./inotif/onaccess_hash.c \
205 205
 	./inotif/onaccess_hash.h ./misc/onaccess_others.c \
206 206
 	./misc/onaccess_others.h ./misc/priv_fts.h \
207
-	./scan/onaccess_scth.c ./scan/onaccess_scth.h ./misc/fts.c
207
+	./scan/onaccess_scth.c ./scan/onaccess_scth.h \
208
+	./scan/onaccess_scque.c ./scan/onaccess_scque.h \
209
+	./c-thread-pool/thpool.c ./c-thread-pool/thpool.h ./misc/fts.c
208 210
 @BUILD_CLAMD_TRUE@@SYSTEM_LFS_FTS_FALSE@am__objects_1 = clamonacc-fts.$(OBJEXT)
209 211
 @BUILD_CLAMD_TRUE@am_clamonacc_OBJECTS = clamonacc-output.$(OBJEXT) \
210 212
 @BUILD_CLAMD_TRUE@	clamonacc-optparser.$(OBJEXT) \
... ...
@@ -220,7 +222,8 @@ am__clamonacc_SOURCES_DIST = $(top_srcdir)/shared/output.c \
220 220
 @BUILD_CLAMD_TRUE@	clamonacc-onaccess_hash.$(OBJEXT) \
221 221
 @BUILD_CLAMD_TRUE@	clamonacc-onaccess_others.$(OBJEXT) \
222 222
 @BUILD_CLAMD_TRUE@	clamonacc-onaccess_scth.$(OBJEXT) \
223
-@BUILD_CLAMD_TRUE@	$(am__objects_1)
223
+@BUILD_CLAMD_TRUE@	clamonacc-onaccess_scque.$(OBJEXT) \
224
+@BUILD_CLAMD_TRUE@	clamonacc-thpool.$(OBJEXT) $(am__objects_1)
224 225
 clamonacc_OBJECTS = $(am_clamonacc_OBJECTS)
225 226
 clamonacc_LDADD = $(LDADD)
226 227
 AM_V_lt = $(am__v_lt_@AM_V@)
... ...
@@ -295,6 +298,7 @@ ACLOCAL = @ACLOCAL@
295 295
 AMTAR = @AMTAR@
296 296
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
297 297
 AR = @AR@
298
+ARGZ_H = @ARGZ_H@
298 299
 AUTOCONF = @AUTOCONF@
299 300
 AUTOHEADER = @AUTOHEADER@
300 301
 AUTOMAKE = @AUTOMAKE@
... ...
@@ -417,11 +421,9 @@ LTDLINCL = @LTDLINCL@
417 417
 LTDLOPEN = @LTDLOPEN@
418 418
 LTLIBBZ2 = @LTLIBBZ2@
419 419
 LTLIBOBJS = @LTLIBOBJS@
420
-LT_ARGZ_H = @LT_ARGZ_H@
421 420
 LT_CONFIG_H = @LT_CONFIG_H@
422 421
 LT_DLLOADERS = @LT_DLLOADERS@
423 422
 LT_DLPREOPEN = @LT_DLPREOPEN@
424
-LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
425 423
 MAINT = @MAINT@
426 424
 MAKEINFO = @MAKEINFO@
427 425
 MANIFEST_TOOL = @MANIFEST_TOOL@
... ...
@@ -562,7 +564,11 @@ top_srcdir = @top_srcdir@
562 562
 @BUILD_CLAMD_TRUE@	./misc/onaccess_others.c \
563 563
 @BUILD_CLAMD_TRUE@	./misc/onaccess_others.h ./misc/priv_fts.h \
564 564
 @BUILD_CLAMD_TRUE@	./scan/onaccess_scth.c \
565
-@BUILD_CLAMD_TRUE@	./scan/onaccess_scth.h $(am__append_1)
565
+@BUILD_CLAMD_TRUE@	./scan/onaccess_scth.h \
566
+@BUILD_CLAMD_TRUE@	./scan/onaccess_scque.c \
567
+@BUILD_CLAMD_TRUE@	./scan/onaccess_scque.h \
568
+@BUILD_CLAMD_TRUE@	./c-thread-pool/thpool.c \
569
+@BUILD_CLAMD_TRUE@	./c-thread-pool/thpool.h $(am__append_1)
566 570
 @BUILD_CLAMD_TRUE@AM_CFLAGS = @WERR_CFLAGS@
567 571
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamd -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CURL_CPPFLAGS@ @SSL_CPPFLAGS@ @CLAMONACC_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
568 572
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamonacc$(EXEEXT)
... ...
@@ -689,9 +695,11 @@ distclean-compile:
689 689
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-onaccess_hash.Po@am__quote@
690 690
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-onaccess_others.Po@am__quote@
691 691
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-onaccess_proto.Po@am__quote@
692
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-onaccess_scque.Po@am__quote@
692 693
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-onaccess_scth.Po@am__quote@
693 694
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-optparser.Po@am__quote@
694 695
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-output.Po@am__quote@
696
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamonacc-thpool.Po@am__quote@
695 697
 
696 698
 .c.o:
697 699
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
... ...
@@ -910,6 +918,34 @@ clamonacc-onaccess_scth.obj: ./scan/onaccess_scth.c
910 910
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
911 911
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -c -o clamonacc-onaccess_scth.obj `if test -f './scan/onaccess_scth.c'; then $(CYGPATH_W) './scan/onaccess_scth.c'; else $(CYGPATH_W) '$(srcdir)/./scan/onaccess_scth.c'; fi`
912 912
 
913
+clamonacc-onaccess_scque.o: ./scan/onaccess_scque.c
914
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -MT clamonacc-onaccess_scque.o -MD -MP -MF $(DEPDIR)/clamonacc-onaccess_scque.Tpo -c -o clamonacc-onaccess_scque.o `test -f './scan/onaccess_scque.c' || echo '$(srcdir)/'`./scan/onaccess_scque.c
915
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/clamonacc-onaccess_scque.Tpo $(DEPDIR)/clamonacc-onaccess_scque.Po
916
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='./scan/onaccess_scque.c' object='clamonacc-onaccess_scque.o' libtool=no @AMDEPBACKSLASH@
917
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
918
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -c -o clamonacc-onaccess_scque.o `test -f './scan/onaccess_scque.c' || echo '$(srcdir)/'`./scan/onaccess_scque.c
919
+
920
+clamonacc-onaccess_scque.obj: ./scan/onaccess_scque.c
921
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -MT clamonacc-onaccess_scque.obj -MD -MP -MF $(DEPDIR)/clamonacc-onaccess_scque.Tpo -c -o clamonacc-onaccess_scque.obj `if test -f './scan/onaccess_scque.c'; then $(CYGPATH_W) './scan/onaccess_scque.c'; else $(CYGPATH_W) '$(srcdir)/./scan/onaccess_scque.c'; fi`
922
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/clamonacc-onaccess_scque.Tpo $(DEPDIR)/clamonacc-onaccess_scque.Po
923
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='./scan/onaccess_scque.c' object='clamonacc-onaccess_scque.obj' libtool=no @AMDEPBACKSLASH@
924
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
925
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -c -o clamonacc-onaccess_scque.obj `if test -f './scan/onaccess_scque.c'; then $(CYGPATH_W) './scan/onaccess_scque.c'; else $(CYGPATH_W) '$(srcdir)/./scan/onaccess_scque.c'; fi`
926
+
927
+clamonacc-thpool.o: ./c-thread-pool/thpool.c
928
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -MT clamonacc-thpool.o -MD -MP -MF $(DEPDIR)/clamonacc-thpool.Tpo -c -o clamonacc-thpool.o `test -f './c-thread-pool/thpool.c' || echo '$(srcdir)/'`./c-thread-pool/thpool.c
929
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/clamonacc-thpool.Tpo $(DEPDIR)/clamonacc-thpool.Po
930
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='./c-thread-pool/thpool.c' object='clamonacc-thpool.o' libtool=no @AMDEPBACKSLASH@
931
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
932
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -c -o clamonacc-thpool.o `test -f './c-thread-pool/thpool.c' || echo '$(srcdir)/'`./c-thread-pool/thpool.c
933
+
934
+clamonacc-thpool.obj: ./c-thread-pool/thpool.c
935
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -MT clamonacc-thpool.obj -MD -MP -MF $(DEPDIR)/clamonacc-thpool.Tpo -c -o clamonacc-thpool.obj `if test -f './c-thread-pool/thpool.c'; then $(CYGPATH_W) './c-thread-pool/thpool.c'; else $(CYGPATH_W) '$(srcdir)/./c-thread-pool/thpool.c'; fi`
936
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/clamonacc-thpool.Tpo $(DEPDIR)/clamonacc-thpool.Po
937
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='./c-thread-pool/thpool.c' object='clamonacc-thpool.obj' libtool=no @AMDEPBACKSLASH@
938
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
939
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -c -o clamonacc-thpool.obj `if test -f './c-thread-pool/thpool.c'; then $(CYGPATH_W) './c-thread-pool/thpool.c'; else $(CYGPATH_W) '$(srcdir)/./c-thread-pool/thpool.c'; fi`
940
+
913 941
 clamonacc-fts.o: ./misc/fts.c
914 942
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(clamonacc_CPPFLAGS) $(CPPFLAGS) $(clamonacc_CFLAGS) $(CFLAGS) -MT clamonacc-fts.o -MD -MP -MF $(DEPDIR)/clamonacc-fts.Tpo -c -o clamonacc-fts.o `test -f './misc/fts.c' || echo '$(srcdir)/'`./misc/fts.c
915 943
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/clamonacc-fts.Tpo $(DEPDIR)/clamonacc-fts.Po
... ...
@@ -51,6 +51,7 @@
51 51
 
52 52
 
53 53
 pthread_t ddd_pid = 0;
54
+pthread_t scque_pid = 0;
54 55
 
55 56
 int main(int argc, char **argv)
56 57
 {
... ...
@@ -58,6 +58,8 @@ struct onas_context {
58 58
 	int timeout;
59 59
 
60 60
         int64_t portnum;
61
+
62
+        int32_t maxthreads;
61 63
 } __attribute__((packed));
62 64
 
63 65
 #ifdef HAVE_PRAGMA_PACK
... ...
@@ -33,87 +33,76 @@
33 33
 #include <signal.h>
34 34
 #include <pthread.h>
35 35
 #include <string.h>
36
-#include <errno.h>
37
-#include <stdbool.h>
38 36
 
39
-#include <sys/fanotify.h>
40
-#include <sys/inotify.h>
41
-
42
-#include "../fanotif/onaccess_fan.h"
43
-#include "onaccess_hash.h"
44
-#include "onaccess_ddd.h"
45
-#include "../scan/onaccess_scth.h"
46 37
 #include "../misc/onaccess_others.h"
47 38
 
48 39
 #include "libclamav/clamav.h"
49
-#include "libclamav/scanners.h"
50 40
 
51 41
 #include "shared/optparser.h"
52 42
 #include "shared/output.h"
53 43
 
54
-#include "clamd/server.h"
55
-#include "clamd/others.h"
56
-#include "clamd/scanner.h"
57
-
58 44
 #include "../c-thread-pool/thpool.h"
59 45
 
46
+#include "onaccess_scth.h"
47
+#include "onaccess_scque.h"
48
+
60 49
 static void onas_scanque_exit(int sig);
61
-static int onas_consume_event(struct *event_data);
50
+static int onas_consume_event(threadpool thpool);
51
+static cl_error_t onas_new_event_queue_node(struct onas_event_queue_node **node);
52
+static void onas_destroy_event_queue_node(struct onas_event_queue_node *node);
62 53
 
63 54
 static pthread_mutex_t onas_queue_lock = PTHREAD_MUTEX_INITIALIZER;
55
+extern pthread_t scque_pid;
64 56
 
65 57
 static threadpool g_thpool;
66 58
 
67 59
 static struct onas_event_queue_node *g_onas_event_queue_head = NULL;
68 60
 static struct onas_event_queue_node *g_onas_event_queue_tail = NULL;
69 61
 
70
-static struct onas_event_queue g_onas_event_queue = {
71
-    head = g_onas_event_queue_head,
72
-    tail = g_onas_event_queue_tail,
62
+static struct onas_event_queue g_onas_event_queue;
73 63
 
74
-    size = 0;
75
-};
64
+static cl_error_t onas_new_event_queue_node(struct onas_event_queue_node **node) {
76 65
 
77
-static void *onas_init_event_queue() {
78
-    *g_onas_event_queue_head = (struct event_queue_node) {
79
-        .next = NULL,
80
-            .prev = NULL,
66
+	*node = malloc(sizeof(struct onas_event_queue_node));
67
+	if (NULL == *node) {
68
+		return CL_EMEM;
69
+	}
81 70
 
82
-            .data = NULL
83
-    };
84 71
 
85
-    *g_onas_event_queue_tail = &(struct event_queue_node) {
86
-        .next = NULL,
87
-            .prev = NULL,
72
+	**node = (struct onas_event_queue_node) {
73
+		.next = NULL,
74
+		.prev = NULL,
88 75
 
89
-            .data = NULL
90
-    };
76
+		.data = NULL
77
+	};
91 78
 
92
-    g_onas_event_queue_tail->prev = g_onas_event_queue_head;
93
-    g_onas_event_queue_head->next = g_onas_event_queue_tail;
79
+	return CL_SUCCESS;
94 80
 }
95 81
 
96
-extern pthread_t scque_pid;
82
+static void *onas_init_event_queue() {
97 83
 
98
-static cl_error_t onas_new_event_queue_node(struct event_queue_node **node) {
84
+	if (CL_EMEM == onas_new_event_queue_node(&g_onas_event_queue_head)) {
85
+		return NULL;
86
+	}
99 87
 
100
-	*node = malloc(sizeof(struct onas_event_queue));
101
-	if (NULL == *node) {
102
-		return CL_EMEM;
88
+	if (CL_EMEM == onas_new_event_queue_node(&g_onas_event_queue_tail)) {
89
+		return NULL;
103 90
 	}
104 91
 
92
+	g_onas_event_queue_tail->prev = g_onas_event_queue_head;
93
+	g_onas_event_queue_head->next = g_onas_event_queue_tail;
105 94
 
106
-	**node = (struct event_queue_node) {
107
-		.next = NULL,
108
-		.prev = NULL,
95
+	g_onas_event_queue = (struct onas_event_queue)  {
96
+		.head = g_onas_event_queue_head,
97
+		.tail = g_onas_event_queue_tail,
109 98
 
110
-		.data = NULL
99
+		.size = 0
111 100
 	};
112 101
 
113
-	return CL_SUCCESS;
102
+	return &g_onas_event_queue;
114 103
 }
115 104
 
116
-static void onas_destroy_event_queue_node(struct event_queue_node *node) {
105
+static void onas_destroy_event_queue_node(struct onas_event_queue_node *node) {
117 106
 
118 107
 	if (NULL == node) {
119 108
 		return;
... ...
@@ -188,12 +177,11 @@ void *onas_scanque_th(void *arg) {
188 188
 		}
189 189
 	} while(1);
190 190
 
191
-	return;
192 191
 }
193 192
 
194 193
 static int onas_queue_is_b_empty() {
195 194
 
196
-    if (g_onas_event_queue->head->next == g_onas_event_queue->tail) {
195
+    if (g_onas_event_queue.head->next == g_onas_event_queue.tail) {
197 196
         return 1;
198 197
     }
199 198
 
... ...
@@ -214,11 +202,11 @@ static int onas_consume_event(threadpool thpool) {
214 214
     thpool_add_work(thpool, (void *) onas_scan_worker, (void *) popped_node->data);
215 215
 
216 216
     g_onas_event_queue_head->next = g_onas_event_queue_head->next->next;
217
-    g_onas_event_queue_head->next->prev = g_onas_event_head;
217
+    g_onas_event_queue_head->next->prev = g_onas_event_queue_head;
218 218
 
219 219
     onas_destroy_event_queue_node(popped_node);
220 220
 
221
-    g_onas_event_queue->size--;
221
+    g_onas_event_queue.size--;
222 222
 
223 223
     pthread_mutex_unlock(&onas_queue_lock);
224 224
     return 0;
... ...
@@ -243,7 +231,7 @@ cl_error_t onas_queue_event(struct onas_scan_event *event_data) {
243 243
     ((struct onas_event_queue_node *) g_onas_event_queue_tail->prev)->next = node;
244 244
     g_onas_event_queue_tail->prev = node;
245 245
 
246
-    g_onas_event_queue->size++;
246
+    g_onas_event_queue.size++;
247 247
 
248 248
     pthread_mutex_unlock(&onas_queue_lock);
249 249