Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/tcpdmatch.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
#include "inetcf.h" | #include "inetcf.h" | ||||
#include "scaffold.h" | #include "scaffold.h" | ||||
static void usage(char *myname); | static void usage(char *myname); | ||||
static void tcpdmatch(struct request_info *request); | static void tcpdmatch(struct request_info *request); | ||||
/* The main program */ | /* The main program */ | ||||
int main(argc, argv) | int main(int argc, char **argv) | ||||
int argc; | |||||
char **argv; | |||||
{ | { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct addrinfo hints, *hp, *res; | struct addrinfo hints, *hp, *res; | ||||
#else | #else | ||||
struct hostent *hp; | struct hostent *hp; | ||||
#endif | #endif | ||||
char *myname = argv[0]; | char *myname = argv[0]; | ||||
char *client; | char *client; | ||||
▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | if (hp->h_addr_list[count + 1]) | ||||
} | } | ||||
free((char *) hp); | free((char *) hp); | ||||
#endif | #endif | ||||
exit(0); | exit(0); | ||||
} | } | ||||
/* Explain how to use this program */ | /* Explain how to use this program */ | ||||
static void usage(myname) | static void usage(char *myname) | ||||
char *myname; | |||||
{ | { | ||||
fprintf(stderr, "usage: %s [-d] [-i inet_conf] daemon[@host] [user@]host\n", | fprintf(stderr, "usage: %s [-d] [-i inet_conf] daemon[@host] [user@]host\n", | ||||
myname); | myname); | ||||
fprintf(stderr, " -d: use allow/deny files in current directory\n"); | fprintf(stderr, " -d: use allow/deny files in current directory\n"); | ||||
fprintf(stderr, " -i: location of inetd.conf file\n"); | fprintf(stderr, " -i: location of inetd.conf file\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
/* Print interesting expansions */ | /* Print interesting expansions */ | ||||
static void expand(text, pattern, request) | static void expand(char *text, char *pattern, struct request_info *request) | ||||
char *text; | |||||
char *pattern; | |||||
struct request_info *request; | |||||
{ | { | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
if (STR_NE(percent_x(buf, sizeof(buf), pattern, request), unknown)) | if (STR_NE(percent_x(buf, sizeof(buf), pattern, request), unknown)) | ||||
printf("%s %s\n", text, buf); | printf("%s %s\n", text, buf); | ||||
} | } | ||||
/* Try out a (server,client) pair */ | /* Try out a (server,client) pair */ | ||||
static void tcpdmatch(request) | static void tcpdmatch(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
int verdict; | int verdict; | ||||
/* | /* | ||||
* Show what we really know. Suppress uninteresting noise. | * Show what we really know. Suppress uninteresting noise. | ||||
*/ | */ | ||||
expand("client: hostname", "%n", request); | expand("client: hostname", "%n", request); | ||||
expand("client: address ", "%a", request); | expand("client: address ", "%a", request); | ||||
Show All 36 Lines |