1 /**
2 * collectd - src/email.c
3 * Copyright (C) 2006,2007 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; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * Author:
19 * Sebastian Harl <sh at tokkee.org>
20 **/
22 /*
23 * This plugin communicates with a spam filter, a virus scanner or similar
24 * software using a UNIX socket and a very simple protocol:
25 *
26 * e-mail type (e.g. ham, spam, virus, ...) and size
27 * e:<type>:<bytes>
28 *
29 * spam score
30 * s:<value>
31 *
32 * successful spam checks
33 * c:<type1>[,<type2>,...]
34 */
36 #include "collectd.h"
37 #include "common.h"
38 #include "plugin.h"
40 #include "configfile.h"
42 #include <stddef.h>
44 #if HAVE_LIBPTHREAD
45 # include <pthread.h>
46 #endif
48 #include <sys/socket.h>
49 #include <sys/un.h>
50 #include <sys/select.h>
52 /* some systems (e.g. Darwin) seem to not define UNIX_PATH_MAX at all */
53 #ifndef UNIX_PATH_MAX
54 # define UNIX_PATH_MAX sizeof (((struct sockaddr_un *)0)->sun_path)
55 #endif /* UNIX_PATH_MAX */
57 #if HAVE_GRP_H
58 # include <grp.h>
59 #endif /* HAVE_GRP_H */
61 #define MODULE_NAME "email"
63 /* 256 bytes ought to be enough for anybody ;-) */
64 #define BUFSIZE 256
66 #define SOCK_PATH LOCALSTATEDIR"/run/"PACKAGE_NAME"-email"
67 #define MAX_CONNS 5
68 #define MAX_CONNS_LIMIT 16384
70 #define log_err(...) ERROR (MODULE_NAME": "__VA_ARGS__)
71 #define log_warn(...) WARNING (MODULE_NAME": "__VA_ARGS__)
73 /*
74 * Private data structures
75 */
76 /* linked list of email and check types */
77 typedef struct type {
78 char *name;
79 int value;
80 struct type *next;
81 } type_t;
83 typedef struct {
84 type_t *head;
85 type_t *tail;
86 } type_list_t;
88 /* collector thread control information */
89 typedef struct collector {
90 pthread_t thread;
92 /* socket descriptor of the current/last connection */
93 int socket;
94 } collector_t;
96 /* linked list of pending connections */
97 typedef struct conn {
98 /* socket to read data from */
99 int socket;
101 /* buffer to read data to */
102 char *buffer;
103 int idx; /* current write position in buffer */
104 int length; /* length of the current line, i.e. index of '\0' */
106 struct conn *next;
107 } conn_t;
109 typedef struct {
110 conn_t *head;
111 conn_t *tail;
112 } conn_list_t;
114 /*
115 * Private variables
116 */
117 /* valid configuration file keys */
118 static const char *config_keys[] =
119 {
120 "SocketFile",
121 "SocketGroup",
122 "SocketPerms",
123 "MaxConns"
124 };
125 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
127 /* socket configuration */
128 static char *sock_file = SOCK_PATH;
129 static char *sock_group = COLLECTD_GRP_NAME;
130 static int sock_perms = S_IRWXU | S_IRWXG;
131 static int max_conns = MAX_CONNS;
133 /* state of the plugin */
134 static int disabled = 0;
136 /* thread managing "client" connections */
137 static pthread_t connector = (pthread_t) 0;
138 static int connector_socket = -1;
140 /* tell the collector threads that a new connection is available */
141 static pthread_cond_t conn_available = PTHREAD_COND_INITIALIZER;
143 /* connections that are waiting to be processed */
144 static pthread_mutex_t conns_mutex = PTHREAD_MUTEX_INITIALIZER;
145 static conn_list_t conns;
147 /* tell the connector thread that a collector is available */
148 static pthread_cond_t collector_available = PTHREAD_COND_INITIALIZER;
150 /* collector threads */
151 static collector_t **collectors = NULL;
153 static pthread_mutex_t available_mutex = PTHREAD_MUTEX_INITIALIZER;
154 static int available_collectors;
156 static pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
157 static type_list_t count;
159 static pthread_mutex_t size_mutex = PTHREAD_MUTEX_INITIALIZER;
160 static type_list_t size;
162 static pthread_mutex_t score_mutex = PTHREAD_MUTEX_INITIALIZER;
163 static double score;
164 static int score_count;
166 static pthread_mutex_t check_mutex = PTHREAD_MUTEX_INITIALIZER;
167 static type_list_t check;
169 /*
170 * Private functions
171 */
172 static int email_config (const char *key, const char *value)
173 {
174 if (0 == strcasecmp (key, "SocketFile")) {
175 sock_file = sstrdup (value);
176 }
177 else if (0 == strcasecmp (key, "SocketGroup")) {
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);
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 max_conns = MAX_CONNS;
192 }
193 else if (tmp > MAX_CONNS_LIMIT) {
194 fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
195 "value %li, will use hardcoded limit %i.\n",
196 tmp, MAX_CONNS_LIMIT);
197 max_conns = MAX_CONNS_LIMIT;
198 }
199 else {
200 max_conns = (int)tmp;
201 }
202 }
203 else {
204 return -1;
205 }
206 return 0;
207 } /* static int email_config (char *, char *) */
209 /* Increment the value of the given name in the given list by incr. */
210 static void type_list_incr (type_list_t *list, char *name, int incr)
211 {
212 if (NULL == list->head) {
213 list->head = (type_t *)smalloc (sizeof (type_t));
215 list->head->name = sstrdup (name);
216 list->head->value = incr;
217 list->head->next = NULL;
219 list->tail = list->head;
220 }
221 else {
222 type_t *ptr;
224 for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
225 if (0 == strcmp (name, ptr->name))
226 break;
227 }
229 if (NULL == ptr) {
230 list->tail->next = (type_t *)smalloc (sizeof (type_t));
231 list->tail = list->tail->next;
233 list->tail->name = sstrdup (name);
234 list->tail->value = incr;
235 list->tail->next = NULL;
236 }
237 else {
238 ptr->value += incr;
239 }
240 }
241 return;
242 } /* static void type_list_incr (type_list_t *, char *) */
244 /* Read a single character from the socket. If an error occurs or end-of-file
245 * is reached return '\0'. */
246 static char read_char (conn_t *src)
247 {
248 char ret = '\0';
250 fd_set fdset;
252 FD_ZERO (&fdset);
253 FD_SET (src->socket, &fdset);
255 if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
256 char errbuf[1024];
257 log_err ("select() failed: %s",
258 sstrerror (errno, errbuf, sizeof (errbuf)));
259 return '\0';
260 }
262 assert (FD_ISSET (src->socket, &fdset));
264 do {
265 ssize_t len = 0;
267 errno = 0;
268 if (0 > (len = read (src->socket, (void *)&ret, 1))) {
269 if (EINTR != errno) {
270 char errbuf[1024];
271 log_err ("read() failed: %s",
272 sstrerror (errno, errbuf, sizeof (errbuf)));
273 return '\0';
274 }
275 }
277 if (0 == len)
278 return '\0';
279 } while (EINTR == errno);
280 return ret;
281 } /* static char read_char (conn_t *) */
283 /* Read a single line (terminated by '\n') from the the socket.
284 *
285 * The return value is zero terminated and does not contain any newline
286 * characters.
287 *
288 * If an error occurs or end-of-file is reached return NULL.
289 *
290 * IMPORTANT NOTE: If there is no newline character found in BUFSIZE
291 * characters of the input stream, the line will will be ignored! By
292 * definition we should not get any longer input lines, thus this is
293 * acceptable in this case ;-) */
294 static char *read_line (conn_t *src)
295 {
296 int i = 0;
298 assert ((BUFSIZE >= src->idx) && (src->idx >= 0));
299 assert ((src->idx > src->length) || (src->length == 0));
301 if (src->length > 0) { /* remove old line */
302 src->idx -= (src->length + 1);
303 memmove (src->buffer, src->buffer + src->length + 1, src->idx);
304 src->length = 0;
305 }
307 for (i = 0; i < src->idx; ++i) {
308 if ('\n' == src->buffer[i])
309 break;
310 }
312 if (i == src->idx) {
313 fd_set fdset;
315 ssize_t len = 0;
317 FD_ZERO (&fdset);
318 FD_SET (src->socket, &fdset);
320 if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
321 char errbuf[1024];
322 log_err ("select() failed: %s",
323 sstrerror (errno, errbuf, sizeof (errbuf)));
324 return NULL;
325 }
327 assert (FD_ISSET (src->socket, &fdset));
329 do {
330 errno = 0;
331 if (0 > (len = read (src->socket,
332 (void *)(src->buffer + src->idx),
333 BUFSIZE - src->idx))) {
334 if (EINTR != errno) {
335 char errbuf[1024];
336 log_err ("read() failed: %s",
337 sstrerror (errno, errbuf, sizeof (errbuf)));
338 return NULL;
339 }
340 }
342 if (0 == len)
343 return NULL;
344 } while (EINTR == errno);
346 src->idx += len;
348 for (i = src->idx - len; i < src->idx; ++i) {
349 if ('\n' == src->buffer[i])
350 break;
351 }
353 if (i == src->idx) {
354 src->length = 0;
356 if (BUFSIZE == src->idx) { /* no space left in buffer */
357 while ('\n' != read_char (src))
358 /* ignore complete line */;
360 src->idx = 0;
361 }
362 return read_line (src);
363 }
364 }
366 src->buffer[i] = '\0';
367 src->length = i;
369 return src->buffer;
370 } /* static char *read_line (conn_t *) */
372 static void *collect (void *arg)
373 {
374 collector_t *this = (collector_t *)arg;
376 char *buffer = (char *)smalloc (BUFSIZE);
378 while (1) {
379 int loop = 1;
381 conn_t *connection;
383 pthread_mutex_lock (&conns_mutex);
385 while (NULL == conns.head) {
386 pthread_cond_wait (&conn_available, &conns_mutex);
387 }
389 connection = conns.head;
390 conns.head = conns.head->next;
392 if (NULL == conns.head) {
393 conns.tail = NULL;
394 }
396 this->socket = connection->socket;
398 pthread_mutex_unlock (&conns_mutex);
400 connection->buffer = buffer;
401 connection->idx = 0;
402 connection->length = 0;
404 { /* put the socket in non-blocking mode */
405 int flags = 0;
407 errno = 0;
408 if (-1 == fcntl (connection->socket, F_GETFL, &flags)) {
409 char errbuf[1024];
410 log_err ("fcntl() failed: %s",
411 sstrerror (errno, errbuf, sizeof (errbuf)));
412 loop = 0;
413 }
415 errno = 0;
416 if (-1 == fcntl (connection->socket, F_SETFL, flags | O_NONBLOCK)) {
417 char errbuf[1024];
418 log_err ("fcntl() failed: %s",
419 sstrerror (errno, errbuf, sizeof (errbuf)));
420 loop = 0;
421 }
422 }
424 while (loop) {
425 char *line = read_line (connection);
427 if (NULL == line) {
428 loop = 0;
429 break;
430 }
432 if (':' != line[1]) {
433 log_err ("syntax error in line '%s'", line);
434 continue;
435 }
437 if ('e' == line[0]) { /* e:<type>:<bytes> */
438 char *ptr = NULL;
439 char *type = strtok_r (line + 2, ":", &ptr);
440 char *tmp = strtok_r (NULL, ":", &ptr);
441 int bytes = 0;
443 if (NULL == tmp) {
444 log_err ("syntax error in line '%s'", line);
445 continue;
446 }
448 bytes = atoi (tmp);
450 pthread_mutex_lock (&count_mutex);
451 type_list_incr (&count, type, 1);
452 pthread_mutex_unlock (&count_mutex);
454 if (bytes > 0) {
455 pthread_mutex_lock (&size_mutex);
456 type_list_incr (&size, type, bytes);
457 pthread_mutex_unlock (&size_mutex);
458 }
459 }
460 else if ('s' == line[0]) { /* s:<value> */
461 pthread_mutex_lock (&score_mutex);
462 score = (score * (double)score_count + atof (line + 2))
463 / (double)(score_count + 1);
464 ++score_count;
465 pthread_mutex_unlock (&score_mutex);
466 }
467 else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
468 char *ptr = NULL;
469 char *type = strtok_r (line + 2, ",", &ptr);
471 do {
472 pthread_mutex_lock (&check_mutex);
473 type_list_incr (&check, type, 1);
474 pthread_mutex_unlock (&check_mutex);
475 } while (NULL != (type = strtok_r (NULL, ",", &ptr)));
476 }
477 else {
478 log_err ("unknown type '%c'", line[0]);
479 }
480 } /* while (loop) */
482 close (connection->socket);
483 free (connection);
485 this->socket = -1;
487 pthread_mutex_lock (&available_mutex);
488 ++available_collectors;
489 pthread_mutex_unlock (&available_mutex);
491 pthread_cond_signal (&collector_available);
492 } /* while (1) */
494 free (buffer);
495 pthread_exit ((void *)0);
496 } /* static void *collect (void *) */
498 static void *open_connection (void *arg)
499 {
500 struct sockaddr_un addr;
502 /* create UNIX socket */
503 errno = 0;
504 if (-1 == (connector_socket = socket (PF_UNIX, SOCK_STREAM, 0))) {
505 char errbuf[1024];
506 disabled = 1;
507 log_err ("socket() failed: %s",
508 sstrerror (errno, errbuf, sizeof (errbuf)));
509 pthread_exit ((void *)1);
510 }
512 addr.sun_family = AF_UNIX;
514 strncpy (addr.sun_path, sock_file, (size_t)(UNIX_PATH_MAX - 1));
515 addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
516 unlink (addr.sun_path);
518 errno = 0;
519 if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
520 offsetof (struct sockaddr_un, sun_path)
521 + strlen(addr.sun_path))) {
522 char errbuf[1024];
523 disabled = 1;
524 connector_socket = -1; /* TODO: close? */
525 log_err ("bind() failed: %s",
526 sstrerror (errno, errbuf, sizeof (errbuf)));
527 pthread_exit ((void *)1);
528 }
530 errno = 0;
531 if (-1 == listen (connector_socket, 5)) {
532 char errbuf[1024];
533 disabled = 1;
534 connector_socket = -1; /* TODO: close? */
535 log_err ("listen() failed: %s",
536 sstrerror (errno, errbuf, sizeof (errbuf)));
537 pthread_exit ((void *)1);
538 }
540 if ((uid_t) 0 == geteuid ())
541 {
542 struct group sg;
543 struct group *grp;
544 char grbuf[2048];
545 int status;
547 grp = NULL;
548 status = getgrnam_r (sock_group, &sg, grbuf, sizeof (grbuf), &grp);
549 if (status != 0)
550 {
551 char errbuf[1024];
552 log_warn ("getgrnam_r (%s) failed: %s", sock_group,
553 sstrerror (errno, errbuf, sizeof (errbuf)));
554 }
555 else if (grp == NULL)
556 {
557 log_warn ("No such group: `%s'", sock_group);
558 }
559 else
560 {
561 status = chown (sock_file, (uid_t) -1, grp->gr_gid);
562 if (status != 0)
563 {
564 char errbuf[1024];
565 log_warn ("chown (%s, -1, %i) failed: %s",
566 sock_file, (int) grp->gr_gid,
567 sstrerror (errno, errbuf, sizeof (errbuf)));
568 }
569 }
570 }
571 else /* geteuid != 0 */
572 {
573 log_warn ("not running as root");
574 }
576 errno = 0;
577 if (0 != chmod (sock_file, sock_perms)) {
578 char errbuf[1024];
579 log_warn ("chmod() failed: %s",
580 sstrerror (errno, errbuf, sizeof (errbuf)));
581 }
583 { /* initialize collector threads */
584 int i = 0;
585 int err = 0;
587 pthread_attr_t ptattr;
589 conns.head = NULL;
590 conns.tail = NULL;
592 pthread_attr_init (&ptattr);
593 pthread_attr_setdetachstate (&ptattr, PTHREAD_CREATE_DETACHED);
595 available_collectors = max_conns;
597 collectors =
598 (collector_t **)smalloc (max_conns * sizeof (collector_t *));
600 for (i = 0; i < max_conns; ++i) {
601 collectors[i] = (collector_t *)smalloc (sizeof (collector_t));
602 collectors[i]->socket = -1;
604 if (0 != (err = pthread_create (&collectors[i]->thread, &ptattr,
605 collect, collectors[i]))) {
606 char errbuf[1024];
607 log_err ("pthread_create() failed: %s",
608 sstrerror (errno, errbuf, sizeof (errbuf)));
609 collectors[i]->thread = (pthread_t) 0;
610 }
611 }
613 pthread_attr_destroy (&ptattr);
614 }
616 while (1) {
617 int remote = 0;
619 conn_t *connection;
621 pthread_mutex_lock (&available_mutex);
623 while (0 == available_collectors) {
624 pthread_cond_wait (&collector_available, &available_mutex);
625 }
627 --available_collectors;
629 pthread_mutex_unlock (&available_mutex);
631 do {
632 errno = 0;
633 if (-1 == (remote = accept (connector_socket, NULL, NULL))) {
634 if (EINTR != errno) {
635 char errbuf[1024];
636 disabled = 1;
637 connector_socket = -1; /* TODO: close? */
638 log_err ("accept() failed: %s",
639 sstrerror (errno, errbuf, sizeof (errbuf)));
640 pthread_exit ((void *)1);
641 }
642 }
643 } while (EINTR == errno);
645 connection = (conn_t *)smalloc (sizeof (conn_t));
647 connection->socket = remote;
648 connection->next = NULL;
650 pthread_mutex_lock (&conns_mutex);
652 if (NULL == conns.head) {
653 conns.head = connection;
654 conns.tail = connection;
655 }
656 else {
657 conns.tail->next = connection;
658 conns.tail = conns.tail->next;
659 }
661 pthread_mutex_unlock (&conns_mutex);
663 pthread_cond_signal (&conn_available);
664 }
665 pthread_exit ((void *)0);
666 } /* static void *open_connection (void *) */
668 static int email_init (void)
669 {
670 int err = 0;
672 if (0 != (err = pthread_create (&connector, NULL,
673 open_connection, NULL))) {
674 char errbuf[1024];
675 disabled = 1;
676 log_err ("pthread_create() failed: %s",
677 sstrerror (errno, errbuf, sizeof (errbuf)));
678 return (-1);
679 }
681 return (0);
682 } /* int email_init */
684 static int email_shutdown (void)
685 {
686 int i = 0;
688 if (connector != ((pthread_t) 0)) {
689 pthread_kill (connector, SIGTERM);
690 connector = (pthread_t) 0;
691 }
693 if (connector_socket >= 0) {
694 close (connector_socket);
695 connector_socket = -1;
696 }
698 /* don't allow any more connections to be processed */
699 pthread_mutex_lock (&conns_mutex);
701 if (collectors != NULL) {
702 for (i = 0; i < max_conns; ++i) {
703 if (collectors[i] == NULL)
704 continue;
706 if (collectors[i]->thread != ((pthread_t) 0)) {
707 pthread_kill (collectors[i]->thread, SIGTERM);
708 collectors[i]->thread = (pthread_t) 0;
709 }
711 if (collectors[i]->socket >= 0) {
712 close (collectors[i]->socket);
713 collectors[i]->socket = -1;
714 }
715 }
716 } /* if (collectors != NULL) */
718 pthread_mutex_unlock (&conns_mutex);
720 unlink (sock_file);
721 errno = 0;
723 return (0);
724 } /* static void email_shutdown (void) */
726 static void email_submit (const char *type, const char *type_instance, gauge_t value)
727 {
728 value_t values[1];
729 value_list_t vl = VALUE_LIST_INIT;
731 values[0].gauge = value;
733 vl.values = values;
734 vl.values_len = 1;
735 vl.time = time (NULL);
736 strcpy (vl.host, hostname_g);
737 strcpy (vl.plugin, "email");
738 strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
740 plugin_dispatch_values (type, &vl);
741 } /* void email_submit */
743 /* Copy list l1 to list l2. l2 may partly exist already, but it is assumed
744 * that neither the order nor the name of any element of either list is
745 * changed and no elements are deleted. The values of l1 are reset to zero
746 * after they have been copied to l2. */
747 static void copy_type_list (type_list_t *l1, type_list_t *l2)
748 {
749 type_t *ptr1;
750 type_t *ptr2;
752 type_t *last = NULL;
754 for (ptr1 = l1->head, ptr2 = l2->head; NULL != ptr1;
755 ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
756 if (NULL == ptr2) {
757 ptr2 = (type_t *)smalloc (sizeof (type_t));
758 ptr2->name = NULL;
759 ptr2->next = NULL;
761 if (NULL == last) {
762 l2->head = ptr2;
763 }
764 else {
765 last->next = ptr2;
766 }
768 l2->tail = ptr2;
769 }
771 if (NULL == ptr2->name) {
772 ptr2->name = sstrdup (ptr1->name);
773 }
775 ptr2->value = ptr1->value;
776 ptr1->value = 0;
777 }
778 return;
779 }
781 static int email_read (void)
782 {
783 type_t *ptr;
785 double score_old;
786 int score_count_old;
788 static type_list_t *cnt;
789 static type_list_t *sz;
790 static type_list_t *chk;
792 if (disabled)
793 return (-1);
795 if (NULL == cnt) {
796 cnt = (type_list_t *)smalloc (sizeof (type_list_t));
797 cnt->head = NULL;
798 }
800 if (NULL == sz) {
801 sz = (type_list_t *)smalloc (sizeof (type_list_t));
802 sz->head = NULL;
803 }
805 if (NULL == chk) {
806 chk = (type_list_t *)smalloc (sizeof (type_list_t));
807 chk->head = NULL;
808 }
810 /* email count */
811 pthread_mutex_lock (&count_mutex);
813 copy_type_list (&count, cnt);
815 pthread_mutex_unlock (&count_mutex);
817 for (ptr = cnt->head; NULL != ptr; ptr = ptr->next) {
818 email_submit ("email_count", ptr->name, ptr->value);
819 }
821 /* email size */
822 pthread_mutex_lock (&size_mutex);
824 copy_type_list (&size, sz);
826 pthread_mutex_unlock (&size_mutex);
828 for (ptr = sz->head; NULL != ptr; ptr = ptr->next) {
829 email_submit ("email_size", ptr->name, ptr->value);
830 }
832 /* spam score */
833 pthread_mutex_lock (&score_mutex);
835 score_old = score;
836 score_count_old = score_count;
837 score = 0.0;
838 score_count = 0;
840 pthread_mutex_unlock (&score_mutex);
842 if (score_count_old > 0)
843 email_submit ("spam_score", "", score_old);
845 /* spam checks */
846 pthread_mutex_lock (&check_mutex);
848 copy_type_list (&check, chk);
850 pthread_mutex_unlock (&check_mutex);
852 for (ptr = chk->head; NULL != ptr; ptr = ptr->next)
853 email_submit ("spam_check", ptr->name, ptr->value);
855 return (0);
856 } /* int email_read */
858 void module_register (void)
859 {
860 plugin_register_config ("email", email_config, config_keys, config_keys_num);
861 plugin_register_init ("email", email_init);
862 plugin_register_read ("email", email_read);
863 plugin_register_shutdown ("email", email_shutdown);
864 } /* void module_register */
866 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */