1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 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;
56 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
58 const char *daemon_name = (const char *) cd;
62 if (daemon_name && *daemon_name)
65 struct request_info request_info;
67 char *host_name = 0, *host_addr = 0;
70 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
72 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
73 sizeof(addr_in->sin_addr),
75 host_name = (char*) host->h_name;
76 host_addr = inet_ntoa(addr_in->sin_addr);
77 if (host_addr && host_name)
78 request_init(&request_info, RQ_DAEMON, daemon_name,
79 RQ_CLIENT_NAME, host_name,
80 RQ_CLIENT_SIN, addr_in,
81 RQ_CLIENT_ADDR, host_addr, 0);
83 request_init(&request_info, RQ_DAEMON, daemon_name,
84 RQ_CLIENT_SIN, addr_in, 0);
85 i = hosts_access(&request_info);
88 yaz_log(YLOG_DEBUG, "access denied from %s",
89 host_name ? host_name : host_addr);
92 yaz_log(YLOG_DEBUG, "access granted from %s",
93 host_name ? host_name : host_addr);
103 * c-file-style: "Stroustrup"
104 * indent-tabs-mode: nil
106 * vim: shiftwidth=4 tabstop=8 expandtab