# 2.11BSD#431 - /usr/src/libexec/tcpd/eval.c

##### Functions

    eval_client       X
    eval_hostaddr     X
    eval_hostinfo     X
    eval_hostname     X
    eval_server       X
    eval_user         X

##### Variables

    paranoid          X
    unknown           X

       1:  /*
       2:   * Routines for controlled evaluation of host names, user names, and so on.
       3:   * They are, in fact, wrappers around the functions that are specific for
       4:   * the sockets or TLI programming interfaces. The request_info and host_info
       5:   * structures are used for result cacheing.
       6:   *
       7:   * These routines allows us to postpone expensive operations until their
       8:   * results are really needed. Examples are hostname lookups and double
       9:   * checks, or username lookups. Information that cannot be retrieved is
      10:   * given the value "unknown" ("paranoid" in case of hostname problems).
      11:   *
      12:   * When ALWAYS_HOSTNAME is off, hostname lookup is done only when required by
      13:   * tcpd paranoid mode, by access control patterns, or by %letter expansions.
      14:   *
      15:   * When ALWAYS_RFC931 mode is off, user lookup is done only when required by
      16:   * access control patterns or %letter expansions.
      17:   *
      18:   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
      19:   */
      20:
      21: #ifndef lint
      22: static char sccsid[] = "@(#) eval.c 1.3 95/01/30 19:51:45";
      23: #endif
      24:
      25: /* System libraries. */
      26:
      27: #include <stdio.h>
      28: #include <string.h>
      29:
      30: /* Local stuff. */
      31:
      32: #include "tcpd.h"
      33:
      34:  /*
      35:   * When a string has the value STRING_UNKNOWN, it means: don't bother, I
      36:   * tried to look up the data but it was unavailable for some reason. When a
      37:   * host name has the value STRING_PARANOID it means there was a name/address
      38:   * conflict.
      39:   */
      40: char    unknown[] = STRING_UNKNOWN;
      41: char    paranoid[] = STRING_PARANOID;
      42:
      43: /* eval_user - look up user name */
      44:
      45: char   *eval_user(request)
      46: struct request_info *request;
      47: {
      48:     if (request->user[0] == 0) {
      49:     strcpy(request->user, unknown);
      50:     if (request->sink == 0 && request->client->sin && request->server->sin)
      51:         rfc931(request->client->sin, request->server->sin, request->user);
      52:     }
      53:     return (request->user);
      54: }
      55:
      56: /* eval_hostaddr - look up printable address */
      57:
      58: char   *eval_hostaddr(host)
      59: struct host_info *host;
      60: {
      61:     if (host->addr[0] == 0) {
      62:     strcpy(host->addr, unknown);
      63:     if (host->request->hostaddr != 0)
      64:         host->request->hostaddr(host);
      65:     }
      66:     return (host->addr);
      67: }
      68:
      69: /* eval_hostname - look up host name */
      70:
      71: char   *eval_hostname(host)
      72: struct host_info *host;
      73: {
      74:     if (host->name[0] == 0) {
      75:     strcpy(host->name, unknown);
      76:     if (host->request->hostname != 0)
      77:         host->request->hostname(host);
      78:     }
      79:     return (host->name);
      80: }
      81:
      82: /* eval_hostinfo - return string with host name (preferred) or address */
      83:
      84: char   *eval_hostinfo(host)
      85: struct host_info *host;
      86: {
      87:     char   *hostname;
      88:
      89: #ifndef ALWAYS_HOSTNAME             /* no implicit host lookups */
      90:     if (host->name[0] == 0)
      91:     return (eval_hostaddr(host));
      92: #endif
      93:     hostname = eval_hostname(host);
      94:     if (HOSTNAME_KNOWN(hostname)) {
      95:     return (host->name);
      96:     } else {
      97:     return (eval_hostaddr(host));
      98:     }
      99: }
     100:
     101: /* eval_client - return string with as much about the client as we know */
     102:
     103: char   *eval_client(request)
     104: struct request_info *request;
     105: {
     106:     static char both[2 * STRING_LENGTH];
     107:     char   *hostinfo = eval_hostinfo(request->client);
     108:
     109: #ifndef ALWAYS_RFC931               /* no implicit user lookups */
     110:     if (request->user[0] == 0)
     111:     return (hostinfo);
     112: #endif
     113:     if (STR_NE(eval_user(request), unknown)) {
     114:     sprintf(both, "%s@%s", request->user, hostinfo);
     115:     return (both);
     116:     } else {
     117:     return (hostinfo);
     118:     }
     119: }
     120:
     121: /* eval_server - return string with as much about the server as we know */
     122:
     123: char   *eval_server(request)
     124: struct request_info *request;
     125: {
     126:     static char both[2 * STRING_LENGTH];
     127:     char   *host = eval_hostinfo(request->server);
     128:     char   *daemon = eval_daemon(request);
     129:
     130:     if (STR_NE(host, unknown)) {
     131:     sprintf(both, "%s@%s", daemon, host);
     132:     return (both);
     133:     } else {
     134:     return (daemon);
     135:     }
     136: }

