#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1988, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef lint
#endif /* not lint */
#include <sys/sysmacros.h>
#include <signal.h>
#include <netdb.h>
#include <ctype.h>
#include <pwd.h>
#include <errno.h>
#include <strings.h>
#include "general.h"
#include "ring.h"
#include "externs.h"
#include "defines.h"
#include "types.h"
extern char *telnet_krb5_realm;
extern void krb5_profile_get_options(char *, char *,
#include <k5-int.h>
#include <profile/prof_int.h>
{ "forwardable", &forwardable_flag, 0},
{ "forward", &forward_flag, 0},
{ "encrypt", &encrypt_flag, 0 },
{ "autologin", &autologin, 0 },
};
/*
* Number of maximum IPv4 gateways user can specify. This number is limited by
* the maximum size of the IPv4 options in the IPv4 header.
*/
/*
* Number of maximum IPv6 gateways user can specify. This number is limited by
* the maximum header extension length of the IPv6 routing header.
*/
/*
* Depending on the address resolutions of the target and gateways,
* we determine which addresses of the target we'll try connecting to.
*/
#if defined(USE_TOS)
#endif
char *hostname;
static int send_tncmd(void (*func)(), char *, char *);
static int cmdrc(char *, char *);
typedef struct {
} Command;
/*
*/
struct gateway {
};
/*
* IPv4 source routing option.
* In order to avoid padding for the alignment of IPv4 addresses, ipsr_addrs
* is defined as a 2-D array of uint8_t, instead of 1-D array of struct in_addr.
* If it were defined as "struct in_addr ipsr_addrs[1]", "ipsr_ptr" would be
* followed by one byte of padding to avoid misaligned struct in_addr.
*/
struct ip_sourceroute {
/* up to 9 IPv4 addresses */
};
static unsigned linesize = 0;
static int margc;
static unsigned margvlen = 0;
static void
{
if (*fd != -1) {
*fd = -1;
}
}
static void
Free(char **p)
{
if (*p != NULL) {
free(*p);
*p = NULL;
}
}
static void
{
unsigned i;
}
static void
char *str;
{
char **newmargv;
== NULL)
ExitString("telnet: no space for arguments",
}
margc++;
}
static void
makeargv()
{
margc = 0;
cp++;
}
while ((c = *cp) != '\0') {
register int inquote = 0;
while (isspace(c))
c = *++cp;
if (c == '\0')
break;
/*
* For the shell escape, put the rest of the line, less
* leading space, into a single argument, breaking out from
* the loop to prevent the rest of the line being split up
* into smaller arguments.
*/
if (shellcmd)
break;
if (inquote) {
if (c == inquote) {
inquote = 0;
continue;
}
} else {
if (c == '\\') {
if ((c = *++cp) == '\0')
break;
} else if (c == '"') {
inquote = '"';
continue;
} else if (c == '\'') {
inquote = '\'';
continue;
} else if (isspace(c))
break;
}
*cp2++ = c;
}
*cp2 = '\0';
if (c == '\0')
break;
cp++;
}
}
/*
* Make a character string into a number.
*
* Todo: 1. Could take random integers (12, 0x12, 012, 0b1).
*/
static int
special(s)
register char *s;
{
register char c;
char b;
switch (*s) {
case '^':
b = *++s;
if (b == '?') {
c = b | 0x40; /* DEL */
} else {
c = b & 0x1f;
}
break;
default:
c = *s;
break;
}
return (c);
}
/*
* Construct a control character sequence
* for a special character.
*/
static char *
control(c)
register cc_t c;
{
/*
* The only way I could get the Sun 3.5 compiler
* to shut up about
* if ((unsigned int)c >= 0x80)
* was to assign "c" to an unsigned int variable...
* Arggg....
*/
register unsigned int uic = (unsigned int)c;
if (uic == 0x7f)
return ("^?");
if (c == (cc_t)_POSIX_VDISABLE) {
return ("off");
}
if (uic >= 0x80) {
buf[0] = '\\';
buf[4] = 0;
} else if (uic >= 0x20) {
buf[0] = c;
buf[1] = 0;
} else {
buf[0] = '^';
buf[2] = 0;
}
return (buf);
}
/*
* Same as control() except that its only used for escape handling, which uses
* _POSIX_VDISABLE differently and is aided by the use of the state variable
* escape_valid.
*/
static char *
esc_control(c)
register cc_t c;
{
/*
* The only way I could get the Sun 3.5 compiler
* to shut up about
* if ((unsigned int)c >= 0x80)
* was to assign "c" to an unsigned int variable...
* Arggg....
*/
register unsigned int uic = (unsigned int)c;
if (escape_valid == B_FALSE)
return ("off");
if (uic == 0x7f)
return ("^?");
if (uic >= 0x80) {
buf[0] = '\\';
buf[4] = 0;
} else if (uic >= 0x20) {
buf[0] = c;
buf[1] = 0;
} else {
buf[0] = '^';
buf[2] = 0;
}
return (buf);
}
/*
* The following are data structures and routines for
* the "send" command.
*
*/
struct sendlist {
};
static int send_esc(void);
static int send_help(void);
static int send_docmd(char *);
static int send_dontcmd(char *);
static int send_willcmd(char *);
static int send_wontcmd(char *);
{ "help", 0, 0, 0, send_help, 0, 0 },
{ 0 }
};
sizeof (struct sendlist)))
static int
int argc;
char **argv;
{
int i;
struct sendlist *s; /* pointer to current command */
int success = 0;
int needconnect = 0;
if (argc < 2) {
(void) printf(
"need at least one argument for 'send' command\n");
(void) printf("'send ?' for help\n");
return (0);
}
/*
* First, validate all the send arguments.
* In addition, we see how much space we are going to need, and
* whether or not we will be doing a "SYNCH" operation (which
* flushes the network queue).
*/
count = 0;
for (i = 1; i < argc; i++) {
if (s == 0) {
(void) printf("Unknown send argument '%s'\n'send ?' "
"for help.\n", argv[i]);
return (0);
} else if (Ambiguous(s)) {
(void) printf("Ambiguous send argument '%s'\n'send ?' "
"for help.\n", argv[i]);
return (0);
}
"Need %d argument%s to 'send %s' "
"command. 'send %s ?' for help.\n",
return (0);
}
(void) send_help();
return (0);
}
i += s->narg;
needconnect += s->needconnect;
}
if (!connected && needconnect) {
(void) printf("?Need to be connected first.\n");
(void) printf("'send ?' for help\n");
return (0);
}
/* Now, do we have enough room? */
(void) printf("There is not enough room in the buffer "
"TO the network\n");
(void) printf(
"to process your request. Nothing will be done.\n");
(void) printf("('send synch' will throw away most "
"data in the network\n");
(void) printf("buffer, if this might help.)\n");
return (0);
}
/* OK, they are all OK, now go through again and actually send */
count = 0;
for (i = 1; i < argc; i++) {
"Telnet 'send' error - argument disappeared!\n");
(void) quit();
/*NOTREACHED*/
}
if (s->handler) {
count++;
i += s->narg;
} else {
}
}
}
static int
send_esc()
{
return (1);
}
static int
char *name;
{
}
static int
char *name;
{
}
static int
char *name;
{
}
static int
char *name;
{
}
int
void (*func)();
{
char **cpp;
extern char *telopts[];
register int val = 0;
(void) printf("\"value\" must be from 0 to 255\n");
(void) printf("Valid options are:\n\t");
col = 8;
(void) printf("\n\t");
col = 8;
}
}
(void) printf("\n");
return (0);
}
"'%s': ambiguous argument ('send %s ?' for help).\n",
return (0);
}
if (cpp) {
} else {
val *= 10;
cp++;
}
if (*cp != 0) {
"'%s': unknown argument ('send %s ?' for help).\n",
return (0);
"'%s': bad value ('send %s ?' for help).\n",
return (0);
}
}
if (!connected) {
(void) printf("?Need to be connected first.\n");
return (0);
}
return (1);
}
static int
{
struct sendlist *s; /* pointer to current command */
if (s->help)
}
return (0);
}
/*
* The following are the routines and data structures referred
* to by the arguments to the "toggle" command.
*/
static int
lclchars()
{
donelclchars = 1;
return (1);
}
static int
togdebug()
{
if (net > 0 &&
perror("setsockopt (SO_DEBUG)");
}
return (1);
}
static int
togcrlf()
{
if (crlf) {
(void) printf(
"Will send carriage returns as telnet <CR><LF>.\n");
} else {
(void) printf(
"Will send carriage returns as telnet <CR><NUL>.\n");
}
return (1);
}
static int binmode;
static int
int val;
{
donebinarytoggle = 1;
if (val >= 0) {
} else {
if (my_want_state_is_will(TELOPT_BINARY) &&
binmode = 1;
} else if (my_want_state_is_wont(TELOPT_BINARY) &&
binmode = 0;
}
}
if (val == 1) {
if (my_want_state_is_will(TELOPT_BINARY) &&
(void) printf("Already operating in binary mode "
"with remote host.\n");
} else {
(void) printf(
"Negotiating binary mode with remote host.\n");
tel_enter_binary(3);
}
} else {
if (my_want_state_is_wont(TELOPT_BINARY) &&
(void) printf("Already in network ascii mode "
"with remote host.\n");
} else {
(void) printf("Negotiating network ascii mode "
"with remote host.\n");
tel_leave_binary(3);
}
}
return (1);
}
static int
int val;
{
donebinarytoggle = 1;
if (val == -1)
if (val == 1) {
if (my_want_state_is_do(TELOPT_BINARY)) {
(void) printf("Already receiving in binary mode.\n");
} else {
(void) printf("Negotiating binary mode on input.\n");
tel_enter_binary(1);
}
} else {
if (my_want_state_is_dont(TELOPT_BINARY)) {
(void) printf(
"Already receiving in network ascii mode.\n");
} else {
(void) printf(
"Negotiating network ascii mode on input.\n");
tel_leave_binary(1);
}
}
return (1);
}
static int
int val;
{
donebinarytoggle = 1;
if (val == -1)
if (val == 1) {
if (my_want_state_is_will(TELOPT_BINARY)) {
(void) printf("Already transmitting in binary mode.\n");
} else {
(void) printf("Negotiating binary mode on output.\n");
tel_enter_binary(2);
}
} else {
if (my_want_state_is_wont(TELOPT_BINARY)) {
(void) printf(
"Already transmitting in network ascii mode.\n");
} else {
(void) printf(
"Negotiating network ascii mode on output.\n");
tel_leave_binary(2);
}
}
return (1);
}
static int togglehelp(void);
extern int auth_togdebug(int);
struct togglelist {
int *variable;
char *actionexplanation;
};
{ "autoflush",
"flushing of output when sending interrupt characters",
0,
"flush output when sending interrupt characters" },
{ "autosynch",
"automatic sending of interrupt characters in urgent mode",
0,
"send interrupt characters in urgent mode" },
{ "autologin",
0,
{ "authdebug",
"authentication debugging",
0,
"print authentication debugging information" },
{ "autoencrypt",
"automatic encryption of data stream",
0,
"automatically encrypt output" },
{ "autodecrypt",
"automatic decryption of data stream",
0,
"automatically decrypt input" },
{ "verbose_encrypt",
"verbose encryption output",
0,
"print verbose encryption output" },
{ "encdebug",
"encryption debugging",
0,
"print encryption debugging information" },
{ "skiprc",
"don't read ~/.telnetrc file",
0,
&skiprc,
"skip reading of ~/.telnetrc file" },
{ "binary",
"sending and receiving of binary data",
0,
0 },
{ "inbinary",
"receiving of binary data",
0,
0 },
{ "outbinary",
"sending of binary data",
0,
0 },
{ "crlf",
"sending carriage returns as telnet <CR><LF>",
&crlf,
0 },
{ "crmod",
"mapping of received carriage returns",
0,
&crmod,
"map carriage return on output" },
{ "localchars",
"local recognition of certain control characters",
"recognize certain control characters" },
{ " ", "", 0 }, /* empty line */
{ "debug",
"debugging",
&debug,
"turn on socket level debugging" },
{ "netdata",
"printing of hexadecimal network data (debugging)",
0,
&netdata,
"print hexadecimal representation of network traffic" },
{ "prettydump",
"output of \"netdata\" to user readable format (debugging)",
0,
"print user readable output for \"netdata\"" },
{ "options",
"viewing of options processing (debugging)",
0,
"show option processing" },
{ "termdata",
"(debugging) toggle printing of hexadecimal terminal data",
0,
&termdata,
"print hexadecimal representation of terminal traffic" },
{ "?",
0,
togglehelp },
{ "help",
0,
togglehelp },
{ 0 }
};
static int
{
struct togglelist *c;
for (c = Togglelist; c->name; c++) {
if (c->help) {
if (*c->help)
(void) printf(
else
(void) printf("\n");
}
}
(void) printf("\n");
return (0);
}
static void
int set;
{
struct togglelist *c;
for (c = Togglelist; c->name; c++) {
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
}
static int
int argc;
char *argv[];
{
char *name;
struct togglelist *c;
if (argc < 2) {
"Need an argument to 'toggle' command. "
"'toggle ?' for help.\n");
return (0);
}
argc--;
argv++;
while (argc--) {
if (Ambiguous(c)) {
"('toggle ?' for help).\n", name);
return (0);
} else if (c == 0) {
"('toggle ?' for help).\n", name);
return (0);
} else {
if (c->variable) {
if (c->actionexplanation) {
(void) printf("%s %s.\n",
c->actionexplanation);
}
}
if (c->handler) {
}
}
}
return (retval);
}
/*
* The following perform the "set" command.
*/
#ifdef USE_TERMIO
#endif
struct setlist {
void (*handler)();
};
#ifdef KLUDGELINEMODE
#endif
{ "escape", "character to escape back to telnet command mode", 0,
&escape },
(cc_t *)NetTraceFile},
{ " ", "" },
{ " ", "The following need 'localchars' to be toggled true", 0, 0 },
{ "flushoutput", "character to cause an Abort Output", 0,
{ "interrupt", "character to cause an Interrupt Process", 0,
termIntCharp },
{ " ", "" },
{ " ", "The following are for local editing in linemode", 0, 0 },
{ "lnext", "character to use for literal next", 0,
{ 0 }
};
static struct setlist *
char *name;
{
return ((struct setlist *)
}
void
char *s;
{
if (rlogin != _POSIX_VDISABLE) {
(void) printf("Telnet rlogin escape character is '%s'.\n",
} else {
(void) printf("Telnet escape character is '%s'.\n",
}
}
static int
int argc;
char *argv[];
{
int value;
struct togglelist *c;
(void) printf(
"Format is 'set Name Value'\n'set ?' for help.\n");
return (0);
}
if ((argc == 2) &&
(void) printf("\n");
settogglehelp(1);
return (0);
}
if (ct == 0) {
if (c == 0) {
return (0);
} else if (Ambiguous(c)) {
return (0);
}
if (c->variable) {
*c->variable = 1;
*c->variable = 0;
else {
(void) printf(
"Format is 'set togglename [on|off]'\n"
"'set ?' for help.\n");
return (0);
}
if (c->actionexplanation) {
(void) printf("%s %s.\n",
c->actionexplanation);
}
}
if (c->handler)
(*c->handler)(1);
} else if (argc != 3) {
(void) printf(
"Format is 'set Name Value'\n'set ?' for help.\n");
return (0);
return (0);
(void) printf(
} else {
} else {
}
}
slc_check();
return (1);
}
static int
int argc;
char *argv[];
{
struct togglelist *c;
register char *name;
if (argc < 2) {
"'unset ?' for help.\n");
return (0);
}
(void) printf("\n");
settogglehelp(0);
return (0);
}
argc--;
argv++;
while (argc--) {
if (ct == 0) {
if (c == 0) {
"('unset ?' for help).\n", name);
return (0);
} else if (Ambiguous(c)) {
"'%s': ambiguous argument "
"('unset ?' for help).\n", name);
return (0);
}
if (c->variable) {
*c->variable = 0;
if (c->actionexplanation) {
(void) printf("%s %s.\n",
c->actionexplanation);
}
}
if (c->handler)
(*c->handler)(0);
"('unset ?' for help).\n", name);
return (0);
} else {
}
}
return (1);
}
/*
* The following are the data structures and routines for the
* 'mode' command.
*/
extern int reqd_linemode;
#ifdef KLUDGELINEMODE
extern int kludgelinemode;
static int
{
kludgelinemode = 1;
/*
* kludgelinemode requests which are processed before initial option
* negotiations occur.
*/
if (doing_rc)
reqd_linemode = 1;
return (1);
}
#endif
static int
{
#ifdef KLUDGELINEMODE
if (kludgelinemode)
#endif
/*
* kludgelinemode requests which are processed before initial option
* negotiations occur.
*/
if (doing_rc)
reqd_linemode = 1;
return (1);
}
static int
{
#ifdef KLUDGELINEMODE
if (kludgelinemode)
else
#endif
reqd_linemode = 0;
return (1);
}
static int
{
unsigned char c;
extern int linemode;
if (my_want_state_is_wont(TELOPT_LINEMODE)) {
(void) printf("?Need to have LINEMODE option enabled first.\n");
(void) printf("'mode ?' for help.\n");
return (0);
}
if (on)
else
return (1);
}
static int
{
}
static int
{
}
struct modelist {
int arg1;
};
static int modehelp();
#ifdef KLUDGELINEMODE
{ "", "(or disable obsolete line-by-line mode)", 0 },
#endif
#ifdef KLUDGELINEMODE
{ "", "(or enable obsolete line-by-line mode)", 0 },
#endif
{ "", "", 0 },
{ "", "These require the LINEMODE option to be enabled", 0 },
{ "-softtabs", "Disable tab expansion",
{ "litecho", "Enable literal character echo",
{ "help", 0, modehelp, 0 },
#ifdef KLUDGELINEMODE
#endif
{ "", "", 0 },
{ 0 },
};
static int
modehelp()
{
(void) printf("format is: 'mode Mode', where 'Mode' is one of:\n\n");
else
(void) printf("\n");
}
}
return (0);
}
static int
int argc;
char *argv[];
{
if (argc != 2) {
(void) printf("'mode' command requires an argument\n");
(void) printf("'mode ?' for help.\n");
(void) printf("?Need to be connected first.\n");
(void) printf("'mode ?' for help.\n");
}
return (0);
}
/*
* The following data structures and routines implement the
* "display" command.
*/
static int
int argc;
char *argv[];
{
(void) printf("will"); \
} else { \
(void) printf("won't"); \
} \
}
else \
}
if (argc == 1) {
}
(void) printf("\n");
}
} else {
int i;
for (i = 1; i < argc; i++) {
(void) printf(
"?Ambiguous argument '%s'.\n", argv[i]);
return (0);
(void) printf(
"?Unknown argument '%s'.\n", argv[i]);
return (0);
} else {
if (tl) {
}
if (sl) {
}
}
}
}
optionstatus();
(void) EncryptStatus();
return (1);
}
/*
* The following are the data structures, and many of the routines,
* relating to command processing.
*/
/*
* Set the escape character.
*/
static int
int argc;
char *argv[];
{
register char *arg;
if (argc > 2)
else {
(void) printf("new escape character: ");
perror("can't set escape character");
goto setescape_exit;
}
}
}
/* we place no limitations on what escape can be. */
return (1);
}
/*ARGSUSED*/
static int
int argc;
char *argv[];
{
(void) printf(
return (1);
}
/*ARGSUSED*/
static int
int argc;
char *argv[];
{
{
int err;
/*
* If we didn't get the window size before the SUSPEND, but we
* can get them now (?), then send the NAWS to make sure that
* we are set up for the right window size.
*/
sendnaws();
}
}
/* reget parameters in case they were changed */
setconnmode(0);
return (1);
}
/*ARGSUSED*/
static int
int argc;
char *argv[];
{
int err;
switch (vfork()) {
case -1:
perror("Fork failed\n");
break;
case 0:
{
/*
* Fire up the shell in the child.
*/
else
shellname++;
if (argc > 1)
else
perror("Execl");
}
default:
(void) wait((int *)0); /* Wait for the shell to complete */
sendnaws();
}
break;
}
return (1);
}
static int
int argc; /* Number of arguments */
char *argv[]; /* arguments */
{
extern int resettermname;
if (connected) {
hostname);
connected = 0;
resettermname = 1;
/* reset options */
(void) tninit();
}
/* NOTREACHED */
}
return (1); /* Keep lint, etc., happy */
}
/*VARARGS*/
int
quit()
{
/*NOTREACHED*/
return (1);
}
/*ARGSUSED*/
static int
int argc;
char *argv[];
{
(void) netflush();
return (1);
}
/*
* The SLC command.
*/
struct slclist {
char *name;
char *help;
void (*handler)();
int arg;
};
static void slc_help();
{ "export", "Use local special character definitions",
slc_mode_export, 0 },
{ "import", "Use remote special character definitions",
slc_mode_import, 1 },
{ "check", "Verify remote special character definitions",
slc_mode_import, 0 },
{ "help", 0, slc_help, 0 },
{ 0 },
};
static void
slc_help()
{
struct slclist *c;
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
}
static struct slclist *
char *name;
{
return ((struct slclist *)
}
static int
int argc;
char *argv[];
{
struct slclist *c;
if (argc != 2) {
"Need an argument to 'slc' command. 'slc ?' for help.\n");
return (0);
}
if (c == 0) {
"'%s': unknown argument ('slc ?' for help).\n",
argv[1]);
return (0);
}
if (Ambiguous(c)) {
return (0);
}
slcstate();
return (1);
}
/*
* The ENVIRON command.
*/
struct envlist {
char *name;
char *help;
void (*handler)();
int narg;
};
static struct env_lst *env_define(unsigned char *, unsigned char *);
static void env_undefine(unsigned char *);
static void env_export(unsigned char *);
static void env_unexport(unsigned char *);
static void env_send(unsigned char *);
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
static void env_varval(unsigned char *);
#endif
static void env_list(void);
static void env_help(void);
{ "define", "Define an environment variable",
(void (*)())env_define, 2 },
{ "undefine", "Undefine an environment variable",
env_undefine, 1 },
{ "export", "Mark an environment variable for automatic export",
env_export, 1 },
{ "unexport", "Don't mark an environment variable for automatic export",
env_unexport, 1 },
{ "list", "List the current environment variables",
env_list, 0 },
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
{ "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
env_varval, 1 },
#endif
{ "help", 0, env_help, 0 },
{ 0 },
};
static void
env_help()
{
struct envlist *c;
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
}
static struct envlist *
char *name;
{
return ((struct envlist *)
}
static int
int argc;
char *argv[];
{
struct envlist *c;
if (argc < 2) {
"Need an argument to 'environ' command. "
"'environ ?' for help.\n");
return (0);
}
if (c == 0) {
return (0);
}
if (Ambiguous(c)) {
return (0);
}
"Need %s%d argument%s to 'environ %s' command. "
"'environ ?' for help.\n",
return (0);
}
return (1);
}
struct env_lst {
};
static struct env_lst *
unsigned char *var;
{
return (ep);
}
return (NULL);
}
int
env_init()
{
#ifdef lint
#else /* lint */
extern char **environ;
#endif /* lint */
*cp = '\0';
(unsigned char *)cp+1);
return (0);
*cp = '=';
}
}
/*
* Special case for DISPLAY variable. If it is ":0.0" or
* "unix:0.0", we have to get rid of "unix" and insert our
* hostname.
*/
perror("telnet: cannot get hostname");
return (0);
}
perror("telnet: cannot define DISPLAY variable");
return (0);
}
}
/*
* If LOGNAME is defined, but USER is not, then add
* USER with the value from LOGNAME. We do this because the "accepted
* practice" is to always pass USER on the wire, but SVR4 uses
* LOGNAME by default.
*/
env_unexport((unsigned char *)"USER");
}
env_export((unsigned char *)"DISPLAY");
env_export((unsigned char *)"PRINTER");
return (1);
}
static struct env_lst *
{
unsigned char *tmp_value;
unsigned char *tmp_var;
/*
* Allocate copies of arguments first, to make cleanup easier
* in the case of allocation errors.
*/
perror("telnet: can't copy environment variable name");
return (NULL);
}
perror("telnet: can't copy environment variable value");
return (NULL);
}
} else {
perror("telnet: can't define environment variable");
return (NULL);
}
}
return (ep);
}
static void
unsigned char *var;
{
}
}
static void
unsigned char *var;
{
}
static void
unsigned char *var;
{
}
static void
unsigned char *var;
{
#ifdef OLD_ENVIRON
#endif
/* no environ */) {
"Cannot send '%s': Telnet ENVIRON option not enabled\n",
var);
return;
}
if (ep == 0) {
"Cannot send '%s': variable not defined\n", var);
return;
}
env_opt_end(0);
}
static void
env_list()
{
}
}
unsigned char *
int init;
{
if (init) {
/* return value is not used */
nep = &envlisthead;
return (NULL);
}
if (nep) {
}
}
return (NULL);
}
unsigned char *
unsigned char *var;
{
return (NULL);
}
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
static void
unsigned char *what;
{
if (len == 0)
goto unknown;
if (env_auto)
"determined automatically\n");
if (old_env_var == OLD_ENV_VAR)
(void) printf(
"VAR and VALUE set to correct definitions\n");
else
(void) printf(
"VAR and VALUE definitions are reversed\n");
env_auto = 1;
env_auto = 0;
env_auto = 0;
} else {
(void) printf(
"Unknown \"varval\" command. (\"auto\", \"right\", "
"\"wrong\", \"status\")\n");
}
}
#endif /* OLD_ENVIRON && ENV_HACK */
/*
* The AUTHENTICATE command.
*/
struct authlist {
char *name;
char *help;
int (*handler)();
int narg;
};
extern int auth_enable(char *);
extern int auth_disable(char *);
extern int auth_status(void);
static int auth_help(void);
{ "status",
"Display current status of authentication information",
auth_status, 0 },
{ "disable",
"Disable an authentication type ('auth disable ?' for more)",
auth_disable, 1 },
{ "enable",
"Enable an authentication type ('auth enable ?' for more)",
auth_enable, 1 },
{ "help", 0, auth_help, 0 },
{ 0 },
};
static int
auth_help(void)
{
struct authlist *c;
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
return (0);
}
static int
int argc;
char *argv[];
{
struct authlist *c;
if (argc < 2) {
"command. 'auth ?' for help.\n");
return (0);
}
c = (struct authlist *)
if (c == 0) {
"'%s': unknown argument ('auth ?' for help).\n",
argv[1]);
return (0);
}
if (Ambiguous(c)) {
return (0);
}
"Need %s%d argument%s to 'auth %s' command."
" 'auth ?' for help.\n",
return (0);
}
}
/*
* The FORWARD command.
*/
extern int forward_flags;
struct forwlist {
char *name;
char *help;
int (*handler)();
int f_flags;
};
static int forw_status(void);
static int forw_set(int);
static int forw_help(void);
{"status",
"Display current status of credential forwarding",
forw_status, 0},
{"disable",
"Disable credential forwarding",
forw_set, 0},
{"enable",
"Enable credential forwarding",
{"forwardable",
"Enable credential forwarding of "
"forwardable credentials",
{"help",
0,
forw_help, 0},
{"?",
"Print help information",
forw_help, 0},
{0},
};
static int
forw_status(void)
{
if (forward_flags & OPTS_FORWARD_CREDS) {
"Credential forwarding of "
"forwardable credentials enabled\n"));
else
"Credential forwarding enabled\n"));
} else
return (0);
}
static int
{
return (0);
}
static int
forw_help(void)
{
struct forwlist *c;
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
return (0);
}
static int
{
struct forwlist *c;
if (argc < 2) {
"Need an argument to 'forward' "
"command. 'forward ?' for help.\n"));
return (0);
}
sizeof (struct forwlist));
if (c == 0) {
"'%s': unknown argument ('forward ?' for help).\n"),
argv[1]);
return (0);
}
if (Ambiguous(c)) {
"'%s': ambiguous argument ('forward ?' for help).\n"),
argv[1]);
return (0);
}
if (argc != 2) {
"No arguments needed to 'forward %s' command. "
"'forward ?' for help.\n"), c->name);
return (0);
}
}
/*
* The ENCRYPT command.
*/
struct encryptlist {
char *name;
char *help;
int (*handler)();
int needconnect;
int minarg;
int maxarg;
};
static int EncryptHelp(void);
{ "enable", "Enable encryption. ('encrypt enable ?' for more)",
{ "disable", "Disable encryption. ('encrypt disable ?' for more)",
{ "type", "Set encryption type. ('encrypt type ?' for more)",
{ "start", "Start encryption. ('encrypt start ?' for more)",
{ "stop", "Stop encryption. ('encrypt stop ?' for more)",
{ "input", "Start encrypting the input stream",
EncryptStartInput, 1, 0, 0 },
{ "-input", "Stop encrypting the input stream",
EncryptStopInput, 1, 0, 0 },
{ "output", "Start encrypting the output stream",
EncryptStartOutput, 1, 0, 0 },
{ "-output", "Stop encrypting the output stream",
EncryptStopOutput, 1, 0, 0 },
{ "status", "Display current status of encryption information",
EncryptStatus, 0, 0, 0 },
{ "help", 0,
EncryptHelp, 0, 0, 0 },
{ 0 },
};
static int
EncryptHelp(void)
{
struct encryptlist *c;
for (c = EncryptList; c->name; c++) {
if (c->help) {
if (*c->help)
else
(void) printf("\n");
}
}
return (0);
}
static int
{
struct encryptlist *c;
if (argc < 2) {
"Need an argument to 'encrypt' command. "
"'encrypt ?' for help.\n"));
return (0);
}
c = (struct encryptlist *)
if (c == 0) {
"'%s': unknown argument ('encrypt ?' for help).\n"),
argv[1]);
return (0);
}
if (Ambiguous(c)) {
"'%s': ambiguous argument ('encrypt ?' for help).\n"),
argv[1]);
return (0);
}
argc -= 2;
c->minarg == 1 ?
} else {
gettext("Need %s%d-%d arguments "),
}
"to 'encrypt %s' command. 'encrypt ?' for help.\n"),
c->name);
return (0);
}
if (c->needconnect && !connected) {
if (!(argc &&
(void) printf(
gettext("?Need to be connected first.\n"));
return (0);
}
}
}
/*
* Print status about the connection.
*/
static int
{
if (connected) {
if (my_want_state_is_will(TELOPT_LINEMODE)) {
(void) printf(
"Operating with LINEMODE option\n");
(void) printf(
"Local" : "No");
(void) printf("%s catching of signals\n",
slcstate();
#ifdef KLUDGELINEMODE
} else if (kludgelinemode &&
(void) printf(
"Operating in obsolete linemode\n");
#endif
} else {
(void) printf(
"Operating in single character mode\n");
if (localchars)
(void) printf(
"Catching signals locally\n");
}
"Local" : "Remote");
(void) printf("%s flow control\n",
}
} else {
(void) printf("No connection.\n");
}
if (rlogin != _POSIX_VDISABLE)
else
(void) printf(
return (1);
}
/*
* Parse the user input (cmd_line_input) which should:
* - start with the target host, or with "@" or "!@" followed by at least one
* gateway.
* - each host (can be literal address or hostname) can be separated by ",",
* "@", or ",@".
* Note that the last host is the target, all the others (if any ) are the
* gateways.
*
* Returns: -1 if a library call fails, too many gateways, or parse
* error
* num_gw otherwise
* On successful return, hostname_list points to a list of hosts (last one being
* the target, others gateways), src_rtng_type points to the type of source
* routing (strict vs. loose)
*/
static int
{
char *cp;
int gw_count;
int i;
gw_count = 0;
cp = cmd_line_input;
/*
* Defining ICMD generates the Itelnet binary, the special version of
* telnet which is used with firewall proxy.
* If ICMD is defined, parse_input will treat the whole cmd_line_input
* as the target host and set the num_gw to 0. Therefore, none of the
* source routing related code paths will be executed.
*/
#ifndef ICMD
if (*cp == '@') {
cp++;
} else if (*cp == '!') {
/* "!" must be followed by '@' */
goto parse_error;
cp += 2;
} else {
#endif /* ICMD */
/* no gateways, just the target */
if (hostname_list[0] == NULL) {
perror("telnet: copying host name");
return (-1);
}
return (0);
#ifndef ICMD
}
while (*cp != '\0') {
/*
* Identify each gateway separated by ",", "@" or ",@" and
* store in hname[].
*/
i = 0;
if (i > MAXHOSTNAMELEN)
goto parse_error;
}
hname[i] = '\0';
/*
* Two consecutive delimiters which result in a 0 length hname
* is a parse error.
*/
if (i == 0)
goto parse_error;
perror("telnet: copying hostname from list");
return (-1);
}
if (++gw_count > MAXMAX_GATEWAY) {
return (-1);
}
/* Jump over the next delimiter. */
if (*cp != '\0') {
/* ...gw1,@gw2... accepted */
cp += 2;
else
cp++;
}
}
/* discount the target */
gw_count--;
/* Any input starting with '!@' or '@' must have at least one gateway */
if (gw_count <= 0)
goto parse_error;
return (gw_count);
return (-1);
#endif /* ICMD */
}
/*
* Resolves the target and gateway addresses, determines what type of addresses
* (ALL_ADDRS, ONLY_V6, ONLY_V4) telnet will be trying to connect.
*
* Returns: pointer to resolved target if name resolutions succeed
* NULL if name resolutions fail or
* a library function call fails
*
* The last host in the hostname_list is the target. After resolving the target,
* determines for what type of addresses it should try to resolve gateways. It
* resolves gateway addresses and picks one address for each desired address
* type and stores in the array pointed by gw_addrsp. Also, this 'type of
* addresses' is pointed by addr_type argument on successful return.
*/
static struct addrinfo *
{
/* whether we already picked an IPv4 address for the current gateway */
/* whether we need to get an IPv4 address for the current gateway */
int res_failed_at6;
int error_num;
int i;
int rc;
if (rc != 0) {
return (NULL);
}
/*
* Let's see what type of addresses we got for the target. This
* determines what type of addresses we'd like to resolve gateways
* later.
*/
else
/*
* Let's stop after seeing we need both IPv6 and IPv4.
*/
if (need_v4_addr && need_v6_addr)
break;
}
if (num_gw > 0) {
/*
* In the prepare_optbuf(), we'll store the IPv4 address of the
* target in the last slot of gw_addrs array. Therefore we need
* space for num_gw+1 hosts.
*/
perror("telnet: calloc");
return (NULL);
}
}
/*
* Now we'll go through all the gateways and try to resolve them to
* the desired address types.
*/
/* -1 means 'no address resolution failure yet' */
res_failed_at4 = -1;
res_failed_at6 = -1;
for (i = 0; i < num_gw; i++) {
if (rc != 0) {
if (hostname_list[i] != NULL &&
*hostname_list[i] != '\0')
hostname_list[i]);
return (NULL);
}
/*
* Initially we have no address of any type for this gateway.
*/
/*
* Let's go through all the addresses of this gateway.
* Use the first address which matches the needed family.
*/
/*LINTED*/
else
/*
* If we need to determine an IPv4 address and haven't
* found one yet and this is a IPv4-mapped IPv6 address,
* then bingo!
*/
if (need_v4_addr && !got_v4_addr) {
if (is_v4mapped) {
}
}
if (need_v6_addr && !got_v6_addr &&
}
/*
* Let's stop if we got all what we looked for.
*/
if ((!need_v4_addr || got_v4_addr) &&
(!need_v6_addr || got_v6_addr))
break;
}
/*
* We needed an IPv4 address for this gateway but couldn't
* find one.
*/
if (need_v4_addr && !got_v4_addr) {
res_failed_at4 = i;
/*
* Since we couldn't resolve a gateway to IPv4 address
* we can't use IPv4 at all. Therefore we no longer
* need IPv4 addresses for any of the gateways.
*/
}
if (need_v6_addr && !got_v6_addr) {
res_failed_at6 = i;
}
/*
* If some gateways don't resolve to any of the desired
* address types, we fail.
*/
if (!need_v4_addr && !need_v6_addr) {
if (res_failed_at6 != -1) {
"%s: Host doesn't have any IPv6 address\n",
}
if (res_failed_at4 != -1) {
"%s: Host doesn't have any IPv4 address\n",
}
return (NULL);
}
gw++;
}
/*
* When we get here, need_v4_addr and need_v6_addr have their final
* values based on the name resolution of the target and gateways.
*/
if (need_v4_addr && need_v6_addr)
else if (need_v4_addr && !need_v6_addr)
else if (!need_v4_addr && need_v6_addr)
return (res);
}
/*
* Initializes the buffer pointed by opt_bufpp for a IPv4 option of type
* src_rtng_type using the gateway addresses stored in gw_addrs. If no buffer
* is passed, it allocates one. If a buffer is passed, checks if it's big
* enough.
* On return opt_buf_len points to the buffer length which we need later for the
* setsockopt() call, and opt_bufpp points to the newly allocated or already
* passed buffer. Returns B_FALSE if a library function call fails or passed
* buffer is not big enough, B_TRUE otherwise.
*/
static boolean_t
{
int i;
/*
* We have (num_gw + 1) IP addresses in the buffer because the number
* of gateway addresses we put in the option buffer includes the target
* address.
* At the time of setsockopt() call, passed option length needs to be
* multiple of 4 bytes. Therefore we need one IPOPT_NOP before (or
* after) IPOPT_LSRR.
* 1 = preceding 1 byte of IPOPT_NOP
* 3 = 1 (code) + 1 (len) + 1 (ptr)
*/
/* check if the passed buffer is big enough */
if (*opt_buf_len < needed_buflen) {
"telnet: buffer too small for IPv4 source routing "
"option\n");
return (B_FALSE);
}
} else {
perror("telnet: malloc");
return (B_FALSE);
}
}
/* final hop is the target */
/* IPOPT_LSRR starts right after IPOPT_NOP */
/* discount the 1 byte of IPOPT_NOP */
/* copy the gateways into the optlist */
for (i = 0; i < num_gw + 1; i++) {
sizeof (struct in_addr));
}
return (B_TRUE);
}
/*
* Initializes the buffer pointed by opt_bufpp for a IPv6 routing header option
* using the gateway addresses stored in gw_addrs. If no buffer is passed, it
* allocates one. If a buffer is passed, checks if it's big enough.
* On return opt_buf_len points to the buffer length which we need later for the
* setsockopt() call, and opt_bufpp points to the newly allocated or already
* passed buffer. Returns B_FALSE if a library function call fails or passed
* buffer is not big enough, B_TRUE otherwise.
*/
static boolean_t
{
char *opt_bufp;
int i;
/* check if the passed buffer is big enough */
if (*opt_buf_len < needed_buflen) {
"telnet: buffer too small for IPv6 routing "
"header option\n");
return (B_FALSE);
}
} else {
perror("telnet: malloc");
return (B_FALSE);
}
}
/*
* Initialize the buffer to be used for IPv6 routing header type 0.
*/
perror("telnet: inet6_rth_init");
return (B_FALSE);
}
/*
* Add gateways one by one.
*/
for (i = 0; i < num_gw; i++) {
perror("telnet: inet6_rth_add");
return (B_FALSE);
}
}
/* successful operation */
return (B_TRUE);
}
int
int argc;
char *argv[];
{
struct addrinfo *h;
void *addrp;
char *cmd;
#ifdef ICMD
char *itelnet_host;
char *real_host;
unsigned short dest_port;
#endif /* ICMD */
/*
* The two strings at the end of this function are 24 and 39
* characters long (minus the %.*s in the format strings). Add
* one for the null terminator making the longest print string 40.
*/
/*
* In the case of ICMD defined, dest_port will contain the real port
* we are trying to telnet to, and target_port will contain
* "telnet-passthru" port.
*/
unsigned short target_port;
int num_gw;
int ret_val;
/*
* Type of addresses we'll try to connect to (ALL_ADDRS, ONLY_V6,
* ONLY_V4).
*/
int addr_type;
/* clear the socket address prior to use */
if (connected) {
return (0);
}
#ifdef ICMD
(void) printf("INTERNET_HOST environment variable undefined\n");
goto tn_exit;
}
#endif
if (argc < 2) {
(void) printf("(to) ");
perror("telnet");
goto tn_exit;
}
}
makeargv();
}
while (argc) {
goto usage;
if (argc == 0)
goto usage;
--argc;
continue;
}
continue;
}
if (hostp == 0) {
--argc;
continue;
}
if (portp == 0) {
--argc;
/*
* Do we treat this like a telnet port or raw?
*/
if (*portp == '-') {
portp++;
telnetport = 1;
} else
telnetport = 0;
continue;
}
(void) printf(
"usage: %s [-l user] [-a] host-name [port]\n", cmd);
goto tn_exit;
}
if (hostp == 0)
goto usage;
#ifdef ICMD
/*
* For setup phase treat the relay host as the target host.
*/
#endif
if (num_gw < 0) {
goto tn_exit;
}
/* Last host in the hostname_list is the target */
portp);
goto tn_exit;
}
/*
* Check if number of gateways is less than max. available
*/
num_gw > MAX_GATEWAY6) {
goto tn_exit;
}
num_gw > MAX_GATEWAY) {
goto tn_exit;
}
/*
* If we pass a literal IPv4 address to getaddrinfo(), in the
* returned addrinfo structure, hostname is the IPv4-mapped IPv6
* address string. We prefer to preserve the literal IPv4 address
* string as the hostname. Also, if the hostname entered by the
* user is IPv4-mapped IPv6 address, we'll downgrade it to IPv4
* address.
*/
/* this is a literal IPv4 address */
/* this is a IPv4-mapped IPv6 address */
} else {
sizeof (_hostname));
}
telnetport = 1;
}
} else {
->sin6_port;
}
#ifdef ICMD
/*
* Since we pass the port number as an ascii string to the proxy,
* we need it in host format.
*/
if (sp == 0) {
"telnet: tcp/telnet-passthru: unknown service\n");
goto tn_exit;
}
#endif
h = host;
/*
* For IPv6 source routing, we need to initialize option buffer only
* once.
*/
&opt_buf_len6)) {
goto tn_exit;
}
}
/*
* We procure the Kerberos config files options only
* if the user has choosen Krb5 authentication.
*/
if (krb5auth_flag > 0) {
}
if (encrypt_flag) {
extern boolean_t auth_enable_encrypt;
if (krb5_privacy_allowed()) {
encrypt_auto(1);
decrypt_auto(1);
autologin = 1;
} else {
"%s:Encryption not supported.\n"), prompt);
exit(1);
}
}
if (forward_flag && forwardable_flag) {
"Error in krb5 configuration file. "
"Both forward and forwardable are set.\n"));
exit(1);
}
if (forwardable_flag) {
} else if (forward_flag)
do {
/*
* Search for an address of desired type in the IP address list
* of the target.
*/
while (h != NULL) {
else
break;
/* skip undesired typed addresses */
h = h->ai_next;
}
if (h == NULL) {
"telnet: Unable to connect to remote host");
goto tn_exit;
}
/*
* We need to open a socket with a family matching the type of
* address we are trying to connect to. This is because we
* deal with IPv4 options and IPv6 extension headers.
*/
} else {
->sin6_addr;
}
if (net < 0) {
perror("telnet: socket");
goto tn_exit;
}
#ifndef ICMD
if (num_gw > 0) {
goto tn_exit;
}
opt_buf, opt_buf_len) < 0)
perror("setsockopt (IP_OPTIONS)");
} else {
opt_buf6, opt_buf_len6) < 0)
perror("setsockopt (IPV6_RTHDR)");
}
}
#endif
#if defined(USE_TOS)
if (is_v4mapped) {
if (tos < 0)
if (tos &&
&tos, sizeof (int)) < 0) &&
(errno != ENOPROTOOPT))
perror("telnet: setsockopt (IP_TOS) (ignored)");
}
#endif /* defined(USE_TOS) */
perror("setsockopt (SO_DEBUG)");
}
/*
* If failed, try the next address of the target.
*/
if (ret_val < 0) {
"telnet: connect to address %s: ", abuf);
perror((char *)0);
h = h->ai_next;
continue;
}
perror("telnet: Unable to connect to remote host");
goto tn_exit;
}
connected++;
} while (connected == 0);
#ifdef ICMD
/*
* Do initial protocol to connect to farther end...
*/
{
}
#endif
goto tn_exit;
else
}
}
if (user) {
env_export((unsigned char *)"USER");
else {
/* Clean up and exit. */
"Connection to %.*s closed.\n",
/* NOTREACHED */
}
}
"Connection to %.*s closed by foreign host.\n",
/*NOTREACHED*/
connected = 0;
return (0);
}
static char logouthelp[] =
"forcibly logout remote user and close the connection";
static char sendhelp[] =
"transmit special characters ('send ?' for more)";
static char togglestring[] =
"toggle operating parameters ('toggle ?' for more)";
static char authhelp[] =
"turn on (off) authentication ('auth ?' for more)";
static char forwardhelp[] =
"turn on (off) credential forwarding ('forward ?' for more)";
static char encrypthelp[] =
"turn on (off) encryption ('encrypt ?' for more)";
static char modestring[] =
"try to enter line or character mode ('mode ?' for more)";
static int help();
0
};
{ "help", 0, help, 0 },
{ "escape", 0, setescape, 0 },
{ "crmod", 0, togcrmod, 0 },
0
};
/*
* Call routine with argc, argv set from args.
*/
/*VARARGS1*/
static void
{
typedef int (*intrtn_t)();
int argno = 0;
n_ptrs--;
}
static Command *
char *name;
{
return (cm);
}
void
int top;
char *tbuf;
int cnt;
{
Command *c;
if (!top) {
(void) putchar('\n');
} else {
}
for (;;) {
if (rlogin == _POSIX_VDISABLE)
if (tbuf) {
char *cp;
goto command_exit;
cnt--;
tbuf = 0;
goto getline;
*cp = '\0';
if (rlogin == _POSIX_VDISABLE)
} else {
if (rlogin != _POSIX_VDISABLE)
perror("telnet");
(void) quit();
/*NOTREACHED*/
break;
}
}
if (line[0] == 0)
break;
makeargv();
if (margv[0] == 0) {
break;
}
if (Ambiguous(c)) {
(void) printf("?Ambiguous command\n");
continue;
}
if (c == 0) {
(void) printf("?Invalid command\n");
continue;
}
if (c->needconnect && !connected) {
(void) printf("?Need to be connected first.\n");
continue;
}
break;
}
}
if (!top) {
if (!connected) {
/*NOTREACHED*/
}
setconnmode(0);
}
}
/*
* Help command.
*/
static int
int argc;
char *argv[];
{
register Command *c;
if (argc == 1) {
(void) printf(
"Commands may be abbreviated. Commands are:\n\n");
if (c->help) {
}
(void) printf("<return>\tleave command mode\n");
return (0);
}
while (--argc > 0) {
register char *arg;
if (Ambiguous(c))
else if (c == (Command *)0)
else if (c->help) {
} else {
}
}
return (0);
}
static int
{
Command *c;
int gotmachine = 0;
int ret = 0;
if (skiprc)
goto cmdrc_exit;
doing_rc = 1;
char *homedir;
unsigned rcbuflen;
homedir = "";
ret = 1;
goto cmdrc_exit;
}
}
goto cmdrc_exit;
for (;;) {
ret = 1;
goto cmdrc_exit;
}
break;
}
if (line[0] == 0)
continue;
if (line[0] == '#')
continue;
if (gotmachine) {
gotmachine = 0;
}
if (gotmachine == 0) {
continue;
else
continue;
line[0] != '\n')
continue;
gotmachine = 1;
}
makeargv();
if (margv[0] == 0)
continue;
if (Ambiguous(c)) {
continue;
}
if (c == 0) {
continue;
}
/*
* This should never happen...
*/
if (c->needconnect && !connected) {
(void) printf("?Need to be connected first for %s.\n",
margv[0]);
continue;
}
}
doing_rc = 0;
return (ret);
}