Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/scaffold.c
Show All 37 Lines | /* | ||||
* These are referenced by the options module and by rfc931.c. | * These are referenced by the options module and by rfc931.c. | ||||
*/ | */ | ||||
int allow_severity = SEVERITY; | int allow_severity = SEVERITY; | ||||
int deny_severity = LOG_WARNING; | int deny_severity = LOG_WARNING; | ||||
#ifndef INET6 | #ifndef INET6 | ||||
/* dup_hostent - create hostent in one memory block */ | /* dup_hostent - create hostent in one memory block */ | ||||
static struct hostent *dup_hostent(hp) | static struct hostent *dup_hostent(struct hostent *hp) | ||||
struct hostent *hp; | |||||
{ | { | ||||
struct hostent_block { | struct hostent_block { | ||||
struct hostent host; | struct hostent host; | ||||
char *addr_list[1]; | char *addr_list[1]; | ||||
}; | }; | ||||
struct hostent_block *hb; | struct hostent_block *hb; | ||||
int count; | int count; | ||||
char *data; | char *data; | ||||
Show All 19 Lines | memcpy(hb->host.h_addr_list[count], addr, hp->h_length); | ||||
} | } | ||||
return (&hb->host); | return (&hb->host); | ||||
} | } | ||||
#endif | #endif | ||||
/* find_inet_addr - find all addresses for this host, result to free() */ | /* find_inet_addr - find all addresses for this host, result to free() */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct addrinfo *find_inet_addr(host) | struct addrinfo *find_inet_addr(char *host) | ||||
char *host; | |||||
{ | { | ||||
struct addrinfo hints, *res; | struct addrinfo hints, *res; | ||||
memset(&hints, 0, sizeof(hints)); | memset(&hints, 0, sizeof(hints)); | ||||
hints.ai_family = PF_UNSPEC; | hints.ai_family = PF_UNSPEC; | ||||
hints.ai_socktype = SOCK_STREAM; | hints.ai_socktype = SOCK_STREAM; | ||||
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; | hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; | ||||
if (getaddrinfo(host, NULL, &hints, &res) == 0) | if (getaddrinfo(host, NULL, &hints, &res) == 0) | ||||
Show All 17 Lines | struct addrinfo *find_inet_addr(char *host) | ||||
tcpd_warn("(cannot obtain official name)", res->ai_canonname); | tcpd_warn("(cannot obtain official name)", res->ai_canonname); | ||||
} else if (STR_NE(host, res->ai_canonname)) { | } else if (STR_NE(host, res->ai_canonname)) { | ||||
tcpd_warn("%s: hostname alias", host); | tcpd_warn("%s: hostname alias", host); | ||||
tcpd_warn("(official name: %.*s)", STRING_LENGTH, res->ai_canonname); | tcpd_warn("(official name: %.*s)", STRING_LENGTH, res->ai_canonname); | ||||
} | } | ||||
return (res); | return (res); | ||||
} | } | ||||
#else | #else | ||||
struct hostent *find_inet_addr(host) | struct hostent *find_inet_addr(char *host) | ||||
char *host; | |||||
{ | { | ||||
struct in_addr addr; | struct in_addr addr; | ||||
struct hostent *hp; | struct hostent *hp; | ||||
static struct hostent h; | static struct hostent h; | ||||
static char *addr_list[2]; | static char *addr_list[2]; | ||||
/* | /* | ||||
* Host address: translate it to internal form. | * Host address: translate it to internal form. | ||||
Show All 28 Lines | struct hostent *find_inet_addr(char *host) | ||||
tcpd_warn("(official name: %.*s)", STRING_LENGTH, hp->h_name); | tcpd_warn("(official name: %.*s)", STRING_LENGTH, hp->h_name); | ||||
} | } | ||||
return (dup_hostent(hp)); | return (dup_hostent(hp)); | ||||
} | } | ||||
#endif | #endif | ||||
/* check_dns - give each address thorough workout, return address count */ | /* check_dns - give each address thorough workout, return address count */ | ||||
int check_dns(host) | int check_dns(char *host) | ||||
char *host; | |||||
{ | { | ||||
struct request_info request; | struct request_info request; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct sockaddr_storage sin; | struct sockaddr_storage sin; | ||||
struct addrinfo *hp, *res; | struct addrinfo *hp, *res; | ||||
#else | #else | ||||
struct sockaddr_in sin; | struct sockaddr_in sin; | ||||
struct hostent *hp; | struct hostent *hp; | ||||
Show All 36 Lines | |||||
#endif | #endif | ||||
return (count); | return (count); | ||||
} | } | ||||
/* dummy function to intercept the real shell_cmd() */ | /* dummy function to intercept the real shell_cmd() */ | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
void shell_cmd(command) | void shell_cmd(char *command) | ||||
char *command; | |||||
{ | { | ||||
if (hosts_access_verbose) | if (hosts_access_verbose) | ||||
printf("command: %s", command); | printf("command: %s", command); | ||||
} | } | ||||
/* dummy function to intercept the real clean_exit() */ | /* dummy function to intercept the real clean_exit() */ | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
void clean_exit(request) | void clean_exit(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
exit(0); | exit(0); | ||||
} | } | ||||
/* check_path - examine accessibility */ | /* check_path - examine accessibility */ | ||||
int check_path(path, st) | int check_path(char *path, struct stat *st) | ||||
char *path; | |||||
struct stat *st; | |||||
{ | { | ||||
struct stat stbuf; | struct stat stbuf; | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
if (stat(path, st) < 0) | if (stat(path, st) < 0) | ||||
return (-1); | return (-1); | ||||
#ifdef notdef | #ifdef notdef | ||||
if (st->st_uid != 0) | if (st->st_uid != 0) | ||||
Show All 12 Lines |