2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)main.c 8.3 (Berkeley) 5/30/95
30 * $FreeBSD: src/crypto/telnet/telnet/main.c,v 1.4.2.5 2002/04/13 10:59:08 markm Exp $
33 #include <sys/types.h>
34 #include <sys/socket.h>
44 #include <libtelnet/auth.h>
47 #include <libtelnet/encrypt.h>
50 /* These values need to be the same as defined in libtelnet/kerberos5.c */
51 /* Either define them in both places, or put in some common header file. */
52 #define OPTS_FORWARD_CREDS 0x00000002
53 #define OPTS_FORWARDABLE_CREDS 0x00000001
59 int family
= AF_UNSPEC
;
62 * Initialize variables.
79 fprintf(stderr
, "Usage: %s %s%s%s%s\n",
82 "[-4] [-6] [-8] [-E] [-K] [-L] [-N] [-S tos] [-X atype] [-c] [-d]",
83 "\n\t[-e char] [-k realm] [-l user] [-f/-F] [-n tracefile] ",
85 "[-4] [-6] [-8] [-E] [-L] [-N] [-S tos] [-c] [-d]",
86 "\n\t[-e char] [-l user] [-n tracefile] ",
88 "[-r] [-s src_addr] [-u] ",
90 "[-y] [host-name [port]]"
91 #else /* ENCRYPTION */
93 #endif /* ENCRYPTION */
99 * main. Parse arguments, invoke the protocol or command parser.
103 main(int argc
, char *argv
[])
107 char *src_addr
= NULL
;
109 extern int forward_flags
;
112 tninit(); /* Clear out things */
116 if ((prompt
= strrchr(argv
[0], '/')))
123 rlogin
= (strncmp(prompt
, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE
;
124 #ifdef AUTHENTICATION
135 while ((ch
= getopt(argc
, argv
, "468EKLNS:X:acde:fFk:l:n:rs:t:uxy")) != -1) {
146 eight
= 3; /* binary output and input */
149 rlogin
= escape
= _POSIX_VDISABLE
;
152 #ifdef AUTHENTICATION
153 /* It's the default now, so ignore */
157 eight
|= 2; /* binary output only */
167 if ((tos
= parsetos(optarg
, "tcp")) < 0)
168 fprintf(stderr
, "%s%s%s%s\n",
169 prompt
, ": Bad TOS argument '",
171 "; will try to use default TOS");
174 "%s: Warning: -S ignored, no parsetos() support.\n",
180 #ifdef AUTHENTICATION
181 auth_disable_name(optarg
);
194 set_escape_char(optarg
);
197 #ifdef AUTHENTICATION
198 #if defined(KRB5) && defined(FORWARD)
199 if (forward_flags
& OPTS_FORWARD_CREDS
) {
201 "%s: Only one of -f and -F allowed.\n",
205 forward_flags
|= OPTS_FORWARD_CREDS
;
208 "%s: Warning: -f ignored, no Kerberos V5 support.\n",
213 "%s: Warning: -f ignored, no Kerberos V5 support.\n",
218 #ifdef AUTHENTICATION
219 #if defined(KRB5) && defined(FORWARD)
220 if (forward_flags
& OPTS_FORWARD_CREDS
) {
222 "%s: Only one of -f and -F allowed.\n",
226 forward_flags
|= OPTS_FORWARD_CREDS
;
227 forward_flags
|= OPTS_FORWARDABLE_CREDS
;
230 "%s: Warning: -F ignored, no Kerberos V5 support.\n",
235 "%s: Warning: -F ignored, no Kerberos V5 support.\n",
240 #ifdef AUTHENTICATION
243 extern char *dest_realm
, dst_realm_buf
[], dst_realm_sz
;
244 dest_realm
= dst_realm_buf
;
245 (void)strncpy(dest_realm
, optarg
, dst_realm_sz
);
249 "%s: Warning: -k ignored, no Kerberos V4 support.\n",
254 "%s: Warning: -k ignored, no Kerberos V4 support.\n",
259 #ifdef AUTHENTICATION
260 /* This is the default now, so ignore it */
281 "%s: Warning: -x ignored, no ENCRYPT support.\n",
283 #endif /* ENCRYPTION */
291 "%s: Warning: -y ignored, no ENCRYPT support.\n",
293 #endif /* ENCRYPTION */
302 autologin
= (rlogin
== _POSIX_VDISABLE
) ? 0 : 1;
308 char *args
[9], **argp
= args
;
314 *argp
++ = strdup("-l");
318 *argp
++ = strdup("-s");
321 *argp
++ = argv
[0]; /* host */
323 *argp
++ = argv
[1]; /* port */
326 if (setjmp(toplevel
) != 0)
328 if (tn(argp
- args
, args
) == 1)
333 (void)setjmp(toplevel
);