1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements TCP WRAPPER check.
14 #include <sys/types.h>
20 #include <netinet/in.h>
22 #include <arpa/inet.h>
23 #include <netinet/tcp.h>
27 #include <sys/socket.h>
30 #include <yaz/yconfig.h>
31 #include <yaz/comstack.h>
32 #include <yaz/statserv.h>
40 int allow_severity = LOG_INFO; /* not YLOG !! */
41 int deny_severity = LOG_WARNING;
52 int check_ip_tcpd(void *cd, const char *addr, int len, int type)
54 const char *daemon_name = (const char *) cd;
58 if (daemon_name && *daemon_name)
61 struct request_info request_info;
64 char *host_name = 0, *host_addr = 0;
67 struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
69 if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
70 sizeof(addr_in->sin_addr),
72 host_name = (char*) host->h_name;
73 host_addr = inet_ntoa(addr_in->sin_addr);
76 request_init(&request_info, RQ_DAEMON, daemon_name,
77 RQ_CLIENT_NAME, host_name,
78 RQ_CLIENT_SIN, addr_in,
79 RQ_CLIENT_ADDR, host_addr, 0);
81 request_init(&request_info, RQ_DAEMON, daemon_name,
82 RQ_CLIENT_SIN, addr_in,
83 RQ_CLIENT_ADDR, host_addr, 0);
84 i = hosts_access(&request_info);
87 yaz_log (YLOG_DEBUG, "access denied from %s",
88 host_name ? host_name : host_addr);
91 yaz_log (YLOG_DEBUG, "access granted from %s",
92 host_name ? host_name : host_addr);
102 * indent-tabs-mode: nil
104 * vim: shiftwidth=4 tabstop=8 expandtab