44 |
{NULL, 0, NULL, 0} |
{NULL, 0, NULL, 0} |
45 |
}; |
}; |
46 |
|
|
47 |
static void telnetd_version (); |
static void telnetd_version P((void)); |
48 |
static void telnetd_license (); |
static void telnetd_license P((void)); |
49 |
static void telnetd_help (); |
static void telnetd_help P((void)); |
50 |
static void parse_authmode (char *str); |
static void parse_authmode P((char *str)); |
51 |
static void parse_linemode (char *str); |
static void parse_linemode P((char *str)); |
52 |
static void parse_debug_level (char *str); |
static void parse_debug_level P((char *str)); |
53 |
static void telnetd_setup (int fd); |
static void telnetd_setup P((int fd)); |
54 |
static int telnetd_run (); |
static int telnetd_run P((void)); |
55 |
|
static void print_hostinfo P((void)); |
56 |
|
|
57 |
|
/* Template command line for invoking login program */ |
58 |
|
|
59 |
|
char *login_invocation = |
60 |
|
#ifdef SOLARIS |
61 |
|
"/bin/login -h %h %?T{TERM=%T}{-} %?u{%?a{-f }-- %u}" |
62 |
|
#else |
63 |
|
"/bin/login -p -h %h %?u{-f %u}" |
64 |
|
#endif |
65 |
|
; |
66 |
|
|
|
char *login_invocation; /* Template command line for invoking login program */ |
|
67 |
int keepalive = 1; /* Should the TCP keepalive bit be set */ |
int keepalive = 1; /* Should the TCP keepalive bit be set */ |
68 |
int reverse_lookup = 0; /* Reject connects from hosts which IP numbers |
int reverse_lookup = 0; /* Reject connects from hosts which IP numbers |
69 |
cannot be reverse mapped to their hostnames */ |
cannot be reverse mapped to their hostnames */ |
81 |
int pty; /* PTY master descriptor */ |
int pty; /* PTY master descriptor */ |
82 |
char *remote_hostname; |
char *remote_hostname; |
83 |
char *local_hostname; |
char *local_hostname; |
84 |
|
char *user_name; |
85 |
|
char line[256]; |
86 |
|
|
87 |
char options[256]; |
char options[256]; |
88 |
char do_dont_resp[256]; |
char do_dont_resp[256]; |
277 |
int true = 1; |
int true = 1; |
278 |
int len; |
int len; |
279 |
struct hostent *hp; |
struct hostent *hp; |
280 |
char user_name[256]; /*FIXME*/ |
char uname[256]; /*FIXME*/ |
281 |
int level; |
int level; |
282 |
|
|
283 |
len = sizeof (saddr); |
len = sizeof (saddr); |
287 |
exit (1); |
exit (1); |
288 |
} |
} |
289 |
|
|
290 |
syslog (LOG_INFO, "Connect from %s", inet_ntoa (saddr.sin_addr.s_addr)); |
syslog (LOG_INFO, "Connect from %s", inet_ntoa (saddr.sin_addr)); |
291 |
|
|
292 |
hp = gethostbyaddr ((char*)&saddr.sin_addr.s_addr, |
hp = gethostbyaddr ((char*)&saddr.sin_addr.s_addr, |
293 |
sizeof (saddr.sin_addr.s_addr), AF_INET); |
sizeof (saddr.sin_addr.s_addr), AF_INET); |
299 |
{ |
{ |
300 |
syslog (LOG_AUTH|LOG_NOTICE, |
syslog (LOG_AUTH|LOG_NOTICE, |
301 |
"Can't resolve %s: %s", |
"Can't resolve %s: %s", |
302 |
inet_ntoa (saddr.sin_addr.s_addr), |
inet_ntoa (saddr.sin_addr), |
303 |
hstrerror (h_errno)); |
hstrerror (h_errno)); |
304 |
fatal (fd, "Cannot resolve address."); |
fatal (fd, "Cannot resolve address."); |
305 |
} |
} |
324 |
syslog (LOG_AUTH|LOG_NOTICE, |
syslog (LOG_AUTH|LOG_NOTICE, |
325 |
"None of addresses of %s matched %s", |
"None of addresses of %s matched %s", |
326 |
remote_hostname, |
remote_hostname, |
327 |
inet_ntoa (saddr.sin_addr.s_addr)); |
inet_ntoa (saddr.sin_addr)); |
328 |
exit (0); |
exit (0); |
329 |
} |
} |
330 |
} |
} |
333 |
if (hp) |
if (hp) |
334 |
remote_hostname = xstrdup (hp->h_name); |
remote_hostname = xstrdup (hp->h_name); |
335 |
else |
else |
336 |
remote_hostname = xstrdup (inet_ntoa (saddr.sin_addr.s_addr)); |
remote_hostname = xstrdup (inet_ntoa (saddr.sin_addr)); |
337 |
} |
} |
338 |
|
|
339 |
/* Set socket options */ |
/* Set socket options */ |
364 |
/**/ |
/**/ |
365 |
|
|
366 |
/* get terminal type. */ |
/* get terminal type. */ |
367 |
*user_name = 0; |
uname[0] = 0; |
368 |
level = getterminaltype (&user_name); |
level = getterminaltype (uname); |
369 |
setenv ("TERM", terminaltype ? terminaltype : "network", 1); |
setenv ("TERM", terminaltype ? terminaltype : "network", 1); |
370 |
|
if (uname[0]) |
371 |
|
user_name = xstrdup (uname); |
372 |
pty = startslave (remote_hostname, level, user_name); |
pty = startslave (remote_hostname, level, user_name); |
373 |
|
|
374 |
#ifndef HAVE_STREAMSPTY |
#ifndef HAVE_STREAMSPTY |
462 |
/* Pick up anything received during the negotiations */ |
/* Pick up anything received during the negotiations */ |
463 |
telrcv (); |
telrcv (); |
464 |
|
|
465 |
/* if (hostinfo && !getenv("USER")) |
if (hostinfo) |
466 |
print_hostinfo (); |
print_hostinfo (); |
|
*/ |
|
467 |
|
|
468 |
init_termbuf (); |
init_termbuf (); |
469 |
localstat (); |
localstat (); |
591 |
print_hostinfo () |
print_hostinfo () |
592 |
{ |
{ |
593 |
char *im = NULL; |
char *im = NULL; |
594 |
|
char *str; |
595 |
#ifdef HAVE_UNAME |
#ifdef HAVE_UNAME |
596 |
struct utsname u; |
struct utsname u; |
597 |
|
|
609 |
} |
} |
610 |
#endif /* HAVE_UNAME */ |
#endif /* HAVE_UNAME */ |
611 |
if (!im) |
if (!im) |
612 |
im = "\r\n\nUNIX (%h) (%t)\r\n\n"; |
im = xstrdup ("\r\n\nUNIX (%h) (%t)\r\n\n"); |
613 |
|
|
614 |
/*FIXME*/ |
str = expand_line (im); |
615 |
DEBUG(debug_pty_data, 1, debug_output_data ("sending %s", im)); |
free (im); |
616 |
pty_output_datalen (im, strlen (im)); |
|
617 |
|
DEBUG(debug_pty_data, 1, debug_output_data ("sending %s", str)); |
618 |
|
pty_input_putback (str, strlen (str)); |
619 |
|
free (str); |
620 |
} |
} |
621 |
|
|
622 |
void |
void |
660 |
Options are:\n\ |
Options are:\n\ |
661 |
-a, --authmode AUTHMODE specify what mode to use for authentication\n\ |
-a, --authmode AUTHMODE specify what mode to use for authentication\n\ |
662 |
-D, --debug[=LEVEL] set debugging level\n\ |
-D, --debug[=LEVEL] set debugging level\n\ |
663 |
* -E, --exec-login STRING set program to be executed instead of /bin/login\n\ |
-E, --exec-login STRING set program to be executed instead of /bin/login\n\ |
664 |
-h, --no-hostinfo do not print host information before login has\n\ |
-h, --no-hostinfo do not print host information before login has\n\ |
665 |
been completed\n\ |
been completed\n\ |
666 |
-l, --linemode[=MODE] set line mode\n\ |
-l, --linemode[=MODE] set line mode\n\ |
672 |
Informational options:\n\ |
Informational options:\n\ |
673 |
-V, --version display this help and exit\n\ |
-V, --version display this help and exit\n\ |
674 |
-L, --license display license and exit\n\ |
-L, --license display license and exit\n\ |
675 |
-H. --help output version information and exit\n\ |
-H. --help output version information and exit\n"); |
|
\n\ |
|
|
Options, marked with an * are not yet implemented\n"); |
|
676 |
} |
} |
677 |
|
|
678 |
int |
int |