2 * Copyright (c) 1995-2004, Index Data
3 * See the file LICENSE for details.
5 * $Id: tcpdchk.c,v 1.2 2004-10-15 00:19:01 adam Exp $
9 * \brief Implements TCP WRAPPER check.
15 #include <yaz/yconfig.h>
16 #include <yaz/comstack.h>
23 int allow_severity = LOG_INFO;
24 int deny_severity = LOG_WARNING;
35 #include <yaz/statserv.h>
38 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
40 const char *daemon_name = (const char *) cd;
44 if (daemon_name && *daemon_name)
47 struct request_info request_info;
50 char *host_name = 0, *host_addr = 0;
53 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
55 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
56 sizeof(addr_in->sin_addr),
58 host_name = (char*) host->h_name;
59 host_addr = inet_ntoa(addr_in->sin_addr);
62 request_init(&request_info, RQ_DAEMON, daemon_name,
63 RQ_CLIENT_NAME, host_name,
64 RQ_CLIENT_SIN, addr_in,
65 RQ_CLIENT_ADDR, host_addr, 0);
67 request_init(&request_info, RQ_DAEMON, daemon_name,
68 RQ_CLIENT_SIN, addr_in,
69 RQ_CLIENT_ADDR, host_addr, 0);
70 i = hosts_access(&request_info);
73 yaz_log (LOG_DEBUG, "access denied from %s",
74 host_name ? host_name : host_addr);
77 yaz_log (LOG_DEBUG, "access granted from %s",
78 host_name ? host_name : host_addr);