X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_daemon.c;fp=src%2Frrd_daemon.c;h=0586a8de7efbf82db37bd8a07ee8ef4f97bfd6cb;hp=0dc8e0b33f28c7f38be82cc513e727b26b92366e;hb=21bf05343fdc263596289485c3d506ed613f2c75;hpb=9d1b36962ce04d82d32284807df44d349e0ac4f3 diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 0dc8e0b..0586a8d 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -109,6 +109,10 @@ #include #include +#ifdef HAVE_LIBWRAP +#include +#endif /* HAVE_LIBWRAP */ + #include /* }}} */ @@ -2636,6 +2640,21 @@ static void *connection_thread_main (void *args) /* {{{ */ } pthread_mutex_lock (&connection_threads_lock); +#ifdef HAVE_LIBWRAP + /* LIBWRAP does not support multiple threads! By putting this code + inside pthread_mutex_lock we do not have to worry about request_info + getting overwritten by another thread. + */ + struct request_info req; + request_init(&req, RQ_DAEMON, "rrdcache\0", RQ_FILE, fd, NULL ); + fromhost(&req); + if(!hosts_access(&req)) { + RRDD_LOG(LOG_INFO, "refused connection from %s", eval_client(&req)); + pthread_mutex_unlock (&connection_threads_lock); + close_connection(sock); + return NULL; + } +#endif /* HAVE_LIBWRAP */ connection_threads_num++; pthread_mutex_unlock (&connection_threads_lock);