Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/eval.c
Show All 36 Lines | /* | ||||
* host name has the value STRING_PARANOID it means there was a name/address | * host name has the value STRING_PARANOID it means there was a name/address | ||||
* conflict. | * conflict. | ||||
*/ | */ | ||||
char unknown[] = STRING_UNKNOWN; | char unknown[] = STRING_UNKNOWN; | ||||
char paranoid[] = STRING_PARANOID; | char paranoid[] = STRING_PARANOID; | ||||
/* eval_user - look up user name */ | /* eval_user - look up user name */ | ||||
char *eval_user(request) | char *eval_user(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
if (request->user[0] == 0) { | if (request->user[0] == 0) { | ||||
strcpy(request->user, unknown); | strcpy(request->user, unknown); | ||||
if (request->sink == 0 && request->client->sin && request->server->sin) | if (request->sink == 0 && request->client->sin && request->server->sin) | ||||
rfc931(request->client->sin, request->server->sin, request->user); | rfc931(request->client->sin, request->server->sin, request->user); | ||||
} | } | ||||
return (request->user); | return (request->user); | ||||
} | } | ||||
/* eval_hostaddr - look up printable address */ | /* eval_hostaddr - look up printable address */ | ||||
char *eval_hostaddr(host) | char *eval_hostaddr(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
if (host->addr[0] == 0) { | if (host->addr[0] == 0) { | ||||
strcpy(host->addr, unknown); | strcpy(host->addr, unknown); | ||||
if (host->request->hostaddr != 0) | if (host->request->hostaddr != 0) | ||||
host->request->hostaddr(host); | host->request->hostaddr(host); | ||||
} | } | ||||
return (host->addr); | return (host->addr); | ||||
} | } | ||||
/* eval_hostname - look up host name */ | /* eval_hostname - look up host name */ | ||||
char *eval_hostname(host) | char *eval_hostname(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
if (host->name[0] == 0) { | if (host->name[0] == 0) { | ||||
strcpy(host->name, unknown); | strcpy(host->name, unknown); | ||||
if (host->request->hostname != 0) | if (host->request->hostname != 0) | ||||
host->request->hostname(host); | host->request->hostname(host); | ||||
} | } | ||||
return (host->name); | return (host->name); | ||||
} | } | ||||
/* eval_hostinfo - return string with host name (preferred) or address */ | /* eval_hostinfo - return string with host name (preferred) or address */ | ||||
char *eval_hostinfo(host) | char *eval_hostinfo(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
char *hostname; | char *hostname; | ||||
#ifndef ALWAYS_HOSTNAME /* no implicit host lookups */ | #ifndef ALWAYS_HOSTNAME /* no implicit host lookups */ | ||||
if (host->name[0] == 0) | if (host->name[0] == 0) | ||||
return (eval_hostaddr(host)); | return (eval_hostaddr(host)); | ||||
#endif | #endif | ||||
hostname = eval_hostname(host); | hostname = eval_hostname(host); | ||||
if (HOSTNAME_KNOWN(hostname)) { | if (HOSTNAME_KNOWN(hostname)) { | ||||
return (host->name); | return (host->name); | ||||
} else { | } else { | ||||
return (eval_hostaddr(host)); | return (eval_hostaddr(host)); | ||||
} | } | ||||
} | } | ||||
/* eval_client - return string with as much about the client as we know */ | /* eval_client - return string with as much about the client as we know */ | ||||
char *eval_client(request) | char *eval_client(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
static char both[2 * STRING_LENGTH]; | static char both[2 * STRING_LENGTH]; | ||||
char *hostinfo = eval_hostinfo(request->client); | char *hostinfo = eval_hostinfo(request->client); | ||||
#ifndef ALWAYS_RFC931 /* no implicit user lookups */ | #ifndef ALWAYS_RFC931 /* no implicit user lookups */ | ||||
if (request->user[0] == 0) | if (request->user[0] == 0) | ||||
return (hostinfo); | return (hostinfo); | ||||
#endif | #endif | ||||
if (STR_NE(eval_user(request), unknown)) { | if (STR_NE(eval_user(request), unknown)) { | ||||
sprintf(both, "%s@%s", request->user, hostinfo); | sprintf(both, "%s@%s", request->user, hostinfo); | ||||
return (both); | return (both); | ||||
} else { | } else { | ||||
return (hostinfo); | return (hostinfo); | ||||
} | } | ||||
} | } | ||||
/* eval_server - return string with as much about the server as we know */ | /* eval_server - return string with as much about the server as we know */ | ||||
char *eval_server(request) | char *eval_server(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
static char both[2 * STRING_LENGTH]; | static char both[2 * STRING_LENGTH]; | ||||
char *host = eval_hostinfo(request->server); | char *host = eval_hostinfo(request->server); | ||||
char *daemon = eval_daemon(request); | char *daemon = eval_daemon(request); | ||||
if (STR_NE(host, unknown)) { | if (STR_NE(host, unknown)) { | ||||
sprintf(both, "%s@%s", daemon, host); | sprintf(both, "%s@%s", daemon, host); | ||||
return (both); | return (both); | ||||
} else { | } else { | ||||
return (daemon); | return (daemon); | ||||
} | } | ||||
} | } |