Merge pull request #1490 from rubenk/uuid
[collectd.git] / src / email.c
1 /**
2  * collectd - src/email.c
3  * Copyright (C) 2006-2008  Sebastian Harl
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Sebastian Harl <sh at tokkee.org>
25  **/
26
27 /*
28  * This plugin communicates with a spam filter, a virus scanner or similar
29  * software using a UNIX socket and a very simple protocol:
30  *
31  * e-mail type (e.g. ham, spam, virus, ...) and size
32  * e:<type>:<bytes>
33  *
34  * spam score
35  * s:<value>
36  *
37  * successful spam checks
38  * c:<type1>[,<type2>,...]
39  */
40
41 #include "collectd.h"
42
43 #include "common.h"
44 #include "plugin.h"
45
46 #include "configfile.h"
47
48 #include <stddef.h>
49
50 #include <sys/un.h>
51 #include <sys/select.h>
52
53 /* some systems (e.g. Darwin) seem to not define UNIX_PATH_MAX at all */
54 #ifndef UNIX_PATH_MAX
55 # define UNIX_PATH_MAX sizeof (((struct sockaddr_un *)0)->sun_path)
56 #endif /* UNIX_PATH_MAX */
57
58 #if HAVE_GRP_H
59 #       include <grp.h>
60 #endif /* HAVE_GRP_H */
61
62 #define SOCK_PATH LOCALSTATEDIR"/run/"PACKAGE_NAME"-email"
63 #define MAX_CONNS 5
64 #define MAX_CONNS_LIMIT 16384
65
66 #define log_debug(...) DEBUG ("email: "__VA_ARGS__)
67 #define log_err(...) ERROR ("email: "__VA_ARGS__)
68 #define log_warn(...) WARNING ("email: "__VA_ARGS__)
69
70 /*
71  * Private data structures
72  */
73 /* linked list of email and check types */
74 typedef struct type {
75         char        *name;
76         int         value;
77         struct type *next;
78 } type_t;
79
80 typedef struct {
81         type_t *head;
82         type_t *tail;
83 } type_list_t;
84
85 /* collector thread control information */
86 typedef struct collector {
87         pthread_t thread;
88
89         /* socket descriptor of the current/last connection */
90         FILE *socket;
91 } collector_t;
92
93 /* linked list of pending connections */
94 typedef struct conn {
95         /* socket to read data from */
96         FILE *socket;
97
98         /* linked list of connections */
99         struct conn *next;
100 } conn_t;
101
102 typedef struct {
103         conn_t *head;
104         conn_t *tail;
105 } conn_list_t;
106
107 /*
108  * Private variables
109  */
110 /* valid configuration file keys */
111 static const char *config_keys[] =
112 {
113         "SocketFile",
114         "SocketGroup",
115         "SocketPerms",
116         "MaxConns"
117 };
118 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
119
120 /* socket configuration */
121 static char *sock_file  = NULL;
122 static char *sock_group = NULL;
123 static int  sock_perms  = S_IRWXU | S_IRWXG;
124 static int  max_conns   = MAX_CONNS;
125
126 /* state of the plugin */
127 static int disabled = 0;
128
129 /* thread managing "client" connections */
130 static pthread_t connector = (pthread_t) 0;
131 static int connector_socket = -1;
132
133 /* tell the collector threads that a new connection is available */
134 static pthread_cond_t conn_available = PTHREAD_COND_INITIALIZER;
135
136 /* connections that are waiting to be processed */
137 static pthread_mutex_t conns_mutex = PTHREAD_MUTEX_INITIALIZER;
138 static conn_list_t conns;
139
140 /* tell the connector thread that a collector is available */
141 static pthread_cond_t collector_available = PTHREAD_COND_INITIALIZER;
142
143 /* collector threads */
144 static collector_t **collectors = NULL;
145
146 static pthread_mutex_t available_mutex = PTHREAD_MUTEX_INITIALIZER;
147 static int available_collectors;
148
149 static pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
150 static type_list_t list_count;
151 static type_list_t list_count_copy;
152
153 static pthread_mutex_t size_mutex = PTHREAD_MUTEX_INITIALIZER;
154 static type_list_t list_size;
155 static type_list_t list_size_copy;
156
157 static pthread_mutex_t score_mutex = PTHREAD_MUTEX_INITIALIZER;
158 static double score;
159 static int score_count;
160
161 static pthread_mutex_t check_mutex = PTHREAD_MUTEX_INITIALIZER;
162 static type_list_t list_check;
163 static type_list_t list_check_copy;
164
165 /*
166  * Private functions
167  */
168 static int email_config (const char *key, const char *value)
169 {
170         if (0 == strcasecmp (key, "SocketFile")) {
171                 if (NULL != sock_file)
172                         free (sock_file);
173                 sock_file = sstrdup (value);
174         }
175         else if (0 == strcasecmp (key, "SocketGroup")) {
176                 if (NULL != sock_group)
177                         free (sock_group);
178                 sock_group = sstrdup (value);
179         }
180         else if (0 == strcasecmp (key, "SocketPerms")) {
181                 /* the user is responsible for providing reasonable values */
182                 sock_perms = (int)strtol (value, NULL, 8);
183         }
184         else if (0 == strcasecmp (key, "MaxConns")) {
185                 long int tmp = strtol (value, NULL, 0);
186
187                 if (tmp < 1) {
188                         fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
189                                         "value %li, will use default %i.\n",
190                                         tmp, MAX_CONNS);
191                         ERROR ("email plugin: `MaxConns' was set to invalid "
192                                         "value %li, will use default %i.\n",
193                                         tmp, MAX_CONNS);
194                         max_conns = MAX_CONNS;
195                 }
196                 else if (tmp > MAX_CONNS_LIMIT) {
197                         fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
198                                         "value %li, will use hardcoded limit %i.\n",
199                                         tmp, MAX_CONNS_LIMIT);
200                         ERROR ("email plugin: `MaxConns' was set to invalid "
201                                         "value %li, will use hardcoded limit %i.\n",
202                                         tmp, MAX_CONNS_LIMIT);
203                         max_conns = MAX_CONNS_LIMIT;
204                 }
205                 else {
206                         max_conns = (int)tmp;
207                 }
208         }
209         else {
210                 return -1;
211         }
212         return 0;
213 } /* static int email_config (char *, char *) */
214
215 /* Increment the value of the given name in the given list by incr. */
216 static void type_list_incr (type_list_t *list, char *name, int incr)
217 {
218         if (NULL == list->head) {
219                 list->head = smalloc (sizeof (*list->head));
220
221                 list->head->name  = sstrdup (name);
222                 list->head->value = incr;
223                 list->head->next  = NULL;
224
225                 list->tail = list->head;
226         }
227         else {
228                 type_t *ptr;
229
230                 for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
231                         if (0 == strcmp (name, ptr->name))
232                                 break;
233                 }
234
235                 if (NULL == ptr) {
236                         list->tail->next = smalloc (sizeof (*list->tail->next));
237                         list->tail = list->tail->next;
238
239                         list->tail->name  = sstrdup (name);
240                         list->tail->value = incr;
241                         list->tail->next  = NULL;
242                 }
243                 else {
244                         ptr->value += incr;
245                 }
246         }
247         return;
248 } /* static void type_list_incr (type_list_t *, char *) */
249
250 static void *collect (void *arg)
251 {
252         collector_t *this = (collector_t *)arg;
253
254         while (1) {
255                 conn_t *connection;
256
257                 pthread_mutex_lock (&conns_mutex);
258
259                 while (NULL == conns.head) {
260                         pthread_cond_wait (&conn_available, &conns_mutex);
261                 }
262
263                 connection = conns.head;
264                 conns.head = conns.head->next;
265
266                 if (NULL == conns.head) {
267                         conns.tail = NULL;
268                 }
269
270                 pthread_mutex_unlock (&conns_mutex);
271
272                 /* make the socket available to the global
273                  * thread and connection management */
274                 this->socket = connection->socket;
275
276                 log_debug ("collect: handling connection on fd #%i",
277                                 fileno (this->socket));
278
279                 while (42) {
280                         /* 256 bytes ought to be enough for anybody ;-) */
281                         char line[256 + 1]; /* line + '\0' */
282                         int  len = 0;
283
284                         errno = 0;
285                         if (NULL == fgets (line, sizeof (line), this->socket)) {
286                                 if (0 != errno) {
287                                         char errbuf[1024];
288                                         log_err ("collect: reading from socket (fd #%i) "
289                                                         "failed: %s", fileno (this->socket),
290                                                         sstrerror (errno, errbuf, sizeof (errbuf)));
291                                 }
292                                 break;
293                         }
294
295                         len = strlen (line);
296                         if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
297                                 log_warn ("collect: line too long (> %zu characters): "
298                                                 "'%s' (truncated)", sizeof (line) - 1, line);
299
300                                 while (NULL != fgets (line, sizeof (line), this->socket))
301                                         if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
302                                                 break;
303                                 continue;
304                         }
305                         if (len < 3) { /* [a-z] ':' '\n' */
306                                 continue;
307                         }
308
309                         line[len - 1] = 0;
310
311                         log_debug ("collect: line = '%s'", line);
312
313                         if (':' != line[1]) {
314                                 log_err ("collect: syntax error in line '%s'", line);
315                                 continue;
316                         }
317
318                         if ('e' == line[0]) { /* e:<type>:<bytes> */
319                                 char *ptr  = NULL;
320                                 char *type = strtok_r (line + 2, ":", &ptr);
321                                 char *tmp  = strtok_r (NULL, ":", &ptr);
322                                 int  bytes = 0;
323
324                                 if (NULL == tmp) {
325                                         log_err ("collect: syntax error in line '%s'", line);
326                                         continue;
327                                 }
328
329                                 bytes = atoi (tmp);
330
331                                 pthread_mutex_lock (&count_mutex);
332                                 type_list_incr (&list_count, type, /* increment = */ 1);
333                                 pthread_mutex_unlock (&count_mutex);
334
335                                 if (bytes > 0) {
336                                         pthread_mutex_lock (&size_mutex);
337                                         type_list_incr (&list_size, type, /* increment = */ bytes);
338                                         pthread_mutex_unlock (&size_mutex);
339                                 }
340                         }
341                         else if ('s' == line[0]) { /* s:<value> */
342                                 pthread_mutex_lock (&score_mutex);
343                                 score = (score * (double)score_count + atof (line + 2))
344                                                 / (double)(score_count + 1);
345                                 ++score_count;
346                                 pthread_mutex_unlock (&score_mutex);
347                         }
348                         else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
349                                 char *dummy = line + 2;
350                                 char *endptr = NULL;
351                                 char *type;
352
353                                 pthread_mutex_lock (&check_mutex);
354                                 while ((type = strtok_r (dummy, ",", &endptr)) != NULL)
355                                 {
356                                         dummy = NULL;
357                                         type_list_incr (&list_check, type, /* increment = */ 1);
358                                 }
359                                 pthread_mutex_unlock (&check_mutex);
360                         }
361                         else {
362                                 log_err ("collect: unknown type '%c'", line[0]);
363                         }
364                 } /* while (42) */
365
366                 log_debug ("Shutting down connection on fd #%i",
367                                 fileno (this->socket));
368
369                 fclose (connection->socket);
370                 free (connection);
371
372                 this->socket = NULL;
373
374                 pthread_mutex_lock (&available_mutex);
375                 ++available_collectors;
376                 pthread_mutex_unlock (&available_mutex);
377
378                 pthread_cond_signal (&collector_available);
379         } /* while (1) */
380
381         pthread_exit ((void *)0);
382         return ((void *) 0);
383 } /* static void *collect (void *) */
384
385 static void *open_connection (void __attribute__((unused)) *arg)
386 {
387         struct sockaddr_un addr;
388
389         const char *path  = (NULL == sock_file) ? SOCK_PATH : sock_file;
390         const char *group = (NULL == sock_group) ? COLLECTD_GRP_NAME : sock_group;
391
392         /* create UNIX socket */
393         errno = 0;
394         if (-1 == (connector_socket = socket (PF_UNIX, SOCK_STREAM, 0))) {
395                 char errbuf[1024];
396                 disabled = 1;
397                 log_err ("socket() failed: %s",
398                                 sstrerror (errno, errbuf, sizeof (errbuf)));
399                 pthread_exit ((void *)1);
400         }
401
402         addr.sun_family = AF_UNIX;
403         sstrncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
404
405         errno = 0;
406         if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
407                                 offsetof (struct sockaddr_un, sun_path)
408                                         + strlen(addr.sun_path))) {
409                 char errbuf[1024];
410                 disabled = 1;
411                 close (connector_socket);
412                 connector_socket = -1;
413                 log_err ("bind() failed: %s",
414                                 sstrerror (errno, errbuf, sizeof (errbuf)));
415                 pthread_exit ((void *)1);
416         }
417
418         errno = 0;
419         if (-1 == listen (connector_socket, 5)) {
420                 char errbuf[1024];
421                 disabled = 1;
422                 close (connector_socket);
423                 connector_socket = -1;
424                 log_err ("listen() failed: %s",
425                                 sstrerror (errno, errbuf, sizeof (errbuf)));
426                 pthread_exit ((void *)1);
427         }
428
429         {
430                 struct group sg;
431                 struct group *grp;
432                 char grbuf[2048];
433                 int status;
434
435                 grp = NULL;
436                 status = getgrnam_r (group, &sg, grbuf, sizeof (grbuf), &grp);
437                 if (status != 0)
438                 {
439                         char errbuf[1024];
440                         log_warn ("getgrnam_r (%s) failed: %s", group,
441                                         sstrerror (errno, errbuf, sizeof (errbuf)));
442                 }
443                 else if (grp == NULL)
444                 {
445                         log_warn ("No such group: `%s'", group);
446                 }
447                 else
448                 {
449                         status = chown (path, (uid_t) -1, grp->gr_gid);
450                         if (status != 0)
451                         {
452                                 char errbuf[1024];
453                                 log_warn ("chown (%s, -1, %i) failed: %s",
454                                                 path, (int) grp->gr_gid,
455                                                 sstrerror (errno, errbuf, sizeof (errbuf)));
456                         }
457                 }
458         }
459
460         errno = 0;
461         if (0 != chmod (path, sock_perms)) {
462                 char errbuf[1024];
463                 log_warn ("chmod() failed: %s",
464                                 sstrerror (errno, errbuf, sizeof (errbuf)));
465         }
466
467         { /* initialize collector threads */
468                 pthread_attr_t ptattr;
469
470                 conns.head = NULL;
471                 conns.tail = NULL;
472
473                 pthread_attr_init (&ptattr);
474                 pthread_attr_setdetachstate (&ptattr, PTHREAD_CREATE_DETACHED);
475
476                 available_collectors = max_conns;
477
478                 collectors =
479                         smalloc (max_conns * sizeof (*collectors));
480
481                 for (int i = 0; i < max_conns; ++i) {
482                         collectors[i] = smalloc (sizeof (*collectors[i]));
483                         collectors[i]->socket = NULL;
484
485                         if (plugin_thread_create (&collectors[i]->thread,
486                                                         &ptattr, collect, collectors[i]) != 0) {
487                                 char errbuf[1024];
488                                 log_err ("plugin_thread_create() failed: %s",
489                                                 sstrerror (errno, errbuf, sizeof (errbuf)));
490                                 collectors[i]->thread = (pthread_t) 0;
491                         }
492                 }
493
494                 pthread_attr_destroy (&ptattr);
495         }
496
497         while (1) {
498                 int remote = 0;
499
500                 conn_t *connection;
501
502                 pthread_mutex_lock (&available_mutex);
503
504                 while (0 == available_collectors) {
505                         pthread_cond_wait (&collector_available, &available_mutex);
506                 }
507
508                 --available_collectors;
509
510                 pthread_mutex_unlock (&available_mutex);
511
512                 while (42) {
513                         errno = 0;
514
515                         remote = accept (connector_socket, NULL, NULL);
516                         if (remote == -1) {
517                                 char errbuf[1024];
518
519                                 if (errno == EINTR)
520                                         continue;
521
522                                 disabled = 1;
523                                 close (connector_socket);
524                                 connector_socket = -1;
525                                 log_err ("accept() failed: %s",
526                                                  sstrerror (errno, errbuf, sizeof (errbuf)));
527                                 pthread_exit ((void *)1);
528                         }
529
530                         /* access() succeeded. */
531                         break;
532                 }
533
534                 connection = calloc (1, sizeof (*connection));
535                 if (connection == NULL)
536                 {
537                         close (remote);
538                         continue;
539                 }
540
541                 connection->socket = fdopen (remote, "r");
542                 connection->next   = NULL;
543
544                 if (NULL == connection->socket) {
545                         close (remote);
546                         sfree (connection);
547                         continue;
548                 }
549
550                 pthread_mutex_lock (&conns_mutex);
551
552                 if (NULL == conns.head) {
553                         conns.head = connection;
554                         conns.tail = connection;
555                 }
556                 else {
557                         conns.tail->next = connection;
558                         conns.tail = conns.tail->next;
559                 }
560
561                 pthread_mutex_unlock (&conns_mutex);
562
563                 pthread_cond_signal (&conn_available);
564         }
565
566         pthread_exit ((void *) 0);
567         return ((void *) 0);
568 } /* static void *open_connection (void *) */
569
570 static int email_init (void)
571 {
572         if (plugin_thread_create (&connector, NULL,
573                                 open_connection, NULL) != 0) {
574                 char errbuf[1024];
575                 disabled = 1;
576                 log_err ("plugin_thread_create() failed: %s",
577                                 sstrerror (errno, errbuf, sizeof (errbuf)));
578                 return (-1);
579         }
580
581         return (0);
582 } /* int email_init */
583
584 static void type_list_free (type_list_t *t)
585 {
586         type_t *this;
587
588         this = t->head;
589         while (this != NULL)
590         {
591                 type_t *next = this->next;
592
593                 sfree (this->name);
594                 sfree (this);
595
596                 this = next;
597         }
598
599         t->head = NULL;
600         t->tail = NULL;
601 }
602
603 static int email_shutdown (void)
604 {
605         if (connector != ((pthread_t) 0)) {
606                 pthread_kill (connector, SIGTERM);
607                 connector = (pthread_t) 0;
608         }
609
610         if (connector_socket >= 0) {
611                 close (connector_socket);
612                 connector_socket = -1;
613         }
614
615         /* don't allow any more connections to be processed */
616         pthread_mutex_lock (&conns_mutex);
617
618         available_collectors = 0;
619
620         if (collectors != NULL) {
621                 for (int i = 0; i < max_conns; ++i) {
622                         if (collectors[i] == NULL)
623                                 continue;
624
625                         if (collectors[i]->thread != ((pthread_t) 0)) {
626                                 pthread_kill (collectors[i]->thread, SIGTERM);
627                                 collectors[i]->thread = (pthread_t) 0;
628                         }
629
630                         if (collectors[i]->socket != NULL) {
631                                 fclose (collectors[i]->socket);
632                                 collectors[i]->socket = NULL;
633                         }
634
635                         sfree (collectors[i]);
636                 }
637                 sfree (collectors);
638         } /* if (collectors != NULL) */
639
640         pthread_mutex_unlock (&conns_mutex);
641
642         type_list_free (&list_count);
643         type_list_free (&list_count_copy);
644         type_list_free (&list_size);
645         type_list_free (&list_size_copy);
646         type_list_free (&list_check);
647         type_list_free (&list_check_copy);
648
649         unlink ((NULL == sock_file) ? SOCK_PATH : sock_file);
650
651         sfree (sock_file);
652         sfree (sock_group);
653         return (0);
654 } /* static void email_shutdown (void) */
655
656 static void email_submit (const char *type, const char *type_instance, gauge_t value)
657 {
658         value_t values[1];
659         value_list_t vl = VALUE_LIST_INIT;
660
661         values[0].gauge = value;
662
663         vl.values = values;
664         vl.values_len = 1;
665         sstrncpy (vl.host, hostname_g, sizeof (vl.host));
666         sstrncpy (vl.plugin, "email", sizeof (vl.plugin));
667         sstrncpy (vl.type, type, sizeof (vl.type));
668         sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
669
670         plugin_dispatch_values (&vl);
671 } /* void email_submit */
672
673 /* Copy list l1 to list l2. l2 may partly exist already, but it is assumed
674  * that neither the order nor the name of any element of either list is
675  * changed and no elements are deleted. The values of l1 are reset to zero
676  * after they have been copied to l2. */
677 static void copy_type_list (type_list_t *l1, type_list_t *l2)
678 {
679         type_t *last = NULL;
680
681         for (type_t *ptr1 = l1->head, *ptr2 = l2->head; NULL != ptr1;
682                         ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
683                 if (NULL == ptr2) {
684                         ptr2 = smalloc (sizeof (*ptr2));
685                         ptr2->name = NULL;
686                         ptr2->next = NULL;
687
688                         if (NULL == last) {
689                                 l2->head = ptr2;
690                         }
691                         else {
692                                 last->next = ptr2;
693                         }
694
695                         l2->tail = ptr2;
696                 }
697
698                 if (NULL == ptr2->name) {
699                         ptr2->name = sstrdup (ptr1->name);
700                 }
701
702                 ptr2->value = ptr1->value;
703                 ptr1->value = 0;
704         }
705         return;
706 }
707
708 static int email_read (void)
709 {
710         double score_old;
711         int score_count_old;
712
713         if (disabled)
714                 return (-1);
715
716         /* email count */
717         pthread_mutex_lock (&count_mutex);
718
719         copy_type_list (&list_count, &list_count_copy);
720
721         pthread_mutex_unlock (&count_mutex);
722
723         for (type_t *ptr = list_count_copy.head; NULL != ptr; ptr = ptr->next) {
724                 email_submit ("email_count", ptr->name, ptr->value);
725         }
726
727         /* email size */
728         pthread_mutex_lock (&size_mutex);
729
730         copy_type_list (&list_size, &list_size_copy);
731
732         pthread_mutex_unlock (&size_mutex);
733
734         for (type_t *ptr = list_size_copy.head; NULL != ptr; ptr = ptr->next) {
735                 email_submit ("email_size", ptr->name, ptr->value);
736         }
737
738         /* spam score */
739         pthread_mutex_lock (&score_mutex);
740
741         score_old = score;
742         score_count_old = score_count;
743         score = 0.0;
744         score_count = 0;
745
746         pthread_mutex_unlock (&score_mutex);
747
748         if (score_count_old > 0)
749                 email_submit ("spam_score", "", score_old);
750
751         /* spam checks */
752         pthread_mutex_lock (&check_mutex);
753
754         copy_type_list (&list_check, &list_check_copy);
755
756         pthread_mutex_unlock (&check_mutex);
757
758         for (type_t *ptr = list_check_copy.head; NULL != ptr; ptr = ptr->next)
759                 email_submit ("spam_check", ptr->name, ptr->value);
760
761         return (0);
762 } /* int email_read */
763
764 void module_register (void)
765 {
766         plugin_register_config ("email", email_config, config_keys, config_keys_num);
767         plugin_register_init ("email", email_init);
768         plugin_register_read ("email", email_read);
769         plugin_register_shutdown ("email", email_shutdown);
770 } /* void module_register */
771
772 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */