Release bumped to "gts4".
[tac_plus.git] / tcpwrap.c
1 /*
2    This function  use for check access control rules from hosts.deny and
3    hosts.access file.
4    Writen by Devrim SERAL<devrim@gazi.edu.tr>. This file protected by
5    GNU Copyright agreement.
6 */
7
8
9 #include "tac_plus.h"
10
11 #ifdef TCPWRAPPER
12
13 #include <tcpd.h>
14
15 #include "tcpwrap.h"
16 #include "report.h"
17 #include "packet.h"
18 #include "do_author.h"                  /* for "struct identity" */
19 #include "main.h"
20
21
22 int allow_severity = LOG_INFO;          /* *_severity accessed from libwrap */
23 int deny_severity = LOG_WARNING;
24
25
26 /* Configurable:
27  */
28
29 /* Define tac_plus name for hosts.* files */
30 #define TACNAME                         "tac_plus"
31
32
33 int check_from_wrap TAC_ARGS((struct identity *datap));
34
35 int
36 check_from_wrap(datap)
37 struct identity *datap;
38 {
39     struct request_info req;
40
41     request_init(&req, RQ_FILE,session.sock,RQ_DAEMON,TACNAME,RQ_CLIENT_ADDR,datap->NAS_name , NULL);
42     fromhost(&req); /* validate client host info */
43     if (!hosts_access(&req))
44       {
45         if (debug & DEBUG_AUTHEN_FLAG)
46                 report(LOG_DEBUG, "Access denied for NAS=%s",datap->NAS_name);
47         send_authen_error("You are not allowed to access here");
48         refuse(&req); /* If connection is not allowed, clean up and exit. */
49         return 0;
50       }
51
52     if (debug & DEBUG_AUTHEN_FLAG )
53                 report(LOG_DEBUG, "Access permited for NAS=%s",datap->NAS_name);
54 return 1;
55
56 }
57
58 #else /* TCPWRAPPER */
59
60 TAC_SOURCEFILE_EMPTY
61
62 #endif /* TCPWRAPPER */