1 /**
2 * collectd - src/email.c
3 * Copyright (C) 2006 Sebastian Harl
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Author:
20 * Sebastian Harl <sh at tokkee.org>
21 **/
23 /*
24 * This plugin communicates with a spam filter, a virus scanner or similar
25 * software using a UNIX socket and a very simple protocol:
26 *
27 * e-mail type (e.g. ham, spam, virus, ...) and size
28 * e:<type>:<bytes>
29 *
30 * spam score
31 * s:<value>
32 *
33 * successful spam checks
34 * c:<type1>[,<type2>,...]
35 */
37 #include "collectd.h"
38 #include "common.h"
39 #include "plugin.h"
41 #include "configfile.h"
43 #if HAVE_LIBPTHREAD
44 # include <pthread.h>
45 # define EMAIL_HAVE_READ 1
46 #else
47 # define EMAIL_HAVE_READ 0
48 #endif
50 #if HAVE_SYS_SELECT_H
51 # include <sys/select.h>
52 #endif /* HAVE_SYS_SELECT_H */
54 #if HAVE_SYS_SOCKET_H
55 # include <sys/socket.h>
56 #endif /* HAVE_SYS_SOCKET_H */
58 /* *sigh* glibc does not define UNIX_PATH_MAX in sys/un.h ... */
59 #if HAVE_LINUX_UN_H
60 # include <linux/un.h>
61 #elif HAVE_SYS_UN_H
62 # include <sys/un.h>
63 #endif /* HAVE_LINUX_UN_H | HAVE_SYS_UN_H */
65 /* some systems (e.g. Darwin) seem to not define UNIX_PATH_MAX at all */
66 #ifndef UNIX_PATH_MAX
67 # define UNIX_PATH_MAX sizeof (((struct sockaddr_un *)0)->sun_path)
68 #endif /* UNIX_PATH_MAX */
70 #if HAVE_GRP_H
71 # include <grp.h>
72 #endif /* HAVE_GRP_H */
74 #define MODULE_NAME "email"
76 /* 256 bytes ought to be enough for anybody ;-) */
77 #define BUFSIZE 256
79 #ifndef COLLECTD_SOCKET_PREFIX
80 # define COLLECTD_SOCKET_PREFIX "/tmp/.collectd-"
81 #endif /* COLLECTD_SOCKET_PREFIX */
83 #define SOCK_PATH COLLECTD_SOCKET_PREFIX"email"
84 #define MAX_CONNS 5
85 #define MAX_CONNS_LIMIT 16384
87 /*
88 * Private data structures
89 */
90 #if EMAIL_HAVE_READ
91 /* linked list of email and check types */
92 typedef struct type {
93 char *name;
94 int value;
95 struct type *next;
96 } type_t;
98 typedef struct {
99 type_t *head;
100 type_t *tail;
101 } type_list_t;
103 /* collector thread control information */
104 typedef struct collector {
105 pthread_t thread;
107 /* socket descriptor of the current/last connection */
108 int socket;
109 } collector_t;
111 /* linked list of pending connections */
112 typedef struct conn {
113 /* socket to read data from */
114 int socket;
116 /* buffer to read data to */
117 char *buffer;
118 int idx; /* current write position in buffer */
119 int length; /* length of the current line, i.e. index of '\0' */
121 struct conn *next;
122 } conn_t;
124 typedef struct {
125 conn_t *head;
126 conn_t *tail;
127 } conn_list_t;
128 #endif /* EMAIL_HAVE_READ */
130 /*
131 * Private variables
132 */
133 #if EMAIL_HAVE_READ
134 /* valid configuration file keys */
135 static char *config_keys[] =
136 {
137 "SocketGroup",
138 "SocketPerms",
139 "MaxConns",
140 NULL
141 };
142 static int config_keys_num = 3;
144 /* socket configuration */
145 static char *sock_group = COLLECTD_GRP_NAME;
146 static int sock_perms = S_IRWXU | S_IRWXG;
147 static int max_conns = MAX_CONNS;
149 /* state of the plugin */
150 static int disabled = 0;
152 /* thread managing "client" connections */
153 static pthread_t connector;
154 static int connector_socket;
156 /* tell the collector threads that a new connection is available */
157 static pthread_cond_t conn_available = PTHREAD_COND_INITIALIZER;
159 /* connections that are waiting to be processed */
160 static pthread_mutex_t conns_mutex = PTHREAD_MUTEX_INITIALIZER;
161 static conn_list_t conns;
163 /* tell the connector thread that a collector is available */
164 static pthread_cond_t collector_available = PTHREAD_COND_INITIALIZER;
166 /* collector threads */
167 static collector_t **collectors;
169 static pthread_mutex_t available_mutex = PTHREAD_MUTEX_INITIALIZER;
170 static int available_collectors;
172 static pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
173 static type_list_t count;
175 static pthread_mutex_t size_mutex = PTHREAD_MUTEX_INITIALIZER;
176 static type_list_t size;
178 static pthread_mutex_t score_mutex = PTHREAD_MUTEX_INITIALIZER;
179 static double score;
180 static int score_count;
182 static pthread_mutex_t check_mutex = PTHREAD_MUTEX_INITIALIZER;
183 static type_list_t check;
184 #endif /* EMAIL_HAVE_READ */
186 #define COUNT_FILE "email/email-%s.rrd"
187 static char *count_ds_def[] =
188 {
189 "DS:count:GAUGE:"COLLECTD_HEARTBEAT":0:U",
190 NULL
191 };
192 static int count_ds_num = 1;
194 #define SIZE_FILE "email/email_size-%s.rrd"
195 static char *size_ds_def[] =
196 {
197 "DS:size:GAUGE:"COLLECTD_HEARTBEAT":0:U",
198 NULL
199 };
200 static int size_ds_num = 1;
202 #define SCORE_FILE "email/spam_score.rrd"
203 static char *score_ds_def[] =
204 {
205 "DS:score:GAUGE:"COLLECTD_HEARTBEAT":U:U",
206 NULL
207 };
208 static int score_ds_num = 1;
210 #define CHECK_FILE "email/spam_check-%s.rrd"
211 static char *check_ds_def[] =
212 {
213 "DS:hits:GAUGE:"COLLECTD_HEARTBEAT":0:U",
214 NULL
215 };
216 static int check_ds_num = 1;
218 #if EMAIL_HAVE_READ
219 static int email_config (char *key, char *value)
220 {
221 if (0 == strcasecmp (key, "SocketGroup")) {
222 sock_group = sstrdup (value);
223 }
224 else if (0 == strcasecmp (key, "SocketPerms")) {
225 /* the user is responsible for providing reasonable values */
226 sock_perms = (int)strtol (value, NULL, 8);
227 }
228 else if (0 == strcasecmp (key, "MaxConns")) {
229 long int tmp = strtol (value, NULL, 0);
231 if (tmp < 1) {
232 fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
233 "value %li, will use default %i.\n",
234 tmp, MAX_CONNS);
235 max_conns = MAX_CONNS;
236 }
237 else if (tmp > MAX_CONNS_LIMIT) {
238 fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
239 "value %li, will use hardcoded limit %i.\n",
240 tmp, MAX_CONNS_LIMIT);
241 max_conns = MAX_CONNS_LIMIT;
242 }
243 else {
244 max_conns = (int)tmp;
245 }
246 }
247 else {
248 return -1;
249 }
250 return 0;
251 } /* static int email_config (char *, char *) */
253 /* Increment the value of the given name in the given list by incr. */
254 static void type_list_incr (type_list_t *list, char *name, int incr)
255 {
256 if (NULL == list->head) {
257 list->head = (type_t *)smalloc (sizeof (type_t));
259 list->head->name = sstrdup (name);
260 list->head->value = incr;
261 list->head->next = NULL;
263 list->tail = list->head;
264 }
265 else {
266 type_t *ptr;
268 for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
269 if (0 == strcmp (name, ptr->name))
270 break;
271 }
273 if (NULL == ptr) {
274 list->tail->next = (type_t *)smalloc (sizeof (type_t));
275 list->tail = list->tail->next;
277 list->tail->name = sstrdup (name);
278 list->tail->value = incr;
279 list->tail->next = NULL;
280 }
281 else {
282 ptr->value += incr;
283 }
284 }
285 return;
286 } /* static void type_list_incr (type_list_t *, char *) */
288 /* Read a single character from the socket. If an error occurs or end-of-file
289 * is reached return '\0'. */
290 char read_char (conn_t *src)
291 {
292 char ret = '\0';
294 fd_set fdset;
296 FD_ZERO (&fdset);
297 FD_SET (src->socket, &fdset);
299 if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
300 syslog (LOG_ERR, "select() failed: %s", strerror (errno));
301 return '\0';
302 }
304 assert (FD_ISSET (src->socket, &fdset));
306 do {
307 ssize_t len = 0;
309 errno = 0;
310 if (0 > (len = read (src->socket, (void *)&ret, 1))) {
311 if (EINTR != errno) {
312 syslog (LOG_ERR, "read() failed: %s", strerror (errno));
313 return '\0';
314 }
315 }
317 if (0 == len)
318 return '\0';
319 } while (EINTR == errno);
320 return ret;
321 } /* char read_char (conn_t *) */
323 /* Read a single line (terminated by '\n') from the the socket.
324 *
325 * The return value is zero terminated and does not contain any newline
326 * characters.
327 *
328 * If an error occurs or end-of-file is reached return NULL.
329 *
330 * IMPORTANT NOTE: If there is no newline character found in BUFSIZE
331 * characters of the input stream, the line will will be ignored! By
332 * definition we should not get any longer input lines, thus this is
333 * acceptable in this case ;-) */
334 char *read_line (conn_t *src)
335 {
336 int i = 0;
338 assert ((BUFSIZE >= src->idx) && (src->idx >= 0));
339 assert ((src->idx > src->length) || (src->length == 0));
341 if (src->length > 0) { /* remove old line */
342 src->idx -= (src->length + 1);
343 memmove (src->buffer, src->buffer + src->length + 1, src->idx);
344 src->length = 0;
345 }
347 for (i = 0; i < src->idx; ++i) {
348 if ('\n' == src->buffer[i])
349 break;
350 }
352 if (i == src->idx) {
353 fd_set fdset;
355 ssize_t len = 0;
357 FD_ZERO (&fdset);
358 FD_SET (src->socket, &fdset);
360 if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
361 syslog (LOG_ERR, "select() failed: %s", strerror (errno));
362 return NULL;
363 }
365 assert (FD_ISSET (src->socket, &fdset));
367 do {
368 errno = 0;
369 if (0 > (len = read (src->socket,
370 (void *)(src->buffer + src->idx),
371 BUFSIZE - src->idx))) {
372 if (EINTR != errno) {
373 syslog (LOG_ERR, "read() failed: %s", strerror (errno));
374 return NULL;
375 }
376 }
378 if (0 == len)
379 return NULL;
380 } while (EINTR == errno);
382 src->idx += len;
384 for (i = src->idx - len; i < src->idx; ++i) {
385 if ('\n' == src->buffer[i])
386 break;
387 }
389 if (i == src->idx) {
390 src->length = 0;
392 if (BUFSIZE == src->idx) { /* no space left in buffer */
393 while ('\n' != read_char (src))
394 /* ignore complete line */;
396 src->idx = 0;
397 }
398 return read_line (src);
399 }
400 }
402 src->buffer[i] = '\0';
403 src->length = i;
405 return src->buffer;
406 } /* char *read_line (conn_t *) */
408 static void *collect (void *arg)
409 {
410 collector_t *this = (collector_t *)arg;
412 char *buffer = (char *)smalloc (BUFSIZE);
414 while (1) {
415 int loop = 1;
417 conn_t *connection;
419 pthread_mutex_lock (&conns_mutex);
421 while (NULL == conns.head) {
422 pthread_cond_wait (&conn_available, &conns_mutex);
423 }
425 connection = conns.head;
426 conns.head = conns.head->next;
428 if (NULL == conns.head) {
429 conns.tail = NULL;
430 }
432 this->socket = connection->socket;
434 pthread_mutex_unlock (&conns_mutex);
436 connection->buffer = buffer;
437 connection->idx = 0;
438 connection->length = 0;
440 { /* put the socket in non-blocking mode */
441 int flags = 0;
443 errno = 0;
444 if (-1 == fcntl (connection->socket, F_GETFL, &flags)) {
445 syslog (LOG_ERR, "fcntl() failed: %s", strerror (errno));
446 loop = 0;
447 }
449 errno = 0;
450 if (-1 == fcntl (connection->socket, F_SETFL, flags | O_NONBLOCK)) {
451 syslog (LOG_ERR, "fcntl() failed: %s", strerror (errno));
452 loop = 0;
453 }
454 }
456 while (loop) {
457 char *line = read_line (connection);
459 if (NULL == line) {
460 loop = 0;
461 break;
462 }
464 if (':' != line[1]) {
465 syslog (LOG_ERR, "email: syntax error in line '%s'", line);
466 continue;
467 }
469 if ('e' == line[0]) { /* e:<type>:<bytes> */
470 char *ptr = NULL;
471 char *type = strtok_r (line + 2, ":", &ptr);
472 char *tmp = strtok_r (NULL, ":", &ptr);
473 int bytes = 0;
475 if (NULL == tmp) {
476 syslog (LOG_ERR, "email: syntax error in line '%s'", line);
477 continue;
478 }
480 bytes = atoi (tmp);
482 pthread_mutex_lock (&count_mutex);
483 type_list_incr (&count, type, 1);
484 pthread_mutex_unlock (&count_mutex);
486 pthread_mutex_lock (&size_mutex);
487 type_list_incr (&size, type, bytes);
488 pthread_mutex_unlock (&size_mutex);
489 }
490 else if ('s' == line[0]) { /* s:<value> */
491 pthread_mutex_lock (&score_mutex);
492 score = (score * (double)score_count + atof (line + 2))
493 / (double)(score_count + 1);
494 ++score_count;
495 pthread_mutex_unlock (&score_mutex);
496 }
497 else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
498 char *ptr = NULL;
499 char *type = strtok_r (line + 2, ",", &ptr);
501 do {
502 pthread_mutex_lock (&check_mutex);
503 type_list_incr (&check, type, 1);
504 pthread_mutex_unlock (&check_mutex);
505 } while (NULL != (type = strtok_r (NULL, ",", &ptr)));
506 }
507 else {
508 syslog (LOG_ERR, "email: unknown type '%c'", line[0]);
509 }
510 } /* while (loop) */
512 close (connection->socket);
514 free (connection);
516 pthread_mutex_lock (&available_mutex);
517 ++available_collectors;
518 pthread_mutex_unlock (&available_mutex);
520 pthread_cond_signal (&collector_available);
521 } /* while (1) */
523 free (buffer);
524 pthread_exit ((void *)0);
525 } /* void *collect (void *) */
527 static void *open_connection (void *arg)
528 {
529 struct sockaddr_un addr;
531 /* create UNIX socket */
532 errno = 0;
533 if (-1 == (connector_socket = socket (PF_UNIX, SOCK_STREAM, 0))) {
534 disabled = 1;
535 syslog (LOG_ERR, "socket() failed: %s", strerror (errno));
536 pthread_exit ((void *)1);
537 }
539 addr.sun_family = AF_UNIX;
541 strncpy (addr.sun_path, SOCK_PATH, (size_t)(UNIX_PATH_MAX - 1));
542 addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
543 unlink (addr.sun_path);
545 errno = 0;
546 if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
547 offsetof (struct sockaddr_un, sun_path)
548 + strlen(addr.sun_path))) {
549 disabled = 1;
550 syslog (LOG_ERR, "bind() failed: %s", strerror (errno));
551 pthread_exit ((void *)1);
552 }
554 errno = 0;
555 if (-1 == listen (connector_socket, 5)) {
556 disabled = 1;
557 syslog (LOG_ERR, "listen() failed: %s", strerror (errno));
558 pthread_exit ((void *)1);
559 }
561 if ((uid_t)0 == geteuid ()) {
562 struct group *grp;
564 errno = 0;
565 if (NULL != (grp = getgrnam (sock_group))) {
566 errno = 0;
567 if (0 != chown (SOCK_PATH, (uid_t)-1, grp->gr_gid)) {
568 syslog (LOG_WARNING, "chown() failed: %s", strerror (errno));
569 }
570 }
571 else {
572 syslog (LOG_WARNING, "getgrnam() failed: %s", strerror (errno));
573 }
574 }
575 else {
576 syslog (LOG_WARNING, "not running as root");
577 }
579 errno = 0;
580 if (0 != chmod (SOCK_PATH, sock_perms)) {
581 syslog (LOG_WARNING, "chmod() failed: %s", strerror (errno));
582 }
584 { /* initialize collector threads */
585 int i = 0;
586 int err = 0;
588 pthread_attr_t ptattr;
590 conns.head = NULL;
591 conns.tail = NULL;
593 pthread_attr_init (&ptattr);
594 pthread_attr_setdetachstate (&ptattr, PTHREAD_CREATE_DETACHED);
596 available_collectors = max_conns;
598 collectors =
599 (collector_t **)smalloc (max_conns * sizeof (collector_t *));
601 for (i = 0; i < max_conns; ++i) {
602 collectors[i] = (collector_t *)smalloc (sizeof (collector_t));
603 collectors[i]->socket = 0;
605 if (0 != (err = pthread_create (&collectors[i]->thread, &ptattr,
606 collect, collectors[i]))) {
607 syslog (LOG_ERR, "pthread_create() failed: %s",
608 strerror (err));
609 }
610 }
612 pthread_attr_destroy (&ptattr);
613 }
615 while (1) {
616 int remote = 0;
618 conn_t *connection;
620 pthread_mutex_lock (&available_mutex);
622 while (0 == available_collectors) {
623 pthread_cond_wait (&collector_available, &available_mutex);
624 }
626 --available_collectors;
628 pthread_mutex_unlock (&available_mutex);
630 do {
631 errno = 0;
632 if (-1 == (remote = accept (connector_socket, NULL, NULL))) {
633 if (EINTR != errno) {
634 disabled = 1;
635 syslog (LOG_ERR, "accept() failed: %s", strerror (errno));
636 pthread_exit ((void *)1);
637 }
638 }
639 } while (EINTR == errno);
641 connection = (conn_t *)smalloc (sizeof (conn_t));
643 connection->socket = remote;
644 connection->next = NULL;
646 pthread_mutex_lock (&conns_mutex);
648 if (NULL == conns.head) {
649 conns.head = connection;
650 conns.tail = connection;
651 }
652 else {
653 conns.tail->next = connection;
654 conns.tail = conns.tail->next;
655 }
657 pthread_mutex_unlock (&conns_mutex);
659 pthread_cond_signal (&conn_available);
660 }
661 pthread_exit ((void *)0);
662 } /* void *open_connection (void *) */
663 #endif /* EMAIL_HAVE_READ */
665 static void email_init (void)
666 {
667 #if EMAIL_HAVE_READ
668 int err = 0;
670 if (0 != (err = pthread_create (&connector, NULL,
671 open_connection, NULL))) {
672 disabled = 1;
673 syslog (LOG_ERR, "pthread_create() failed: %s", strerror (err));
674 return;
675 }
676 #endif /* EMAIL_HAVE_READ */
677 return;
678 } /* static void email_init (void) */
680 #if EMAIL_HAVE_READ
681 static void email_shutdown (void)
682 {
683 int i = 0;
685 if (disabled)
686 return;
688 close (connector_socket);
689 pthread_kill (connector, SIGTERM);
691 /* don't allow any more connections to be processed */
692 pthread_mutex_lock (&conns_mutex);
694 for (i = 0; i < max_conns; ++i) {
695 close (collectors[i]->socket);
696 pthread_kill (collectors[i]->thread, SIGTERM);
697 }
699 pthread_mutex_unlock (&conns_mutex);
701 unlink (SOCK_PATH);
702 return;
703 } /* static void email_shutdown (void) */
704 #endif /* EMAIL_HAVE_READ */
706 static void count_write (char *host, char *inst, char *val)
707 {
708 char file[BUFSIZE] = "";
709 int len = 0;
711 len = snprintf (file, BUFSIZE, COUNT_FILE, inst);
712 if ((len < 0) || (len >= BUFSIZE))
713 return;
715 rrd_update_file (host, file, val, count_ds_def, count_ds_num);
716 return;
717 } /* static void email_write (char *host, char *inst, char *val) */
719 static void size_write (char *host, char *inst, char *val)
720 {
721 char file[BUFSIZE] = "";
722 int len = 0;
724 len = snprintf (file, BUFSIZE, SIZE_FILE, inst);
725 if ((len < 0) || (len >= BUFSIZE))
726 return;
728 rrd_update_file (host, file, val, size_ds_def, size_ds_num);
729 return;
730 } /* static void size_write (char *host, char *inst, char *val) */
732 static void score_write (char *host, char *inst, char *val)
733 {
734 rrd_update_file (host, SCORE_FILE, val, score_ds_def, score_ds_num);
735 return;
736 } /* static void score_write (char *host, char *inst, char *val) */
738 static void check_write (char *host, char *inst, char *val)
739 {
740 char file[BUFSIZE] = "";
741 int len = 0;
743 len = snprintf (file, BUFSIZE, CHECK_FILE, inst);
744 if ((len < 0) || (len >= BUFSIZE))
745 return;
747 rrd_update_file (host, file, val, check_ds_def, check_ds_num);
748 return;
749 } /* static void check_write (char *host, char *inst, char *val) */
751 #if EMAIL_HAVE_READ
752 static void type_submit (char *plugin, char *inst, int value)
753 {
754 char buf[BUFSIZE] = "";
755 int len = 0;
757 if (0 == value)
758 return;
760 len = snprintf (buf, BUFSIZE, "%u:%i", (unsigned int)curtime, value);
761 if ((len < 0) || (len >= BUFSIZE))
762 return;
764 plugin_submit (plugin, inst, buf);
765 return;
766 } /* static void type_submit (char *, char *, int) */
768 static void score_submit (double value)
769 {
770 char buf[BUFSIZE] = "";
771 int len = 0;
773 if (0.0 == value)
774 return;
776 len = snprintf (buf, BUFSIZE, "%u:%.2f", (unsigned int)curtime, value);
777 if ((len < 0) || (len >= BUFSIZE))
778 return;
780 plugin_submit ("email_spam_score", NULL, buf);
781 return;
782 }
784 static void email_read (void)
785 {
786 type_t *ptr;
788 if (disabled)
789 return;
791 pthread_mutex_lock (&count_mutex);
793 for (ptr = count.head; NULL != ptr; ptr = ptr->next) {
794 type_submit ("email_count", ptr->name, ptr->value);
795 ptr->value = 0;
796 }
798 pthread_mutex_unlock (&count_mutex);
800 pthread_mutex_lock (&size_mutex);
802 for (ptr = size.head; NULL != ptr; ptr = ptr->next) {
803 type_submit ("email_size", ptr->name, ptr->value);
804 ptr->value = 0;
805 }
807 pthread_mutex_unlock (&size_mutex);
809 pthread_mutex_lock (&score_mutex);
811 score_submit (score);
812 score = 0.0;
813 score_count = 0;
815 pthread_mutex_unlock (&score_mutex);
817 pthread_mutex_lock (&check_mutex);
819 for (ptr = check.head; NULL != ptr; ptr = ptr->next) {
820 type_submit ("email_spam_check", ptr->name, ptr->value);
821 ptr->value = 0;
822 }
824 pthread_mutex_unlock (&check_mutex);
825 return;
826 } /* static void read (void) */
827 #else /* if !EMAIL_HAVE_READ */
828 # define email_read NULL
829 #endif
831 void module_register (void)
832 {
833 plugin_register (MODULE_NAME, email_init, email_read, NULL);
834 plugin_register ("email_count", NULL, NULL, count_write);
835 plugin_register ("email_size", NULL, NULL, size_write);
836 plugin_register ("email_spam_score", NULL, NULL, score_write);
837 plugin_register ("email_spam_check", NULL, NULL, check_write);
838 #if EMAIL_HAVE_READ
839 plugin_register_shutdown (MODULE_NAME, email_shutdown);
840 cf_register (MODULE_NAME, email_config, config_keys, config_keys_num);
841 #endif /* EMAIL_HAVE_READ */
842 return;
843 } /* void module_register (void) */
845 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */