8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / tcpd / try-from.c
blob8d337ca042133c50de4fd67e0b34383b45b9ea33
1 /*
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.
5 *
6 * Example: "rsh host /some/where/try-from".
7 *
8 * Diagnostics are reported through syslog(3) and redirected to stderr.
9 *
10 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
13 #ifndef lint
14 static char sccsid[] = "@(#) try-from.c 1.2 94/12/28 17:42:55";
15 #endif
17 /* System libraries. */
19 #include <sys/types.h>
20 #include <stdio.h>
21 #include <syslog.h>
22 #include <string.h>
24 #ifdef TLI
25 #include <sys/tiuser.h>
26 #include <stropts.h>
27 #endif
29 #ifndef STDIN_FILENO
30 #define STDIN_FILENO 0
31 #endif
33 /* Local stuff. */
35 #include "tcpd.h"
37 int allow_severity = SEVERITY; /* run-time adjustable */
38 int deny_severity = LOG_WARNING; /* ditto */
40 int
41 main(argc, argv)
42 int argc;
43 char **argv;
45 struct request_info request;
46 char buf[BUFSIZ];
47 char *cp;
50 * Simplify the process name, just like tcpd would.
52 if ((cp = strrchr(argv[0], '/')) != 0)
53 argv[0] = cp + 1;
56 * Turn on the "IP-underneath-TLI" detection heuristics.
58 #ifdef TLI
59 if (ioctl(0, I_FIND, "timod") == 0)
60 ioctl(0, I_PUSH, "timod");
61 #endif /* TLI */
64 * Look up the endpoint information.
66 request_init(&request, RQ_DAEMON, argv[0], RQ_FILE, STDIN_FILENO, 0);
67 (void) fromhost(&request);
70 * Show some results. Name and address information is looked up when we
71 * ask for it.
74 #define EXPAND(str) percent_x(buf, sizeof(buf), str, &request)
76 puts(EXPAND("client address (%%a): %a"));
77 puts(EXPAND("client hostname (%%n): %n"));
78 puts(EXPAND("client username (%%u): %u"));
79 puts(EXPAND("client info (%%c): %c"));
80 puts(EXPAND("server address (%%A): %A"));
81 puts(EXPAND("server hostname (%%N): %N"));
82 puts(EXPAND("server process (%%d): %d"));
83 puts(EXPAND("server info (%%s): %s"));
85 return (0);