1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2011 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements TCP WRAPPER check.
22 #include <sys/types.h>
26 #include <netinet/in.h>
30 #include <arpa/inet.h>
34 /* freebsd wants this for AF_INET */
35 #include <sys/socket.h>
42 #include <yaz/comstack.h>
43 #include <yaz/statserv.h>
51 int allow_severity = LOG_INFO; /* not YLOG !! */
52 int deny_severity = LOG_WARNING;
63 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
65 const char *daemon_name = (const char *) cd;
69 if (daemon_name && *daemon_name)
72 struct request_info request_info;
75 char *host_name = 0, *host_addr = 0;
78 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
80 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
81 sizeof(addr_in->sin_addr),
83 host_name = (char*) host->h_name;
84 host_addr = inet_ntoa(addr_in->sin_addr);
87 request_init(&request_info, RQ_DAEMON, daemon_name,
88 RQ_CLIENT_NAME, host_name,
89 RQ_CLIENT_SIN, addr_in,
90 RQ_CLIENT_ADDR, host_addr, 0);
92 request_init(&request_info, RQ_DAEMON, daemon_name,
93 RQ_CLIENT_SIN, addr_in,
94 RQ_CLIENT_ADDR, host_addr, 0);
95 i = hosts_access(&request_info);
98 yaz_log (YLOG_DEBUG, "access denied from %s",
99 host_name ? host_name : host_addr);
102 yaz_log (YLOG_DEBUG, "access granted from %s",
103 host_name ? host_name : host_addr);
113 * c-file-style: "Stroustrup"
114 * indent-tabs-mode: nil
116 * vim: shiftwidth=4 tabstop=8 expandtab