/*
* tcpdmatch - explain what tcpd would do in a specific case
*
* usage: tcpdmatch [-d] [-i inet_conf] daemon[@host] [user@]host
*
* -d: use the access control tables in the current directory.
*
* -i: location of inetd.conf file.
*
* All errors are reported to the standard error stream, including the errors
* that would normally be reported via the syslog daemon.
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
#endif
/* System libraries. */
#include <netdb.h>
#include <stdio.h>
#include <syslog.h>
#include <setjmp.h>
#include <string.h>
extern void exit();
extern int optind;
extern char *optarg;
#ifndef INADDR_NONE
#endif
#ifndef S_ISDIR
#endif
/* Application-specific. */
#include "tcpd.h"
#include "inetcf.h"
#include "scaffold.h"
static void usage();
static void tcpdmatch();
/* The main program */
int argc;
char **argv;
{
char *client;
char *server;
char *addr;
char *user;
char *daemon;
int ch;
char *inetcf = 0;
int count;
/*
* Show what rule actually matched.
*/
hosts_access_verbose = 2;
/*
* Parse the JCL.
*/
switch (ch) {
case 'd':
hosts_allow_table = "hosts.allow";
hosts_deny_table = "hosts.deny";
break;
case 'i':
break;
default:
/* NOTREACHED */
}
}
/*
* When confusion really strikes...
*/
}
/*
* Default is to specify a daemon process name. When daemon@host is
* specified, separate the two parts.
*/
} else {
}
/*
* Default is to specify a client hostname or address. When user@host is
* specified, separate the two parts.
*/
} else {
}
/*
* Analyze the inetd (or tlid) configuration file, so that we can warn
* the user about services that may not be wrapped, services that are not
* configured, or services that are wrapped in an incorrect manner. Allow
* for services that are not run from inetd, or that have tcpd access
* control built into them.
*/
case WR_UNKNOWN:
break;
case WR_NOT:
break;
}
/*
* Check accessibility of access control files.
*/
/*
* Fill in what we have figured out sofar. Use socket and DNS routines
* for address and name conversions. We attach stdout to the request so
* that banner messages will become visible.
*/
/*
* If a server hostname is specified, insist that the name maps to at
* most one address. eval_hostname() warns the user about name server
* problems, while using the request.server structure as a cache for host
* address and name conversion results.
*/
exit(1);
/*
* Force evaluation of server host name and address. Host name
* conflicts will be reported while eval_hostname() does its job.
*/
tcpd_warn("host address %s->name lookup failed",
}
if (count > 1) {
exit(1);
}
} else {
}
/*
* If a client address is specified, we simulate the effect of client
* hostname lookup failure.
*/
exit(0);
}
/*
* Perhaps they are testing special client hostname patterns that aren't
* really host names at all.
*/
exit(0);
}
/*
* Otherwise, assume that a client hostname is specified, and insist that
* the address can be looked up. The reason for this requirement is that
* in real life the client address is available (at least with IP). Let
* eval_hostname() figure out if this host is properly registered, while
* using the request.client structure as a cache for host name and
* address conversion results.
*/
exit(1);
/*
* Force evaluation of client host name and address. Host name
* conflicts will be reported while eval_hostname() does its job.
*/
tcpd_warn("host address %s->name lookup failed",
printf("\n");
}
exit(0);
}
/* Explain how to use this program */
char *myname;
{
myname);
exit(1);
}
/* Print interesting expansions */
char *text;
char *pattern;
struct request_info *request;
{
}
/* Try out a (server,client) pair */
struct request_info *request;
{
int verdict;
/*
* Show what we really know. Suppress uninteresting noise.
*/
/*
* Reset stuff that might be changed by options handlers. In dry-run
* mode, extension language routines that would not return should inform
* us of their plan, by clearing the dry_run flag. This is a bit clumsy
* but we must be able to verify hosts with more than one network
* address.
*/
dry_run = 1;
/*
* When paranoid mode is enabled, access is rejected no matter what the
* access control rules say.
*/
#ifdef PARANOID
printf("access: denied (PARANOID mode)\n\n");
return;
}
#endif
/*
* Report the access control verdict.
*/
printf("access: %s\n",
dry_run == 0 ? "delegated" :
}