2 * This program can be called via a remote shell command to find out if the
3 * hostname and address are properly recognized, if username lookup works,
4 * and (SysV only) if the TLI on top of IP heuristics work.
6 * Example: "rsh host /some/where/try-from".
8 * Diagnostics are reported through syslog(3) and redirected to stderr.
10 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
14 static char sccsid
[] = "@(#) try-from.c 1.2 94/12/28 17:42:55";
17 /* System libraries. */
19 #include <sys/types.h>
25 #include <sys/tiuser.h>
30 #define STDIN_FILENO 0
37 int allow_severity
= SEVERITY
; /* run-time adjustable */
38 int deny_severity
= LOG_WARNING
; /* ditto */
44 struct request_info request
;
49 * Simplify the process name, just like tcpd would.
51 if ((cp
= strrchr(argv
[0], '/')) != 0)
55 * Turn on the "IP-underneath-TLI" detection heuristics.
58 if (ioctl(0, I_FIND
, "timod") == 0)
59 ioctl(0, I_PUSH
, "timod");
63 * Look up the endpoint information.
65 request_init(&request
, RQ_DAEMON
, argv
[0], RQ_FILE
, STDIN_FILENO
, 0);
66 (void) fromhost(&request
);
69 * Show some results. Name and address information is looked up when we
73 #define EXPAND(str) percent_x(buf, sizeof(buf), str, &request)
75 puts(EXPAND("client address (%%a): %a"));
76 puts(EXPAND("client hostname (%%n): %n"));
77 puts(EXPAND("client username (%%u): %u"));
78 puts(EXPAND("client info (%%c): %c"));
79 puts(EXPAND("server address (%%A): %A"));
80 puts(EXPAND("server hostname (%%N): %N"));
81 puts(EXPAND("server process (%%d): %d"));
82 puts(EXPAND("server info (%%s): %s"));