dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / tcpd / try-from.c
blob3f6dd95870482092175a065d48451aa50017b466
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 static char sccsid[] = "@(#) try-from.c 1.2 94/12/28 17:42:55";
15 /* System libraries. */
17 #include <sys/types.h>
18 #include <stdio.h>
19 #include <syslog.h>
20 #include <string.h>
22 #ifdef TLI
23 #include <sys/tiuser.h>
24 #include <stropts.h>
25 #endif
27 #ifndef STDIN_FILENO
28 #define STDIN_FILENO 0
29 #endif
31 /* Local stuff. */
33 #include "tcpd.h"
35 int allow_severity = SEVERITY; /* run-time adjustable */
36 int deny_severity = LOG_WARNING; /* ditto */
38 int
39 main(argc, argv)
40 int argc;
41 char **argv;
43 struct request_info request;
44 char buf[BUFSIZ];
45 char *cp;
48 * Simplify the process name, just like tcpd would.
50 if ((cp = strrchr(argv[0], '/')) != 0)
51 argv[0] = cp + 1;
54 * Turn on the "IP-underneath-TLI" detection heuristics.
56 #ifdef TLI
57 if (ioctl(0, I_FIND, "timod") == 0)
58 ioctl(0, I_PUSH, "timod");
59 #endif /* TLI */
62 * Look up the endpoint information.
64 request_init(&request, RQ_DAEMON, argv[0], RQ_FILE, STDIN_FILENO, 0);
65 (void) fromhost(&request);
68 * Show some results. Name and address information is looked up when we
69 * ask for it.
72 #define EXPAND(str) percent_x(buf, sizeof(buf), str, &request)
74 puts(EXPAND("client address (%%a): %a"));
75 puts(EXPAND("client hostname (%%n): %n"));
76 puts(EXPAND("client username (%%u): %u"));
77 puts(EXPAND("client info (%%c): %c"));
78 puts(EXPAND("server address (%%A): %A"));
79 puts(EXPAND("server hostname (%%N): %N"));
80 puts(EXPAND("server process (%%d): %d"));
81 puts(EXPAND("server info (%%s): %s"));
83 return (0);