#### Defined functions

eval_client defined in line 103; used 7 times

- in /usr/src/libexec/tcpd/fix_options.c line 45
- in /usr/src/libexec/tcpd/miscd.c line 113
- in /usr/src/libexec/tcpd/options.c line 375
- in /usr/src/libexec/tcpd/percent_x.c line 59
- in /usr/src/libexec/tcpd/refuse.c line 28
- in /usr/src/libexec/tcpd/tcpd.c line 123
- in /usr/src/libexec/tcpd/tcpd.h line 123

eval_hostaddr defined in line 58; used 12 times

- in line 91, 97
- in /usr/src/libexec/tcpd/hosts_access.c line 263-270(3)
- in /usr/src/libexec/tcpd/percent_x.c line 57-58(2)
- in /usr/src/libexec/tcpd/scaffold.c line 152
- in /usr/src/libexec/tcpd/tcpd.h line 121
- in /usr/src/libexec/tcpd/tcpdmatch.c line 177, 234
- in /usr/src/libexec/tcpd/tli.c line 264

eval_hostinfo defined in line 84; used 5 times

- in line 107, 127
- in /usr/src/libexec/tcpd/percent_x.c line 61-62(2)
- in /usr/src/libexec/tcpd/tcpd.h line 122

eval_hostname defined in line 71; used 14 times

- in line 93
- in /usr/src/libexec/tcpd/hosts_access.c line 256, 262-265(2), 271
- in /usr/src/libexec/tcpd/miscd.c line 85
- in /usr/src/libexec/tcpd/percent_x.c line 63-64(2)
- in /usr/src/libexec/tcpd/scaffold.c line 150
- in /usr/src/libexec/tcpd/tcpd.c line 95
- in /usr/src/libexec/tcpd/tcpd.h line 120
- in /usr/src/libexec/tcpd/tcpdmatch.c line 175, 232, 302

eval_server defined in line 123; used 2 times

- in /usr/src/libexec/tcpd/percent_x.c line 66
- in /usr/src/libexec/tcpd/tcpd.h line 124

eval_user defined in line 45; used 5 times

- in line 113
- in /usr/src/libexec/tcpd/hosts_access.c line 230
- in /usr/src/libexec/tcpd/options.c line 413
- in /usr/src/libexec/tcpd/percent_x.c line 67
- in /usr/src/libexec/tcpd/tcpd.h line 119

#### Defined variables

paranoid defined in line 41; used 4 times

- in /usr/src/libexec/tcpd/tcpd.h line 57
- in /usr/src/libexec/tcpd/tcpdchk.c line 444
- in /usr/src/libexec/tcpd/tcpdmatch.c line 302
- in /usr/src/libexec/tcpd/tli.c line 286

sccsid defined in line 22; never used
unknown defined in line 40; used 15 times

- in line 49, 62, 75, 113, 130
- in /usr/src/libexec/tcpd/tcpd.h line 57
- in /usr/src/libexec/tcpd/tcpdchk.c line 342, 374, 442
- in /usr/src/libexec/tcpd/tcpdmatch.c line 101, 117, 175, 232, 264
- in /usr/src/libexec/tcpd/update.c line 99

Last modified: 1995-01-30 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 732 |