1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements TCP WRAPPER check.
18 #include <sys/types.h>
22 #include <netinet/in.h>
26 #include <arpa/inet.h>
30 /* freebsd wants this for AF_INET */
31 #include <sys/socket.h>
38 #include <yaz/comstack.h>
39 #include <yaz/statserv.h>
47 int allow_severity = LOG_INFO; /* not YLOG !! */
48 int deny_severity = LOG_WARNING;
59 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
61 const char *daemon_name = (const char *) cd;
65 if (daemon_name && *daemon_name)
68 struct request_info request_info;
71 char *host_name = 0, *host_addr = 0;
74 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
76 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
77 sizeof(addr_in->sin_addr),
79 host_name = (char*) host->h_name;
80 host_addr = inet_ntoa(addr_in->sin_addr);
83 request_init(&request_info, RQ_DAEMON, daemon_name,
84 RQ_CLIENT_NAME, host_name,
85 RQ_CLIENT_SIN, addr_in,
86 RQ_CLIENT_ADDR, host_addr, 0);
88 request_init(&request_info, RQ_DAEMON, daemon_name,
89 RQ_CLIENT_SIN, addr_in,
90 RQ_CLIENT_ADDR, host_addr, 0);
91 i = hosts_access(&request_info);
94 yaz_log (YLOG_DEBUG, "access denied from %s",
95 host_name ? host_name : host_addr);
98 yaz_log (YLOG_DEBUG, "access granted from %s",
99 host_name ? host_name : host_addr);
109 * c-file-style: "Stroustrup"
110 * indent-tabs-mode: nil
112 * vim: shiftwidth=4 tabstop=8 expandtab