2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: tcpdchk.c,v 1.6 2005-01-16 21:51:50 adam Exp $
9 * \brief Implements TCP WRAPPER check.
19 #include <arpa/inet.h>
22 #include <yaz/yconfig.h>
23 #include <yaz/comstack.h>
24 #include <yaz/statserv.h>
32 int allow_severity = LOG_INFO; /* not YLOG !! */
33 int deny_severity = LOG_WARNING;
44 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
46 const char *daemon_name = (const char *) cd;
50 if (daemon_name && *daemon_name)
53 struct request_info request_info;
56 char *host_name = 0, *host_addr = 0;
59 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
61 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
62 sizeof(addr_in->sin_addr),
64 host_name = (char*) host->h_name;
65 host_addr = inet_ntoa(addr_in->sin_addr);
68 request_init(&request_info, RQ_DAEMON, daemon_name,
69 RQ_CLIENT_NAME, host_name,
70 RQ_CLIENT_SIN, addr_in,
71 RQ_CLIENT_ADDR, host_addr, 0);
73 request_init(&request_info, RQ_DAEMON, daemon_name,
74 RQ_CLIENT_SIN, addr_in,
75 RQ_CLIENT_ADDR, host_addr, 0);
76 i = hosts_access(&request_info);
79 yaz_log (YLOG_DEBUG, "access denied from %s",
80 host_name ? host_name : host_addr);
83 yaz_log (YLOG_DEBUG, "access granted from %s",
84 host_name ? host_name : host_addr);