Line
Link Here
|
0 |
-- netkit-telnet-0.17.orig/Makefile |
0 |
++ netkit-telnet-0.17/Makefile |
Lines 1-8
Link Here
|
1 |
# You can do "make SUB=blah" to make only a few, or edit here, or both |
1 |
# You can do "make SUB=blah" to make only a few, or edit here, or both |
2 |
# You can also run make directly in the subdirs you want. |
2 |
# You can also run make directly in the subdirs you want. |
3 |
|
3 |
|
4 |
SUB = telnet telnetd |
4 |
SUB = telnet telnetd telnetlogin |
5 |
# not yet: telnetlogin |
|
|
6 |
|
5 |
|
7 |
%.build: |
6 |
%.build: |
8 |
(cd $(patsubst %.build, %, $@) && $(MAKE)) |
7 |
(cd $(patsubst %.build, %, $@) && $(MAKE)) |
9 |
-- netkit-telnet-0.17.orig/configure |
8 |
++ netkit-telnet-0.17/configure |
Lines 67-73
Link Here
|
67 |
|
67 |
|
68 |
################################################## |
68 |
################################################## |
69 |
|
69 |
|
70 |
WARNINGS='-Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline ' |
70 |
WARNINGS='-Wall -Wno-trigraphs ' |
71 |
|
71 |
|
72 |
cat << EOF > __conftest.c |
72 |
cat << EOF > __conftest.c |
73 |
int main() { int class=0; return class; } |
73 |
int main() { int class=0; return class; } |
Lines 117-123
Link Here
|
117 |
|
117 |
|
118 |
cat << EOF > __conftest.cc |
118 |
cat << EOF > __conftest.cc |
119 |
template <class T> class fnord { public: T x; fnord(T y) { x=y; }}; |
119 |
template <class T> class fnord { public: T x; fnord(T y) { x=y; }}; |
120 |
int main() { fnord<int> a(0); return a.x; } |
120 |
int main() { fnord<int> *a = new fnord<int>(0); return a->x; } |
121 |
EOF |
121 |
EOF |
122 |
|
122 |
|
123 |
if [ x"$CXX" = x ]; then |
123 |
if [ x"$CXX" = x ]; then |
124 |
-- netkit-telnet-0.17.orig/telnet/Makefile |
124 |
++ netkit-telnet-0.17/telnet/Makefile |
Lines 7-13
Link Here
|
7 |
|
7 |
|
8 |
# -DAUTHENTICATE |
8 |
# -DAUTHENTICATE |
9 |
CXXFLAGS += -DUSE_TERMIO -DKLUDGELINEMODE |
9 |
CXXFLAGS += -DUSE_TERMIO -DKLUDGELINEMODE |
10 |
LIBS += $(LIBTERMCAP) |
10 |
LIBS = $(LIBTERMCAP) |
11 |
|
11 |
|
12 |
SRCS = commands.cc main.cc network.cc ring.cc sys_bsd.cc telnet.cc \ |
12 |
SRCS = commands.cc main.cc network.cc ring.cc sys_bsd.cc telnet.cc \ |
13 |
terminal.cc tn3270.cc utilities.cc genget.cc environ.cc netlink.cc |
13 |
terminal.cc tn3270.cc utilities.cc genget.cc environ.cc netlink.cc |
14 |
-- netkit-telnet-0.17.orig/telnet/commands.cc |
14 |
++ netkit-telnet-0.17/telnet/commands.cc |
Lines 86-95
Link Here
|
86 |
|
86 |
|
87 |
#define HELPINDENT ((int) sizeof ("connect")) |
87 |
#define HELPINDENT ((int) sizeof ("connect")) |
88 |
|
88 |
|
89 |
#ifndef MAXHOSTNAMELEN |
|
|
90 |
#define MAXHOSTNAMELEN 64 |
91 |
#endif MAXHOSTNAMELEN |
92 |
|
93 |
#if defined(HAS_IPPROTO_IP) && defined(IP_TOS) |
89 |
#if defined(HAS_IPPROTO_IP) && defined(IP_TOS) |
94 |
int tos = -1; |
90 |
int tos = -1; |
95 |
#endif /* defined(HAS_IPPROTO_IP) && defined(IP_TOS) */ |
91 |
#endif /* defined(HAS_IPPROTO_IP) && defined(IP_TOS) */ |
Lines 98-104
Link Here
|
98 |
|
94 |
|
99 |
|
95 |
|
100 |
char *hostname; |
96 |
char *hostname; |
101 |
static char _hostname[MAXHOSTNAMELEN]; |
97 |
static char *_hostname; |
102 |
|
98 |
|
103 |
//typedef int (*intrtn_t)(int argc, const char *argv[]); |
99 |
//typedef int (*intrtn_t)(int argc, const char *argv[]); |
104 |
|
100 |
|
Lines 161-167
Link Here
|
161 |
assert(argc>=1); |
157 |
assert(argc>=1); |
162 |
if (nargs>=0 && argc!=nargs+1) { |
158 |
if (nargs>=0 && argc!=nargs+1) { |
163 |
fprintf(stderr, "Wrong number of arguments for command.\n"); |
159 |
fprintf(stderr, "Wrong number of arguments for command.\n"); |
164 |
fprintf(stderr, "Try %s ? for help\n", argv[0]); |
160 |
fprintf(stderr, "Try ? %s for help\n", argv[0]); |
165 |
return 0; /* is this right? */ |
161 |
return 0; /* is this right? */ |
166 |
} |
162 |
} |
167 |
if (nargs==-2) { |
163 |
if (nargs==-2) { |
Lines 480-485
Link Here
|
480 |
int send_tncmd(int (*func)(int, int), const char *cmd, const char *name) { |
476 |
int send_tncmd(int (*func)(int, int), const char *cmd, const char *name) { |
481 |
char **cpp; |
477 |
char **cpp; |
482 |
extern char *telopts[]; |
478 |
extern char *telopts[]; |
|
|
479 |
long opt; |
483 |
|
480 |
|
484 |
if (isprefix(name, "help") || isprefix(name, "?")) { |
481 |
if (isprefix(name, "help") || isprefix(name, "?")) { |
485 |
register int col, len; |
482 |
register int col, len; |
Lines 506-521
Link Here
|
506 |
name, cmd); |
503 |
name, cmd); |
507 |
return 0; |
504 |
return 0; |
508 |
} |
505 |
} |
|
|
506 |
|
507 |
opt = cpp - telopts; |
509 |
if (cpp == 0) { |
508 |
if (cpp == 0) { |
510 |
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n", |
509 |
char *end; |
|
|
510 |
|
511 |
opt = strtol(name, &end, 10); |
512 |
if (*end || opt < 0 || opt > 255) { |
513 |
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n", |
511 |
name, cmd); |
514 |
name, cmd); |
512 |
return 0; |
515 |
return 0; |
|
|
516 |
} |
513 |
} |
517 |
} |
514 |
if (!connected) { |
518 |
if (!connected) { |
515 |
printf("?Need to be connected first.\n"); |
519 |
printf("?Need to be connected first.\n"); |
516 |
return 0; |
520 |
return 0; |
517 |
} |
521 |
} |
518 |
(*func)(cpp - telopts, 1); |
522 |
(*func)(opt, 1); |
519 |
return 1; |
523 |
return 1; |
520 |
} |
524 |
} |
521 |
|
525 |
|
Lines 689-697
Link Here
|
689 |
"print encryption debugging information" }, |
693 |
"print encryption debugging information" }, |
690 |
#endif |
694 |
#endif |
691 |
|
695 |
|
692 |
{ "skiprc", "don't read ~/.telnetrc file", |
696 |
{ "skiprc", "don't read the telnetrc files", |
693 |
NULL, &skiprc, |
697 |
NULL, &skiprc, |
694 |
"read ~/.telnetrc file" }, |
698 |
"read the telnetrc files" }, |
695 |
{ "binary", |
699 |
{ "binary", |
696 |
"sending and receiving of binary data", |
700 |
"sending and receiving of binary data", |
697 |
togbinary, NULL, |
701 |
togbinary, NULL, |
Lines 1615-1629
Link Here
|
1615 |
#endif |
1619 |
#endif |
1616 |
|
1620 |
|
1617 |
int tn(int argc, const char *argv[]) { |
1621 |
int tn(int argc, const char *argv[]) { |
1618 |
register struct hostent *host = 0; |
|
|
1619 |
struct sockaddr_in sn; |
1622 |
struct sockaddr_in sn; |
1620 |
struct servent *sp = 0; |
|
|
1621 |
char *srp = NULL; |
1623 |
char *srp = NULL; |
1622 |
int srlen; |
1624 |
int srlen; |
1623 |
|
1625 |
int family = 0; |
1624 |
const char *cmd, *volatile user = 0; |
1626 |
const char *cmd, *volatile user = 0, *srchostp = 0; |
1625 |
const char *portp = NULL; |
1627 |
const char *portp = NULL; |
1626 |
char *hostp = NULL; |
1628 |
char *hostp = NULL; |
|
|
1629 |
char *resolv_hostp; |
1630 |
struct addrinfo hints; |
1631 |
struct addrinfo *hostaddr = 0; |
1632 |
int res; |
1633 |
char name[NI_MAXHOST]; |
1634 |
char service[NI_MAXSERV]; |
1635 |
struct addrinfo *tmpaddr; |
1627 |
|
1636 |
|
1628 |
/* clear the socket address prior to use */ |
1637 |
/* clear the socket address prior to use */ |
1629 |
memset(&sn, 0, sizeof(sn)); |
1638 |
memset(&sn, 0, sizeof(sn)); |
Lines 1632-1637
Link Here
|
1632 |
printf("?Already connected to %s\n", hostname); |
1641 |
printf("?Already connected to %s\n", hostname); |
1633 |
return 0; |
1642 |
return 0; |
1634 |
} |
1643 |
} |
|
|
1644 |
if (_hostname) { |
1645 |
delete[] _hostname; |
1646 |
_hostname = 0; |
1647 |
} |
1635 |
if (argc < 2) { |
1648 |
if (argc < 2) { |
1636 |
(void) strcpy(line, "open "); |
1649 |
(void) strcpy(line, "open "); |
1637 |
printf("(to) "); |
1650 |
printf("(to) "); |
Lines 1657-1667
Link Here
|
1657 |
--argc; |
1670 |
--argc; |
1658 |
continue; |
1671 |
continue; |
1659 |
} |
1672 |
} |
|
|
1673 |
if (strcmp(*argv, "-b") == 0) { |
1674 |
--argc; ++argv; |
1675 |
if (argc == 0) |
1676 |
goto usage; |
1677 |
srchostp = *argv++; |
1678 |
--argc; |
1679 |
continue; |
1680 |
} |
1660 |
if (strcmp(*argv, "-a") == 0) { |
1681 |
if (strcmp(*argv, "-a") == 0) { |
1661 |
--argc; ++argv; |
1682 |
--argc; ++argv; |
1662 |
autologin = 1; |
1683 |
autologin = 1; |
1663 |
continue; |
1684 |
continue; |
1664 |
} |
1685 |
} |
|
|
1686 |
if (strcmp(*argv, "-6") == 0) { |
1687 |
--argc; ++argv; |
1688 |
#ifdef AF_INET6 |
1689 |
family = AF_INET6; |
1690 |
#else |
1691 |
puts("IPv6 unsupported"); |
1692 |
#endif |
1693 |
continue; |
1694 |
} |
1695 |
if (strcmp(*argv, "-4") == 0) { |
1696 |
--argc; ++argv; |
1697 |
family = AF_INET; |
1698 |
continue; |
1699 |
} |
1665 |
if (hostp == 0) { |
1700 |
if (hostp == 0) { |
1666 |
/* this leaks memory - FIXME */ |
1701 |
/* this leaks memory - FIXME */ |
1667 |
hostp = strdup(*argv++); |
1702 |
hostp = strdup(*argv++); |
Lines 1680-1685
Link Here
|
1680 |
if (hostp == 0) |
1715 |
if (hostp == 0) |
1681 |
goto usage; |
1716 |
goto usage; |
1682 |
|
1717 |
|
|
|
1718 |
resolv_hostp = hostp; |
1719 |
|
1683 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
1720 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
1684 |
if (hostp[0] == '@' || hostp[0] == '!') { |
1721 |
if (hostp[0] == '@' || hostp[0] == '!') { |
1685 |
if ((hostname = strrchr(hostp, ':')) == NULL) |
1722 |
if ((hostname = strrchr(hostp, ':')) == NULL) |
Lines 1696-1773
Link Here
|
1696 |
} else { |
1733 |
} else { |
1697 |
sn.sin_addr.s_addr = temp; |
1734 |
sn.sin_addr.s_addr = temp; |
1698 |
sn.sin_family = AF_INET; |
1735 |
sn.sin_family = AF_INET; |
|
|
1736 |
/* |
1737 |
* For source route we just make sure to get the IP given |
1738 |
* on the command line when looking up the port. |
1739 |
*/ |
1740 |
resolv_hostp = inet_ntoa(sn.sin_addr); |
1699 |
} |
1741 |
} |
1700 |
} |
1742 |
} |
1701 |
else { |
|
|
1702 |
#endif |
1703 |
if (inet_aton(hostp, &sn.sin_addr)) { |
1704 |
sn.sin_family = AF_INET; |
1705 |
strcpy(_hostname, hostp); |
1706 |
hostname = _hostname; |
1707 |
} |
1708 |
else { |
1709 |
host = gethostbyname(hostp); |
1710 |
if (host) { |
1711 |
sn.sin_family = host->h_addrtype; |
1712 |
if (host->h_length > (int)sizeof(sn.sin_addr)) { |
1713 |
host->h_length = sizeof(sn.sin_addr); |
1714 |
} |
1715 |
#if defined(h_addr) /* In 4.3, this is a #define */ |
1716 |
memcpy((caddr_t)&sn.sin_addr, |
1717 |
host->h_addr_list[0], host->h_length); |
1718 |
#else /* defined(h_addr) */ |
1719 |
memcpy((caddr_t)&sn.sin_addr, host->h_addr, host->h_length); |
1720 |
#endif /* defined(h_addr) */ |
1721 |
strncpy(_hostname, host->h_name, sizeof(_hostname)); |
1722 |
_hostname[sizeof(_hostname)-1] = '\0'; |
1723 |
hostname = _hostname; |
1724 |
} else { |
1725 |
herror(hostp); |
1726 |
return 0; |
1727 |
} |
1728 |
} |
1729 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
1730 |
} |
1731 |
#endif |
1743 |
#endif |
|
|
1744 |
|
1745 |
/* User port or the default name of telnet. */ |
1732 |
if (portp) { |
1746 |
if (portp) { |
1733 |
if (*portp == '-') { |
1747 |
if (*portp == '-') { |
1734 |
portp++; |
1748 |
portp++; |
1735 |
telnetport = 1; |
1749 |
telnetport = 1; |
1736 |
} else |
1750 |
} else |
1737 |
telnetport = 0; |
1751 |
telnetport = 0; |
1738 |
sn.sin_port = atoi(portp); |
1752 |
} |
1739 |
if (sn.sin_port == 0) { |
|
|
1740 |
sp = getservbyname(portp, "tcp"); |
1741 |
if (sp) |
1742 |
sn.sin_port = sp->s_port; |
1743 |
else { |
1744 |
printf("%s: bad port number\n", portp); |
1745 |
return 0; |
1746 |
} |
1747 |
} |
1748 |
else { |
1749 |
sn.sin_port = htons(sn.sin_port); |
1750 |
} |
1751 |
} |
1752 |
else { |
1753 |
else { |
1753 |
if (sp == 0) { |
1754 |
portp = "telnet"; |
1754 |
sp = getservbyname("telnet", "tcp"); |
|
|
1755 |
if (sp == 0) { |
1756 |
fprintf(stderr, "telnet: tcp/telnet: unknown service\n"); |
1757 |
return 0; |
1758 |
} |
1759 |
sn.sin_port = sp->s_port; |
1760 |
} |
1761 |
telnetport = 1; |
1755 |
telnetport = 1; |
1762 |
} |
1756 |
} |
1763 |
printf("Trying %s...\n", inet_ntoa(sn.sin_addr)); |
1757 |
|
|
|
1758 |
/* We only understand SOCK_STREAM sockets. */ |
1759 |
memset(&hints, 0, sizeof(hints)); |
1760 |
hints.ai_socktype = SOCK_STREAM; |
1761 |
hints.ai_flags = AI_NUMERICHOST; |
1762 |
hints.ai_family = family; |
1763 |
|
1764 |
if (srchostp) { |
1765 |
res = getaddrinfo(srchostp, "0", &hints, &hostaddr); |
1766 |
if (res) { |
1767 |
fprintf(stderr, "telnet: could not resolve %s: %s\n", srchostp, |
1768 |
gai_strerror(res)); |
1769 |
return 0; |
1770 |
} |
1771 |
hints.ai_family = hostaddr->ai_family; |
1772 |
res = nlink.bind(hostaddr); |
1773 |
freeaddrinfo(hostaddr); |
1774 |
if (res < 0) |
1775 |
return 0; |
1776 |
} |
1777 |
|
1778 |
/* Resolve both the host and service simultaneously. */ |
1779 |
res = getaddrinfo(resolv_hostp, portp, &hints, &hostaddr); |
1780 |
if (res == EAI_NONAME) { |
1781 |
hints.ai_flags = AI_CANONNAME; |
1782 |
res = getaddrinfo(resolv_hostp, portp, &hints, &hostaddr); |
1783 |
} else if (hostaddr) { |
1784 |
hostaddr->ai_canonname = 0; |
1785 |
} |
1786 |
if (res || !hostaddr) { |
1787 |
fprintf(stderr, "telnet: could not resolve %s/%s: %s\n", resolv_hostp, portp, gai_strerror(res)); |
1788 |
return 0; |
1789 |
} |
1790 |
|
1791 |
/* Try to connect to every listed round robin IP. */ |
1792 |
tmpaddr = hostaddr; |
1793 |
errno = 0; |
1764 |
do { |
1794 |
do { |
1765 |
int x = nlink.connect(debug, host, &sn, srp, srlen, tos); |
1795 |
int x; |
1766 |
if (!x) return 0; |
1796 |
|
1767 |
else if (x==1) continue; |
1797 |
if (!tmpaddr) { |
|
|
1798 |
if (errno) |
1799 |
perror("telnet: Unable to connect to remote host"); |
1800 |
else |
1801 |
fputs("telnet: Unable to connect to remote host: " |
1802 |
"Bad port number\n", stderr); |
1803 |
err: |
1804 |
freeaddrinfo(hostaddr); |
1805 |
return 0; |
1806 |
} |
1807 |
|
1808 |
if (tmpaddr->ai_family == AF_UNIX) { |
1809 |
nextaddr: |
1810 |
tmpaddr = tmpaddr->ai_next; |
1811 |
continue; |
1812 |
} |
1813 |
|
1814 |
getnameinfo(tmpaddr->ai_addr, tmpaddr->ai_addrlen, |
1815 |
name, sizeof(name), service, sizeof(service), |
1816 |
NI_NUMERICHOST | NI_NUMERICSERV); |
1817 |
|
1818 |
printf("Trying %s...\n", name); |
1819 |
x = nlink.connect(debug, tmpaddr, srp, srlen, tos); |
1820 |
if (!x) |
1821 |
goto err; |
1822 |
else if (x==1) |
1823 |
goto nextaddr; |
1824 |
|
1768 |
connected++; |
1825 |
connected++; |
1769 |
} while (connected == 0); |
1826 |
} while (connected == 0); |
1770 |
cmdrc(hostp, hostname); |
1827 |
if (tmpaddr->ai_canonname == 0) { |
|
|
1828 |
hostname = new char[strlen(hostp)+1]; |
1829 |
strcpy(hostname, hostp); |
1830 |
} |
1831 |
else { |
1832 |
hostname = new char[strlen(tmpaddr->ai_canonname)+1]; |
1833 |
strcpy(hostname, tmpaddr->ai_canonname); |
1834 |
} |
1835 |
|
1836 |
cmdrc(hostp, hostname, portp); |
1837 |
freeaddrinfo(hostaddr); |
1771 |
if (autologin && user == NULL) { |
1838 |
if (autologin && user == NULL) { |
1772 |
struct passwd *pw; |
1839 |
struct passwd *pw; |
1773 |
|
1840 |
|
Lines 2013-2042
Link Here
|
2013 |
return 0; |
2080 |
return 0; |
2014 |
} |
2081 |
} |
2015 |
|
2082 |
|
2016 |
static char *rcname = 0; |
2083 |
static void readrc(const char *m1, const char *m2, const char *port, |
2017 |
static char rcbuf[128]; |
2084 |
const char *rcname) |
2018 |
|
2085 |
{ |
2019 |
void cmdrc(const char *m1, const char *m2) { |
|
|
2020 |
FILE *rcfile; |
2086 |
FILE *rcfile; |
2021 |
int gotmachine = 0; |
2087 |
int gotmachine = 0; |
2022 |
int l1 = strlen(m1); |
2088 |
int l1 = strlen(m1); |
2023 |
int l2 = strlen(m2); |
2089 |
int l2 = strlen(m2); |
2024 |
char m1save[64]; |
2090 |
int lport = strlen(port); |
2025 |
|
2091 |
char m1save[l1 + 1]; |
2026 |
if (skiprc) return; |
2092 |
char portsave[lport + 1]; |
2027 |
|
2093 |
|
2028 |
strcpy(m1save, m1); |
2094 |
strcpy(m1save, m1); |
2029 |
m1 = m1save; |
2095 |
m1 = m1save; |
2030 |
|
2096 |
strcpy(portsave, port); |
2031 |
if (rcname == 0) { |
2097 |
port = portsave; |
2032 |
rcname = getenv("HOME"); |
|
|
2033 |
if (rcname) |
2034 |
strcpy(rcbuf, rcname); |
2035 |
else |
2036 |
rcbuf[0] = '\0'; |
2037 |
strcat(rcbuf, "/.telnetrc"); |
2038 |
rcname = rcbuf; |
2039 |
} |
2040 |
|
2098 |
|
2041 |
rcfile = fopen(rcname, "r"); |
2099 |
rcfile = fopen(rcname, "r"); |
2042 |
if (!rcfile) return; |
2100 |
if (!rcfile) return; |
Lines 2061-2066
Link Here
|
2061 |
strncpy(line, &line[7], sizeof(line) - 7); |
2119 |
strncpy(line, &line[7], sizeof(line) - 7); |
2062 |
else |
2120 |
else |
2063 |
continue; |
2121 |
continue; |
|
|
2122 |
|
2123 |
if (line[0] == ':') { |
2124 |
if (!strncasecmp(&line[1], port, lport)) |
2125 |
continue; |
2126 |
strncpy(line, &line[lport + 1], sizeof(line) - lport - 1); |
2127 |
} |
2128 |
|
2064 |
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n') |
2129 |
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n') |
2065 |
continue; |
2130 |
continue; |
2066 |
gotmachine = 1; |
2131 |
gotmachine = 1; |
Lines 2073-2078
Link Here
|
2073 |
fclose(rcfile); |
2138 |
fclose(rcfile); |
2074 |
} |
2139 |
} |
2075 |
|
2140 |
|
|
|
2141 |
void cmdrc(const char *m1, const char *m2, const char *port) { |
2142 |
char *rcname = NULL; |
2143 |
|
2144 |
if (skiprc) return; |
2145 |
|
2146 |
readrc(m1, m2, port, "/etc/telnetrc"); |
2147 |
if (asprintf (&rcname, "%s/.telnetrc", getenv ("HOME")) == -1) |
2148 |
{ |
2149 |
perror ("asprintf"); |
2150 |
return; |
2151 |
} |
2152 |
readrc(m1, m2, port, rcname); |
2153 |
free (rcname); |
2154 |
} |
2155 |
|
2076 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
2156 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
2077 |
|
2157 |
|
2078 |
/* |
2158 |
/* |
2079 |
-- netkit-telnet-0.17.orig/telnet/defines.h |
2159 |
++ netkit-telnet-0.17/telnet/defines.h |
Lines 50-52
Link Here
|
50 |
#define MODE_COMMAND_LINE(m) ((m)==-1) |
50 |
#define MODE_COMMAND_LINE(m) ((m)==-1) |
51 |
|
51 |
|
52 |
#define CONTROL(x) ((x)&0x1f) /* CTRL(x) is not portable */ |
52 |
#define CONTROL(x) ((x)&0x1f) /* CTRL(x) is not portable */ |
53 |
-- netkit-telnet-0.17.orig/telnet/externs.h |
53 |
|
|
|
54 |
#define MODE_OUT8 0x8000 /* binary mode sans -opost */ |
|
|
55 |
++ netkit-telnet-0.17/telnet/externs.h |
Lines 48-56
Link Here
|
48 |
typedef unsigned char cc_t; |
48 |
typedef unsigned char cc_t; |
49 |
#endif |
49 |
#endif |
50 |
|
50 |
|
51 |
#ifdef __linux__ |
|
|
52 |
#include <unistd.h> /* get _POSIX_VDISABLE */ |
51 |
#include <unistd.h> /* get _POSIX_VDISABLE */ |
53 |
#endif |
|
|
54 |
|
52 |
|
55 |
#ifndef _POSIX_VDISABLE |
53 |
#ifndef _POSIX_VDISABLE |
56 |
#error "Please fix externs.h to define _POSIX_VDISABLE" |
54 |
#error "Please fix externs.h to define _POSIX_VDISABLE" |
Lines 60-66
Link Here
|
60 |
|
58 |
|
61 |
extern int autologin; /* Autologin enabled */ |
59 |
extern int autologin; /* Autologin enabled */ |
62 |
extern int skiprc; /* Don't process the ~/.telnetrc file */ |
60 |
extern int skiprc; /* Don't process the ~/.telnetrc file */ |
63 |
extern int eight; /* use eight bit mode (binary in and/or out */ |
61 |
extern int eight; /* use eight bit mode (binary in and/or out) */ |
|
|
62 |
extern int binary; /* use binary option (in and/or out) */ |
64 |
extern int flushout; /* flush output */ |
63 |
extern int flushout; /* flush output */ |
65 |
extern int connected; /* Are we connected to the other side? */ |
64 |
extern int connected; /* Are we connected to the other side? */ |
66 |
extern int globalmode; /* Mode tty should be in */ |
65 |
extern int globalmode; /* Mode tty should be in */ |
Lines 225-230
Link Here
|
225 |
|
224 |
|
226 |
//#if 0 |
225 |
//#if 0 |
227 |
extern struct termios new_tc; |
226 |
extern struct termios new_tc; |
|
|
227 |
extern struct termios old_tc; |
228 |
|
228 |
|
229 |
|
229 |
#define termEofChar new_tc.c_cc[VEOF] |
230 |
#define termEofChar new_tc.c_cc[VEOF] |
230 |
#define termEraseChar new_tc.c_cc[VERASE] |
231 |
#define termEraseChar new_tc.c_cc[VERASE] |
231 |
-- netkit-telnet-0.17.orig/telnet/main.cc |
232 |
++ netkit-telnet-0.17/telnet/main.cc |
Lines 45-51
Link Here
|
45 |
|
45 |
|
46 |
#include <sys/types.h> |
46 |
#include <sys/types.h> |
47 |
#include <getopt.h> |
47 |
#include <getopt.h> |
|
|
48 |
#include <stdlib.h> |
48 |
#include <string.h> |
49 |
#include <string.h> |
|
|
50 |
#include <netdb.h> |
51 |
#include <errno.h> |
49 |
|
52 |
|
50 |
#include "ring.h" |
53 |
#include "ring.h" |
51 |
#include "externs.h" |
54 |
#include "externs.h" |
Lines 80-91
Link Here
|
80 |
void usage(void) { |
83 |
void usage(void) { |
81 |
fprintf(stderr, "Usage: %s %s%s%s%s\n", |
84 |
fprintf(stderr, "Usage: %s %s%s%s%s\n", |
82 |
prompt, |
85 |
prompt, |
83 |
" [-8] [-E] [-L] [-a] [-d] [-e char] [-l user] [-n tracefile]", |
86 |
"[-4] [-6] [-8] [-E] [-L] [-a] [-d] [-e char] [-l user]", |
84 |
"\n\t", |
87 |
"\n\t[-n tracefile] [ -b addr ]", |
85 |
#ifdef TN3270 |
88 |
#ifdef TN3270 |
|
|
89 |
"\n\t" |
86 |
"[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t", |
90 |
"[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t", |
87 |
#else |
91 |
#else |
88 |
"[-r] ", |
92 |
" [-r] ", |
89 |
#endif |
93 |
#endif |
90 |
"[host-name [port]]" |
94 |
"[host-name [port]]" |
91 |
); |
95 |
); |
Lines 102-108
Link Here
|
102 |
extern char *optarg; |
106 |
extern char *optarg; |
103 |
extern int optind; |
107 |
extern int optind; |
104 |
int ch; |
108 |
int ch; |
105 |
char *user; |
109 |
char *user, *srcaddr; |
|
|
110 |
int family; |
106 |
|
111 |
|
107 |
tninit(); /* Clear out things */ |
112 |
tninit(); /* Clear out things */ |
108 |
#if defined(CRAY) && !defined(__STDC__) |
113 |
#if defined(CRAY) && !defined(__STDC__) |
Lines 110-130
Link Here
|
110 |
#endif |
115 |
#endif |
111 |
|
116 |
|
112 |
TerminalSaveState(); |
117 |
TerminalSaveState(); |
|
|
118 |
if ((old_tc.c_cflag & (CSIZE|PARENB)) != CS8) |
119 |
eight = 0; |
113 |
|
120 |
|
114 |
if ((prompt = strrchr(argv[0], '/'))!=NULL) |
121 |
if ((prompt = strrchr(argv[0], '/'))!=NULL) |
115 |
++prompt; |
122 |
++prompt; |
116 |
else |
123 |
else |
117 |
prompt = argv[0]; |
124 |
prompt = argv[0]; |
118 |
|
125 |
|
119 |
user = NULL; |
126 |
user = srcaddr = NULL; |
|
|
127 |
family = 0; |
120 |
|
128 |
|
121 |
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; |
129 |
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; |
122 |
autologin = -1; |
130 |
autologin = -1; |
123 |
|
131 |
|
124 |
while ((ch = getopt(argc, argv, "8EKLS:X:ade:k:l:n:rt:x")) != EOF) { |
132 |
while ((ch = getopt(argc, argv, |
|
|
133 |
"4678EKLS:X:ab:de:k:l:n:rt:x")) != EOF) { |
125 |
switch(ch) { |
134 |
switch(ch) { |
|
|
135 |
case '4': |
136 |
family = AF_INET; |
137 |
break; |
138 |
case '6': |
139 |
#ifdef AF_INET6 |
140 |
family = AF_INET6; |
141 |
#else |
142 |
fputs("IPv6 unsupported\n", stderr); |
143 |
#endif |
144 |
break; |
145 |
case '7': |
146 |
eight = 0; /* 7-bit ouput and input */ |
147 |
break; |
126 |
case '8': |
148 |
case '8': |
127 |
eight = 3; /* binary output and input */ |
149 |
binary = 3; /* binary output and input */ |
128 |
break; |
150 |
break; |
129 |
case 'E': |
151 |
case 'E': |
130 |
rlogin = escapechar = _POSIX_VDISABLE; |
152 |
rlogin = escapechar = _POSIX_VDISABLE; |
Lines 133-155
Link Here
|
133 |
//autologin = 0; |
155 |
//autologin = 0; |
134 |
break; |
156 |
break; |
135 |
case 'L': |
157 |
case 'L': |
136 |
eight |= 2; /* binary output only */ |
158 |
binary |= 2; /* binary output only */ |
137 |
break; |
159 |
break; |
138 |
case 'S': |
160 |
case 'S': |
139 |
{ |
161 |
{ |
140 |
#ifdef HAS_GETTOS |
|
|
141 |
extern int tos; |
162 |
extern int tos; |
|
|
163 |
int num; |
142 |
|
164 |
|
143 |
if ((tos = parsetos(optarg, "tcp")) < 0) |
165 |
#ifdef HAS_GETTOS |
|
|
166 |
if ((num = parsetos(optarg, "tcp")) < 0) { |
167 |
#else |
168 |
errno = 0; |
169 |
num = strtol(optarg, 0, 0); |
170 |
if (errno) { |
171 |
#endif |
144 |
fprintf(stderr, "%s%s%s%s\n", |
172 |
fprintf(stderr, "%s%s%s%s\n", |
145 |
prompt, ": Bad TOS argument '", |
173 |
prompt, ": Bad TOS argument '", |
146 |
optarg, |
174 |
optarg, |
147 |
"; will try to use default TOS"); |
175 |
"; will try to use default TOS"); |
148 |
#else |
176 |
} else |
149 |
fprintf(stderr, |
177 |
tos = num; |
150 |
"%s: Warning: -S ignored, no parsetos() support.\n", |
|
|
151 |
prompt); |
152 |
#endif |
153 |
} |
178 |
} |
154 |
break; |
179 |
break; |
155 |
case 'X': |
180 |
case 'X': |
Lines 210-215
Link Here
|
210 |
"%s: -x ignored, no encryption support.\n", |
235 |
"%s: -x ignored, no encryption support.\n", |
211 |
prompt); |
236 |
prompt); |
212 |
break; |
237 |
break; |
|
|
238 |
case 'b': |
239 |
srcaddr = optarg; |
240 |
break; |
213 |
case '?': |
241 |
case '?': |
214 |
default: |
242 |
default: |
215 |
usage(); |
243 |
usage(); |
Lines 233-238
Link Here
|
233 |
*argp++ = "-l"; |
261 |
*argp++ = "-l"; |
234 |
*argp++ = user; |
262 |
*argp++ = user; |
235 |
} |
263 |
} |
|
|
264 |
if (srcaddr) { |
265 |
*argp++ = "-b"; |
266 |
*argp++ = srcaddr; |
267 |
} |
268 |
if (family) { |
269 |
*argp++ = family == AF_INET ? "-4" : "-6"; |
270 |
} |
236 |
*argp++ = argv[0]; /* host */ |
271 |
*argp++ = argv[0]; /* host */ |
237 |
if (argc > 1) |
272 |
if (argc > 1) |
238 |
*argp++ = argv[1]; /* port */ |
273 |
*argp++ = argv[1]; /* port */ |
239 |
-- netkit-telnet-0.17.orig/telnet/netlink.cc |
274 |
++ netkit-telnet-0.17/telnet/netlink.cc |
Lines 79-100
Link Here
|
79 |
shutdown(net, 2); |
79 |
shutdown(net, 2); |
80 |
} |
80 |
} |
81 |
::close(net); |
81 |
::close(net); |
|
|
82 |
net = -1; |
82 |
} |
83 |
} |
83 |
|
84 |
|
84 |
int netlink::connect(int debug, struct hostent *host, |
85 |
int netlink::bind(struct addrinfo *addr) |
85 |
struct sockaddr_in *sn, |
|
|
86 |
char *srcroute, int srlen, int tos) |
87 |
{ |
86 |
{ |
88 |
int on=1; |
87 |
int res; |
|
|
88 |
|
89 |
res = socket(addr->ai_family); |
90 |
if (res < 2) { |
91 |
if (res == 1) |
92 |
perror("telnet: socket"); |
93 |
return -1; |
94 |
} |
95 |
|
96 |
if (::bind(net, addr->ai_addr, addr->ai_addrlen) < 0) { |
97 |
perror("telnet: bind"); |
98 |
return -1; |
99 |
} |
100 |
|
101 |
return 0; |
102 |
} |
103 |
|
104 |
int netlink::socket(int family) |
105 |
{ |
106 |
if (this->family != family) |
107 |
close(0); |
89 |
|
108 |
|
90 |
net = socket(AF_INET, SOCK_STREAM, 0); |
|
|
91 |
if (net < 0) { |
109 |
if (net < 0) { |
92 |
perror("telnet: socket"); |
110 |
this->family = family; |
93 |
return 0; |
111 |
net = ::socket(family, SOCK_STREAM, 0); |
|
|
112 |
if (net < 0) { |
113 |
if (errno == EAFNOSUPPORT) |
114 |
return 1; |
115 |
perror("telnet: socket"); |
116 |
return 0; |
117 |
} |
94 |
} |
118 |
} |
95 |
|
119 |
|
|
|
120 |
return 2; |
121 |
} |
122 |
|
123 |
int netlink::connect(int debug, struct addrinfo *addr, |
124 |
char *srcroute, int srlen, int tos) |
125 |
{ |
126 |
int on=1; |
127 |
int res; |
128 |
|
129 |
res = socket(addr->ai_family); |
130 |
if (res < 2) |
131 |
return res; |
132 |
|
96 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
133 |
#if defined(IP_OPTIONS) && defined(HAS_IPPROTO_IP) |
97 |
if (srcroute) { |
134 |
if (srcroute) { |
|
|
135 |
if (addr->ai_family != AF_INET) |
136 |
fputs("Source route is only supported for IPv4\n", stderr); |
98 |
if (setsockopt(net, IPPROTO_IP, IP_OPTIONS, srcroute, srlen) < 0) |
137 |
if (setsockopt(net, IPPROTO_IP, IP_OPTIONS, srcroute, srlen) < 0) |
99 |
perror("setsockopt (IP_OPTIONS)"); |
138 |
perror("setsockopt (IP_OPTIONS)"); |
100 |
} |
139 |
} |
Lines 108-114
Link Here
|
108 |
#endif |
147 |
#endif |
109 |
if (tos < 0) tos = 020; /* Low Delay bit */ |
148 |
if (tos < 0) tos = 020; /* Low Delay bit */ |
110 |
if (tos && (setsockopt(net, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0) |
149 |
if (tos && (setsockopt(net, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0) |
111 |
&& (errno != ENOPROTOOPT)) |
150 |
&& (errno != ENOPROTOOPT) && (errno != EOPNOTSUPP)) |
112 |
perror("telnet: setsockopt (IP_TOS) (ignored)"); |
151 |
perror("telnet: setsockopt (IP_TOS) (ignored)"); |
113 |
#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */ |
152 |
#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */ |
114 |
|
153 |
|
Lines 116-142
Link Here
|
116 |
perror("setsockopt (SO_DEBUG)"); |
155 |
perror("setsockopt (SO_DEBUG)"); |
117 |
} |
156 |
} |
118 |
|
157 |
|
119 |
if (::connect(net, (struct sockaddr *)sn, sizeof(*sn)) < 0) { |
158 |
if (::connect(net, addr->ai_addr, addr->ai_addrlen) < 0) { |
120 |
#if defined(h_addr) /* In 4.3, this is a #define */ |
159 |
return 1; |
121 |
if (host && host->h_addr_list[1]) { |
|
|
122 |
int oerrno = errno; |
123 |
|
124 |
fprintf(stderr, "telnet: connect to address %s: ", |
125 |
inet_ntoa(sn->sin_addr)); |
126 |
errno = oerrno; |
127 |
perror(NULL); |
128 |
host->h_addr_list++; |
129 |
if (host->h_length > (int)sizeof(sn->sin_addr)) { |
130 |
host->h_length = sizeof(sn->sin_addr); |
131 |
} |
132 |
memcpy(&sn->sin_addr, host->h_addr_list[0], host->h_length); |
133 |
close(net); |
134 |
return 1; |
135 |
} |
136 |
#endif /* defined(h_addr) */ |
137 |
|
138 |
perror("telnet: Unable to connect to remote host"); |
139 |
return 0; |
140 |
} |
160 |
} |
141 |
return 2; |
161 |
return 2; |
142 |
} |
162 |
} |
143 |
-- netkit-telnet-0.17.orig/telnet/netlink.h |
163 |
++ netkit-telnet-0.17/telnet/netlink.h |
Lines 1-13
Link Here
|
1 |
|
1 |
|
2 |
class netlink { |
2 |
class netlink { |
|
|
3 |
private: |
4 |
int family; |
3 |
protected: |
5 |
protected: |
4 |
int net; |
6 |
int net; |
5 |
public: |
7 |
public: |
6 |
netlink(); |
8 |
netlink(); |
7 |
~netlink(); |
9 |
~netlink(); |
8 |
|
10 |
|
9 |
int connect(int debug, struct hostent *host, |
11 |
int bind(struct addrinfo *hostaddr); |
10 |
struct sockaddr_in *sin, |
12 |
int socket(int family); |
|
|
13 |
int connect(int debug, struct addrinfo *hostaddr, |
11 |
char *srcroute, int srlen, |
14 |
char *srcroute, int srlen, |
12 |
int tos); |
15 |
int tos); |
13 |
void close(int doshutdown); |
16 |
void close(int doshutdown); |
14 |
-- netkit-telnet-0.17.orig/telnet/network.cc |
17 |
++ netkit-telnet-0.17/telnet/network.cc |
Lines 40-45
Link Here
|
40 |
#include <sys/types.h> |
40 |
#include <sys/types.h> |
41 |
#include <sys/socket.h> |
41 |
#include <sys/socket.h> |
42 |
#include <sys/time.h> |
42 |
#include <sys/time.h> |
|
|
43 |
#include <stdlib.h> |
43 |
#include <errno.h> |
44 |
#include <errno.h> |
44 |
#include <arpa/telnet.h> |
45 |
#include <arpa/telnet.h> |
45 |
|
46 |
|
46 |
-- netkit-telnet-0.17.orig/telnet/proto.h |
47 |
++ netkit-telnet-0.17/telnet/proto.h |
Lines 13-19
Link Here
|
13 |
void auth_encrypt_user(char *); |
13 |
void auth_encrypt_user(char *); |
14 |
void auth_name(unsigned char *, int); |
14 |
void auth_name(unsigned char *, int); |
15 |
void auth_printsub(unsigned char *, int, unsigned char *, int); |
15 |
void auth_printsub(unsigned char *, int, unsigned char *, int); |
16 |
void cmdrc(const char *m1, const char *m2); |
16 |
void cmdrc(const char *, const char *, const char *); |
17 |
void env_init(void); |
17 |
void env_init(void); |
18 |
int getconnmode(void); |
18 |
int getconnmode(void); |
19 |
void init_network(void); |
19 |
void init_network(void); |
20 |
-- netkit-telnet-0.17.orig/telnet/ring.cc |
20 |
++ netkit-telnet-0.17/telnet/ring.cc |
Lines 165-171
Link Here
|
165 |
|
165 |
|
166 |
/////////////////////////////////////////////////// supply ////////////// |
166 |
/////////////////////////////////////////////////// supply ////////////// |
167 |
|
167 |
|
168 |
void ringbuf::printf(const char *format, ...) { |
168 |
void ringbuf::xprintf(const char *format, ...) { |
169 |
char xbuf[256]; |
169 |
char xbuf[256]; |
170 |
va_list ap; |
170 |
va_list ap; |
171 |
va_start(ap, format); |
171 |
va_start(ap, format); |
172 |
-- netkit-telnet-0.17.orig/telnet/ring.h |
172 |
++ netkit-telnet-0.17/telnet/ring.h |
Lines 83-89
Link Here
|
83 |
// manual supply |
83 |
// manual supply |
84 |
void putch(char c) { write(&c, 1); } |
84 |
void putch(char c) { write(&c, 1); } |
85 |
void write(const char *buffer, int ct); |
85 |
void write(const char *buffer, int ct); |
86 |
void printf(const char *format, ...); |
86 |
void xprintf(const char *format, ...); |
87 |
int empty_count() { return size - count; } |
87 |
int empty_count() { return size - count; } |
88 |
|
88 |
|
89 |
// automatic supply |
89 |
// automatic supply |
90 |
-- netkit-telnet-0.17.orig/telnet/sys_bsd.cc |
90 |
++ netkit-telnet-0.17/telnet/sys_bsd.cc |
Lines 189-206
Link Here
|
189 |
* Various signal handling routines. |
189 |
* Various signal handling routines. |
190 |
*/ |
190 |
*/ |
191 |
|
191 |
|
|
|
192 |
#if 0 |
192 |
static void deadpeer(int /*sig*/) { |
193 |
static void deadpeer(int /*sig*/) { |
193 |
setcommandmode(); |
194 |
setcommandmode(); |
194 |
siglongjmp(peerdied, -1); |
195 |
siglongjmp(peerdied, -1); |
195 |
} |
196 |
} |
|
|
197 |
#endif |
196 |
|
198 |
|
197 |
static void intr(int /*sig*/) { |
199 |
static void intr(int /*sig*/) { |
198 |
if (localchars) { |
200 |
if (localchars) { |
199 |
intp(); |
201 |
intp(); |
200 |
} |
202 |
} |
201 |
else { |
203 |
else { |
|
|
204 |
#if 0 |
202 |
setcommandmode(); |
205 |
setcommandmode(); |
203 |
siglongjmp(toplevel, -1); |
206 |
siglongjmp(toplevel, -1); |
|
|
207 |
#else |
208 |
signal(SIGINT, SIG_DFL); |
209 |
raise(SIGINT); |
210 |
#endif |
204 |
} |
211 |
} |
205 |
} |
212 |
} |
206 |
|
213 |
|
Lines 214-219
Link Here
|
214 |
sendabort(); |
221 |
sendabort(); |
215 |
return; |
222 |
return; |
216 |
} |
223 |
} |
|
|
224 |
signal(SIGQUIT, SIG_DFL); |
225 |
raise(SIGQUIT); |
217 |
} |
226 |
} |
218 |
|
227 |
|
219 |
#ifdef SIGWINCH |
228 |
#ifdef SIGWINCH |
Lines 238-244
Link Here
|
238 |
void sys_telnet_init(void) { |
247 |
void sys_telnet_init(void) { |
239 |
signal(SIGINT, intr); |
248 |
signal(SIGINT, intr); |
240 |
signal(SIGQUIT, intr2); |
249 |
signal(SIGQUIT, intr2); |
|
|
250 |
#if 0 |
241 |
signal(SIGPIPE, deadpeer); |
251 |
signal(SIGPIPE, deadpeer); |
|
|
252 |
#endif |
242 |
#ifdef SIGWINCH |
253 |
#ifdef SIGWINCH |
243 |
signal(SIGWINCH, sendwin); |
254 |
signal(SIGWINCH, sendwin); |
244 |
#endif |
255 |
#endif |
245 |
-- netkit-telnet-0.17.orig/telnet/telnet.1 |
256 |
++ netkit-telnet-0.17/telnet/telnet.1 |
Lines 42-49
Link Here
|
42 |
protocol |
42 |
protocol |
43 |
.Sh SYNOPSIS |
43 |
.Sh SYNOPSIS |
44 |
.Nm telnet |
44 |
.Nm telnet |
45 |
.Op Fl 8ELadr |
45 |
.Op Fl 468ELadr |
46 |
.Op Fl S Ar tos |
46 |
.Op Fl S Ar tos |
|
|
47 |
.Op Fl b Ar address |
47 |
.Op Fl e Ar escapechar |
48 |
.Op Fl e Ar escapechar |
48 |
.Op Fl l Ar user |
49 |
.Op Fl l Ar user |
49 |
.Op Fl n Ar tracefile |
50 |
.Op Fl n Ar tracefile |
Lines 68-73
Link Here
|
68 |
.Pp |
69 |
.Pp |
69 |
Options: |
70 |
Options: |
70 |
.Bl -tag -width indent |
71 |
.Bl -tag -width indent |
|
|
72 |
.It Fl 4 |
73 |
Force IPv4 address resolution. |
74 |
.It Fl 6 |
75 |
Force IPv6 address resolution. |
71 |
.It Fl 8 |
76 |
.It Fl 8 |
72 |
Request 8-bit operation. This causes an attempt to negotiate the |
77 |
Request 8-bit operation. This causes an attempt to negotiate the |
73 |
.Dv TELNET BINARY |
78 |
.Dv TELNET BINARY |
Lines 89-94
Link Here
|
89 |
option if supported by the remote system. The username is retrieved |
94 |
option if supported by the remote system. The username is retrieved |
90 |
via |
95 |
via |
91 |
.Xr getlogin 3 . |
96 |
.Xr getlogin 3 . |
|
|
97 |
.It Fl b Ar address |
98 |
Use bind(2) on the local socket to bind it to a specific local address. |
92 |
.It Fl d |
99 |
.It Fl d |
93 |
Sets the initial value of the |
100 |
Sets the initial value of the |
94 |
.Ic debug |
101 |
.Ic debug |
Lines 474-490
Link Here
|
474 |
placing a dash before the port number. |
481 |
placing a dash before the port number. |
475 |
.Pp |
482 |
.Pp |
476 |
After establishing a connection, any commands associated with the |
483 |
After establishing a connection, any commands associated with the |
477 |
remote host in the user's |
484 |
remote host in |
|
|
485 |
.Pa /etc/telnetrc |
486 |
and the user's |
478 |
.Pa .telnetrc |
487 |
.Pa .telnetrc |
479 |
file are executed. |
488 |
file are executed, in that order. |
480 |
.Pp |
489 |
.Pp |
481 |
The format of the .telnetrc file is as follows: Lines beginning with a |
490 |
The format of the telnetrc files is as follows: Lines beginning with a |
482 |
#, and blank lines, are ignored. The rest of the file should consist |
491 |
#, and blank lines, are ignored. The rest of the file should consist |
483 |
of hostnames and sequences of |
492 |
of hostnames and sequences of |
484 |
.Nm telnet |
493 |
.Nm telnet |
485 |
commands to use with that host. Commands should be one per line, |
494 |
commands to use with that host. Commands should be one per line, |
486 |
indented by whitespace; lines beginning without whitespace are |
495 |
indented by whitespace; lines beginning without whitespace are |
487 |
interpreted as hostnames. Upon connecting to a particular host, the |
496 |
interpreted as hostnames. Lines beginning with the special hostname |
|
|
497 |
.Ql DEFAULT |
498 |
will apply to all hosts. Hostnames including |
499 |
.Ql DEFAULT |
500 |
may be followed immediately by a colon and a port number or string. |
501 |
If a port is specified it must match exactly with what is specified |
502 |
on the command line. If no port was specified on the command line, |
503 |
then the value |
504 |
.Ql telnet |
505 |
is used. |
506 |
Upon connecting to a particular host, the |
488 |
commands associated with that host are executed. |
507 |
commands associated with that host are executed. |
489 |
.It Ic quit |
508 |
.It Ic quit |
490 |
Close any open session and exit |
509 |
Close any open session and exit |
Lines 1184-1192
Link Here
|
1184 |
When the skiprc toggle is |
1203 |
When the skiprc toggle is |
1185 |
.Dv TRUE , |
1204 |
.Dv TRUE , |
1186 |
.Tn telnet |
1205 |
.Tn telnet |
1187 |
does not read the |
1206 |
does not read the telnetrc files. The initial value for this toggle is |
1188 |
.Pa \&.telnetrc |
|
|
1189 |
file. The initial value for this toggle is |
1190 |
.Dv FALSE. |
1207 |
.Dv FALSE. |
1191 |
.It Ic termdata |
1208 |
.It Ic termdata |
1192 |
Toggles the display of all terminal data (in hexadecimal format). |
1209 |
Toggles the display of all terminal data (in hexadecimal format). |
Lines 1239-1245
Link Here
|
1239 |
.Dv TELNET ENVIRON |
1256 |
.Dv TELNET ENVIRON |
1240 |
option. |
1257 |
option. |
1241 |
.Sh FILES |
1258 |
.Sh FILES |
1242 |
.Bl -tag -width ~/.telnetrc -compact |
1259 |
.Bl -tag -width /etc/telnetrc -compact |
|
|
1260 |
.It Pa /etc/telnetrc |
1261 |
global telnet startup values |
1243 |
.It Pa ~/.telnetrc |
1262 |
.It Pa ~/.telnetrc |
1244 |
user customized telnet startup values |
1263 |
user customized telnet startup values |
1245 |
.El |
1264 |
.El |
1246 |
-- netkit-telnet-0.17.orig/telnet/telnet.cc |
1265 |
++ netkit-telnet-0.17/telnet/telnet.cc |
Lines 88-94
Link Here
|
88 |
char will_wont_resp[256]; |
88 |
char will_wont_resp[256]; |
89 |
|
89 |
|
90 |
int |
90 |
int |
91 |
eight = 0, |
91 |
eight = 3, |
|
|
92 |
binary = 0, |
92 |
autologin = 0, /* Autologin anyone? */ |
93 |
autologin = 0, /* Autologin anyone? */ |
93 |
skiprc = 0, |
94 |
skiprc = 0, |
94 |
connected, |
95 |
connected, |
Lines 646-652
Link Here
|
646 |
mklist(termbuf, tname, termtypes); |
647 |
mklist(termbuf, tname, termtypes); |
647 |
next = 0; |
648 |
next = 0; |
648 |
} |
649 |
} |
649 |
if (next==termtypes.num()) next = 0; |
650 |
if (next==termtypes.num()-1) next = 0; |
650 |
return termtypes[next++]; |
651 |
return termtypes[next++]; |
651 |
} |
652 |
} |
652 |
/* |
653 |
/* |
Lines 681-687
Link Here
|
681 |
} |
682 |
} |
682 |
#endif /* TN3270 */ |
683 |
#endif /* TN3270 */ |
683 |
name = gettermname(); |
684 |
name = gettermname(); |
684 |
netoring.printf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE, |
685 |
netoring.xprintf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE, |
685 |
TELQUAL_IS, name, IAC, SE); |
686 |
TELQUAL_IS, name, IAC, SE); |
686 |
} |
687 |
} |
687 |
break; |
688 |
break; |
Lines 693-699
Link Here
|
693 |
if (SB_GET() == TELQUAL_SEND) { |
694 |
if (SB_GET() == TELQUAL_SEND) { |
694 |
long oospeed, iispeed; |
695 |
long oospeed, iispeed; |
695 |
TerminalSpeeds(&iispeed, &oospeed); |
696 |
TerminalSpeeds(&iispeed, &oospeed); |
696 |
netoring.printf("%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, |
697 |
netoring.xprintf("%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, |
697 |
TELQUAL_IS, oospeed, iispeed, IAC, SE); |
698 |
TELQUAL_IS, oospeed, iispeed, IAC, SE); |
698 |
} |
699 |
} |
699 |
break; |
700 |
break; |
Lines 780-786
Link Here
|
780 |
send_wont(TELOPT_XDISPLOC, 1); |
781 |
send_wont(TELOPT_XDISPLOC, 1); |
781 |
break; |
782 |
break; |
782 |
} |
783 |
} |
783 |
netoring.printf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC, |
784 |
netoring.xprintf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC, |
784 |
TELQUAL_IS, dp, IAC, SE); |
785 |
TELQUAL_IS, dp, IAC, SE); |
785 |
} |
786 |
} |
786 |
break; |
787 |
break; |
Lines 798-804
Link Here
|
798 |
return; |
799 |
return; |
799 |
} |
800 |
} |
800 |
|
801 |
|
801 |
netoring.printf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
802 |
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
802 |
DONT, cmd[0], IAC, SE); |
803 |
DONT, cmd[0], IAC, SE); |
803 |
} |
804 |
} |
804 |
|
805 |
|
Lines 815-821
Link Here
|
815 |
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ |
816 |
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ |
816 |
return; |
817 |
return; |
817 |
} |
818 |
} |
818 |
netoring.printf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
819 |
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
819 |
WONT, cmd[0], IAC, SE); |
820 |
WONT, cmd[0], IAC, SE); |
820 |
} |
821 |
} |
821 |
|
822 |
|
Lines 838-844
Link Here
|
838 |
k |= MODE_ACK; |
839 |
k |= MODE_ACK; |
839 |
} |
840 |
} |
840 |
|
841 |
|
841 |
netoring.printf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, LM_MODE, |
842 |
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, LM_MODE, |
842 |
k, IAC, SE); |
843 |
k, IAC, SE); |
843 |
|
844 |
|
844 |
setconnmode(0); /* set changed mode */ |
845 |
setconnmode(0); /* set changed mode */ |
Lines 933-943
Link Here
|
933 |
|
934 |
|
934 |
void slc_import(int def) { |
935 |
void slc_import(int def) { |
935 |
if (def) { |
936 |
if (def) { |
936 |
netoring.printf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
937 |
netoring.xprintf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
937 |
LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE); |
938 |
LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE); |
938 |
} |
939 |
} |
939 |
else { |
940 |
else { |
940 |
netoring.printf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
941 |
netoring.xprintf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, |
941 |
LM_SLC, 0, SLC_VARIABLE, 0, IAC, SE); |
942 |
LM_SLC, 0, SLC_VARIABLE, 0, IAC, SE); |
942 |
} |
943 |
} |
943 |
} |
944 |
} |
Lines 1142-1147
Link Here
|
1142 |
} |
1143 |
} |
1143 |
} |
1144 |
} |
1144 |
|
1145 |
|
|
|
1146 |
/* OPT_REPLY_SIZE must be a multiple of 2. */ |
1145 |
#define OPT_REPLY_SIZE 256 |
1147 |
#define OPT_REPLY_SIZE 256 |
1146 |
unsigned char *opt_reply; |
1148 |
unsigned char *opt_reply; |
1147 |
unsigned char *opt_replyp; |
1149 |
unsigned char *opt_replyp; |
Lines 1173-1178
Link Here
|
1173 |
|
1175 |
|
1174 |
void env_opt_add(const char *ep) { |
1176 |
void env_opt_add(const char *ep) { |
1175 |
const char *vp; |
1177 |
const char *vp; |
|
|
1178 |
const unsigned char *tp; |
1176 |
unsigned char c; |
1179 |
unsigned char c; |
1177 |
|
1180 |
|
1178 |
if (opt_reply == NULL) /*XXX*/ |
1181 |
if (opt_reply == NULL) /*XXX*/ |
Lines 1185-1195
Link Here
|
1185 |
return; |
1188 |
return; |
1186 |
} |
1189 |
} |
1187 |
vp = env_getvalue(ep, 1); |
1190 |
vp = env_getvalue(ep, 1); |
1188 |
if (opt_replyp + (vp ? strlen(vp) : 0) + strlen(ep) + 6 > opt_replyend) |
1191 |
tp = opt_replyp + (vp ? strlen(vp) * 2 : 0) + strlen(ep) * 2 + 6; |
|
|
1192 |
if (tp > opt_replyend) |
1189 |
{ |
1193 |
{ |
1190 |
register int len; |
1194 |
register int len; |
1191 |
opt_replyend += OPT_REPLY_SIZE; |
1195 |
len = ((tp - opt_reply) + OPT_REPLY_SIZE - 1) & ~(OPT_REPLY_SIZE - 1); |
1192 |
len = opt_replyend - opt_reply; |
1196 |
opt_replyend = opt_reply + len; |
1193 |
opt_reply = (unsigned char *)realloc(opt_reply, len); |
1197 |
opt_reply = (unsigned char *)realloc(opt_reply, len); |
1194 |
if (opt_reply == NULL) { |
1198 |
if (opt_reply == NULL) { |
1195 |
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
1199 |
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
Lines 1740-1747
Link Here
|
1740 |
send_do(TELOPT_STATUS, 1); |
1744 |
send_do(TELOPT_STATUS, 1); |
1741 |
if (env_getvalue("DISPLAY", 0)) |
1745 |
if (env_getvalue("DISPLAY", 0)) |
1742 |
send_will(TELOPT_XDISPLOC, 1); |
1746 |
send_will(TELOPT_XDISPLOC, 1); |
1743 |
if (eight) |
1747 |
if (binary) |
1744 |
tel_enter_binary(eight); |
1748 |
tel_enter_binary(binary); |
1745 |
} |
1749 |
} |
1746 |
#endif /* !defined(TN3270) */ |
1750 |
#endif /* !defined(TN3270) */ |
1747 |
|
1751 |
|
1748 |
-- netkit-telnet-0.17.orig/telnet/terminal.cc |
1752 |
++ netkit-telnet-0.17/telnet/terminal.cc |
Lines 45-50
Link Here
|
45 |
#include <signal.h> |
45 |
#include <signal.h> |
46 |
#include <errno.h> |
46 |
#include <errno.h> |
47 |
#include <stdio.h> |
47 |
#include <stdio.h> |
|
|
48 |
#include <string.h> |
49 |
#include <stdlib.h> |
48 |
|
50 |
|
49 |
#include "ring.h" |
51 |
#include "ring.h" |
50 |
#include "defines.h" |
52 |
#include "defines.h" |
Lines 155-163
Link Here
|
155 |
if (localflow) |
157 |
if (localflow) |
156 |
mode |= MODE_FLOW; |
158 |
mode |= MODE_FLOW; |
157 |
|
159 |
|
158 |
if (my_want_state_is_will(TELOPT_BINARY)) |
160 |
if ((eight & 1) || my_want_state_is_will(TELOPT_BINARY)) |
159 |
mode |= MODE_INBIN; |
161 |
mode |= MODE_INBIN; |
160 |
|
162 |
|
|
|
163 |
if (eight & 2) |
164 |
mode |= MODE_OUT8; |
161 |
if (his_want_state_is_will(TELOPT_BINARY)) |
165 |
if (his_want_state_is_will(TELOPT_BINARY)) |
162 |
mode |= MODE_OUTBIN; |
166 |
mode |= MODE_OUTBIN; |
163 |
|
167 |
|
Lines 449-458
Link Here
|
449 |
// breaks SunOS. |
453 |
// breaks SunOS. |
450 |
tmp_tc.c_iflag |= ISTRIP; |
454 |
tmp_tc.c_iflag |= ISTRIP; |
451 |
} |
455 |
} |
452 |
if (f & MODE_OUTBIN) { |
456 |
if (f & (MODE_OUTBIN|MODE_OUT8)) { |
453 |
tmp_tc.c_cflag &= ~(CSIZE|PARENB); |
457 |
tmp_tc.c_cflag &= ~(CSIZE|PARENB); |
454 |
tmp_tc.c_cflag |= CS8; |
458 |
tmp_tc.c_cflag |= CS8; |
455 |
tmp_tc.c_oflag &= ~OPOST; |
459 |
if (f & MODE_OUTBIN) |
|
|
460 |
tmp_tc.c_oflag &= ~OPOST; |
461 |
else |
462 |
tmp_tc.c_oflag |= OPOST; |
456 |
} else { |
463 |
} else { |
457 |
tmp_tc.c_cflag &= ~(CSIZE|PARENB); |
464 |
tmp_tc.c_cflag &= ~(CSIZE|PARENB); |
458 |
tmp_tc.c_cflag |= old_tc.c_cflag & (CSIZE|PARENB); |
465 |
tmp_tc.c_cflag |= old_tc.c_cflag & (CSIZE|PARENB); |
Lines 468-474
Link Here
|
468 |
|
475 |
|
469 |
#ifdef SIGINFO |
476 |
#ifdef SIGINFO |
470 |
signal(SIGINFO, ayt); |
477 |
signal(SIGINFO, ayt); |
471 |
#endif SIGINFO |
478 |
#endif /* SIGINFO */ |
472 |
|
479 |
|
473 |
#if defined(NOKERNINFO) |
480 |
#if defined(NOKERNINFO) |
474 |
tmp_tc.c_lflag |= NOKERNINFO; |
481 |
tmp_tc.c_lflag |= NOKERNINFO; |
Lines 504-510
Link Here
|
504 |
|
511 |
|
505 |
#ifdef SIGINFO |
512 |
#ifdef SIGINFO |
506 |
signal(SIGINFO, ayt_status); |
513 |
signal(SIGINFO, ayt_status); |
507 |
#endif SIGINFO |
514 |
#endif /* SIGINFO */ |
508 |
|
515 |
|
509 |
#ifdef SIGTSTP |
516 |
#ifdef SIGTSTP |
510 |
signal(SIGTSTP, SIG_DFL); |
517 |
signal(SIGTSTP, SIG_DFL); |
511 |
-- netkit-telnet-0.17.orig/telnet/utilities.cc |
518 |
++ netkit-telnet-0.17/telnet/utilities.cc |
Lines 47-52
Link Here
|
47 |
#include <sys/socket.h> |
47 |
#include <sys/socket.h> |
48 |
#include <unistd.h> |
48 |
#include <unistd.h> |
49 |
#include <ctype.h> |
49 |
#include <ctype.h> |
|
|
50 |
#include <string.h> |
51 |
#include <stdlib.h> |
50 |
|
52 |
|
51 |
#include "ring.h" |
53 |
#include "ring.h" |
52 |
#include "defines.h" |
54 |
#include "defines.h" |
53 |
-- netkit-telnet-0.17.orig/telnetd/Makefile |
55 |
++ netkit-telnet-0.17/telnetd/Makefile |
Lines 9-15
Link Here
|
9 |
# take out -DPARANOID_TTYS. |
9 |
# take out -DPARANOID_TTYS. |
10 |
|
10 |
|
11 |
CFLAGS += '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS \ |
11 |
CFLAGS += '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS \ |
12 |
-DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS |
12 |
-DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS \ |
|
|
13 |
-DLOGIN_WRAPPER=\"/usr/lib/telnetlogin\" |
13 |
# LIBS += $(LIBTERMCAP) |
14 |
# LIBS += $(LIBTERMCAP) |
14 |
|
15 |
|
15 |
OBJS = telnetd.o state.o termstat.o slc.o sys_term.o utility.o \ |
16 |
OBJS = telnetd.o state.o termstat.o slc.o sys_term.o utility.o \ |
16 |
-- netkit-telnet-0.17.orig/telnetd/authenc.c |
17 |
++ netkit-telnet-0.17/telnetd/authenc.c |
Lines 42-59
Link Here
|
42 |
return(0); |
42 |
return(0); |
43 |
} |
43 |
} |
44 |
|
44 |
|
45 |
void |
|
|
46 |
net_encrypt() |
47 |
{ |
48 |
#if defined(ENCRYPT) |
49 |
char *s = (nclearto > nbackp) ? nclearto : nbackp; |
50 |
if (s < nfrontp && encrypt_output) { |
51 |
(*encrypt_output)((unsigned char *)s, nfrontp - s); |
52 |
} |
53 |
nclearto = nfrontp; |
54 |
#endif |
55 |
} |
56 |
|
57 |
int |
45 |
int |
58 |
telnet_spin() |
46 |
telnet_spin() |
59 |
{ |
47 |
{ |
60 |
-- netkit-telnet-0.17.orig/telnetd/defs.h |
48 |
++ netkit-telnet-0.17/telnetd/defs.h |
Lines 55-64
Link Here
|
55 |
#include <fcntl.h> |
55 |
#include <fcntl.h> |
56 |
#include <sys/file.h> |
56 |
#include <sys/file.h> |
57 |
#include <sys/stat.h> |
57 |
#include <sys/stat.h> |
58 |
#include <sys/time.h> |
58 |
#include <time.h> |
59 |
#include <sys/ioctl.h> |
59 |
#include <sys/ioctl.h> |
60 |
#include <netinet/in.h> |
60 |
#include <netinet/in.h> |
61 |
#include <arpa/telnet.h> |
61 |
#include <arpa/telnet.h> |
|
|
62 |
#include <sys/uio.h> |
62 |
#include <stdio.h> |
63 |
#include <stdio.h> |
63 |
#include <stdlib.h> |
64 |
#include <stdlib.h> |
64 |
#include <signal.h> |
65 |
#include <signal.h> |
65 |
-- netkit-telnet-0.17.orig/telnetd/ext.h |
66 |
++ netkit-telnet-0.17/telnetd/ext.h |
Lines 81-102
Link Here
|
81 |
*/ |
81 |
*/ |
82 |
extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; |
82 |
extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; |
83 |
extern char netibuf[BUFSIZ], *netip; |
83 |
extern char netibuf[BUFSIZ], *netip; |
84 |
extern char netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp; |
|
|
85 |
extern char *neturg; /* one past last byte of urgent data */ |
86 |
extern int pcc, ncc; |
84 |
extern int pcc, ncc; |
|
|
85 |
extern FILE *netfile; |
87 |
|
86 |
|
88 |
/* printf into netobuf */ |
87 |
/* printf into netobuf */ |
89 |
void netoprintf(const char *fmt, ...) __attribute((format (printf, 1, 2))); |
88 |
#define netoprintf(fmt, ...) fprintf(netfile, fmt, ## __VA_ARGS__) |
90 |
|
89 |
|
91 |
extern int pty, net; |
90 |
extern int pty, net; |
92 |
extern char *line; |
91 |
extern const char *line; |
93 |
extern int SYNCHing; /* we are in TELNET SYNCH mode */ |
92 |
extern int SYNCHing; /* we are in TELNET SYNCH mode */ |
94 |
|
93 |
|
95 |
void _termstat(void); |
94 |
void _termstat(void); |
96 |
void add_slc(int, int, int); |
95 |
void add_slc(int, int, int); |
97 |
void check_slc(void); |
96 |
void check_slc(void); |
98 |
void change_slc(int, int, int); |
97 |
void change_slc(int, int, int); |
99 |
void cleanup(int); |
98 |
void cleanup(int) __attribute__ ((noreturn)); |
100 |
void clientstat(int, int, int); |
99 |
void clientstat(int, int, int); |
101 |
void copy_termbuf(char *, int); |
100 |
void copy_termbuf(char *, int); |
102 |
void deferslc(void); |
101 |
void deferslc(void); |
Lines 106-113
Link Here
|
106 |
void dooption(int); |
105 |
void dooption(int); |
107 |
void dontoption(int); |
106 |
void dontoption(int); |
108 |
void edithost(const char *, const char *); |
107 |
void edithost(const char *, const char *); |
109 |
void fatal(int, const char *); |
108 |
void fatal(int, const char *) __attribute__ ((noreturn)); |
110 |
void fatalperror(int, const char *); |
109 |
void fatalperror(int, const char *) __attribute__ ((noreturn)); |
111 |
void get_slc_defaults(void); |
110 |
void get_slc_defaults(void); |
112 |
void init_env(void); |
111 |
void init_env(void); |
113 |
void init_termbuf(void); |
112 |
void init_termbuf(void); |
Lines 115-120
Link Here
|
115 |
void localstat(void); |
114 |
void localstat(void); |
116 |
void netclear(void); |
115 |
void netclear(void); |
117 |
void netflush(void); |
116 |
void netflush(void); |
|
|
117 |
size_t netbuflen(int); |
118 |
void sendurg(const char *, size_t); |
118 |
|
119 |
|
119 |
#ifdef DIAGNOSTICS |
120 |
#ifdef DIAGNOSTICS |
120 |
void printoption(const char *, int); |
121 |
void printoption(const char *, int); |
Lines 182-191
Link Here
|
182 |
void tty_tspeed(int); |
183 |
void tty_tspeed(int); |
183 |
void willoption(int); |
184 |
void willoption(int); |
184 |
void wontoption(int); |
185 |
void wontoption(int); |
185 |
void writenet(unsigned char *, int); |
186 |
#define writenet(b, l) fwrite(b, 1, l, netfile) |
|
|
187 |
void netopen(void); |
186 |
|
188 |
|
187 |
#if defined(ENCRYPT) |
189 |
#if defined(ENCRYPT) |
188 |
extern void (*encrypt_output)(unsigned char *, int); |
190 |
extern void (*encrypt_output)(const unsigned char *, int); |
189 |
extern int (*decrypt_input)(int); |
191 |
extern int (*decrypt_input)(int); |
190 |
extern char *nclearto; |
192 |
extern char *nclearto; |
191 |
#endif |
193 |
#endif |
192 |
-- netkit-telnet-0.17.orig/telnetd/global.c |
194 |
++ netkit-telnet-0.17/telnetd/global.c |
Lines 87-97
Link Here
|
87 |
|
87 |
|
88 |
char netibuf[BUFSIZ], *netip; |
88 |
char netibuf[BUFSIZ], *netip; |
89 |
|
89 |
|
90 |
char netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp; |
|
|
91 |
char *neturg; /* one past last bye of urgent data */ |
92 |
|
93 |
int pcc, ncc; |
90 |
int pcc, ncc; |
94 |
|
91 |
|
|
|
92 |
FILE *netfile; |
93 |
|
95 |
int pty, net; |
94 |
int pty, net; |
96 |
int SYNCHing; /* we are in TELNET SYNCH mode */ |
95 |
int SYNCHing; /* we are in TELNET SYNCH mode */ |
97 |
|
96 |
|
98 |
-- netkit-telnet-0.17.orig/telnetd/issue.net.5 |
97 |
++ netkit-telnet-0.17/telnetd/issue.net.5 |
Lines 40-43
Link Here
|
40 |
.Sh FILES |
40 |
.Sh FILES |
41 |
.Pa /etc/issue.net |
41 |
.Pa /etc/issue.net |
42 |
.Sh "SEE ALSO" |
42 |
.Sh "SEE ALSO" |
43 |
.Xr telnetd 8 |
43 |
.Xr in.telnetd 8 |
44 |
-- netkit-telnet-0.17.orig/telnetd/setproctitle.c |
44 |
++ netkit-telnet-0.17/telnetd/setproctitle.c |
Lines 139-145
Link Here
|
139 |
(void) strcpy(Argv[0], buf); |
139 |
(void) strcpy(Argv[0], buf); |
140 |
p = &Argv[0][i]; |
140 |
p = &Argv[0][i]; |
141 |
while (p < LastArgv) |
141 |
while (p < LastArgv) |
142 |
*p++ = ' '; |
142 |
*p++ = '\0'; |
143 |
Argv[1] = NULL; |
143 |
Argv[1] = NULL; |
144 |
} |
144 |
} |
145 |
|
145 |
|
146 |
-- netkit-telnet-0.17.orig/telnetd/state.c |
146 |
++ netkit-telnet-0.17/telnetd/state.c |
Lines 179-184
Link Here
|
179 |
*/ |
179 |
*/ |
180 |
case AO: |
180 |
case AO: |
181 |
{ |
181 |
{ |
|
|
182 |
static const char msg[] = { IAC, DM }; |
182 |
DIAG(TD_OPTIONS, printoption("td: recv IAC", c)); |
183 |
DIAG(TD_OPTIONS, printoption("td: recv IAC", c)); |
183 |
ptyflush(); /* half-hearted */ |
184 |
ptyflush(); /* half-hearted */ |
184 |
init_termbuf(); |
185 |
init_termbuf(); |
Lines 191-199
Link Here
|
191 |
} |
192 |
} |
192 |
|
193 |
|
193 |
netclear(); /* clear buffer back */ |
194 |
netclear(); /* clear buffer back */ |
194 |
*nfrontp++ = (char)IAC; |
195 |
sendurg(msg, sizeof(msg)); |
195 |
*nfrontp++ = (char)DM; |
|
|
196 |
neturg = nfrontp-1; /* off by one XXX */ |
197 |
DIAG(TD_OPTIONS, printoption("td: send IAC", DM)); |
196 |
DIAG(TD_OPTIONS, printoption("td: send IAC", DM)); |
198 |
break; |
197 |
break; |
199 |
} |
198 |
} |
200 |
-- netkit-telnet-0.17.orig/telnetd/sys_term.c |
199 |
++ netkit-telnet-0.17/telnetd/sys_term.c |
Lines 41-48
Link Here
|
41 |
|
41 |
|
42 |
#include "telnetd.h" |
42 |
#include "telnetd.h" |
43 |
#include "pathnames.h" |
43 |
#include "pathnames.h" |
44 |
#include "logout.h" |
|
|
45 |
#include "logwtmp.h" |
46 |
|
44 |
|
47 |
#if defined(__GLIBC__) && (__GLIBC__ >= 2) |
45 |
#if defined(__GLIBC__) && (__GLIBC__ >= 2) |
48 |
/* mmm, nonstandard */ |
46 |
/* mmm, nonstandard */ |
Lines 206-222
Link Here
|
206 |
* |
204 |
* |
207 |
* Returns the file descriptor of the opened pty. |
205 |
* Returns the file descriptor of the opened pty. |
208 |
*/ |
206 |
*/ |
209 |
static char linedata[PATH_MAX]; |
207 |
const char *line; |
210 |
char *line = linedata; |
|
|
211 |
|
208 |
|
212 |
static int ptyslavefd=-1; |
209 |
static int ptyslavefd=-1; |
213 |
|
210 |
|
214 |
int getpty(void) { |
211 |
int getpty(void) { |
215 |
int masterfd; |
212 |
int masterfd; |
216 |
|
213 |
|
217 |
if (openpty(&masterfd, &ptyslavefd, line, NULL, NULL)) { |
214 |
if (openpty(&masterfd, &ptyslavefd, NULL, NULL, NULL)) { |
218 |
return -1; |
215 |
return -1; |
219 |
} |
216 |
} |
|
|
217 |
line = ttyname(ptyslavefd); |
220 |
return masterfd; |
218 |
return masterfd; |
221 |
} |
219 |
} |
222 |
|
220 |
|
Lines 681-687
Link Here
|
681 |
memcpy(&argvfoo, &avs.argv, sizeof(argvfoo)); |
679 |
memcpy(&argvfoo, &avs.argv, sizeof(argvfoo)); |
682 |
execv(loginprg, argvfoo); |
680 |
execv(loginprg, argvfoo); |
683 |
|
681 |
|
|
|
682 |
openlog("telnetd", LOG_PID | LOG_ODELAY, LOG_DAEMON); |
684 |
syslog(LOG_ERR, "%s: %m\n", loginprg); |
683 |
syslog(LOG_ERR, "%s: %m\n", loginprg); |
|
|
684 |
closelog(); |
685 |
fatalperror(net, loginprg); |
685 |
fatalperror(net, loginprg); |
686 |
} |
686 |
} |
687 |
|
687 |
|
Lines 720-744
Link Here
|
720 |
* clean up anything that needs to be cleaned up. |
720 |
* clean up anything that needs to be cleaned up. |
721 |
*/ |
721 |
*/ |
722 |
void cleanup(int sig) { |
722 |
void cleanup(int sig) { |
723 |
char *p; |
723 |
const char *p; |
724 |
(void)sig; |
724 |
(void)sig; |
725 |
|
725 |
|
726 |
p = line + sizeof("/dev/") - 1; |
726 |
p = line + sizeof("/dev/") - 1; |
727 |
if (logout(p)) logwtmp(p, "", ""); |
727 |
if (logout(p)) logwtmp(p, "", ""); |
728 |
#ifdef PARANOID_TTYS |
|
|
729 |
/* |
730 |
* dholland 16-Aug-96 chmod the tty when not in use |
731 |
* This will make it harder to attach unwanted stuff to it |
732 |
* (which is a security risk) but will break some programs. |
733 |
*/ |
734 |
chmod(line, 0600); |
735 |
#else |
736 |
chmod(line, 0666); |
737 |
#endif |
738 |
chown(line, 0, 0); |
739 |
*p = 'p'; |
740 |
chmod(line, 0666); |
741 |
chown(line, 0, 0); |
742 |
shutdown(net, 2); |
728 |
shutdown(net, 2); |
743 |
exit(0); |
729 |
exit(0); |
744 |
} |
730 |
} |
745 |
-- netkit-telnet-0.17.orig/telnetd/telnetd.8 |
731 |
++ netkit-telnet-0.17/telnetd/telnetd.8 |
Lines 161-167
Link Here
|
161 |
.It Fl L Ar loginprg |
161 |
.It Fl L Ar loginprg |
162 |
This option may be used to specify a different login program. |
162 |
This option may be used to specify a different login program. |
163 |
By default, |
163 |
By default, |
164 |
.Pa /bin/login |
164 |
.Pa /usr/lib/telnetlogin |
165 |
is used. |
165 |
is used. |
166 |
.It Fl n |
166 |
.It Fl n |
167 |
Disable |
167 |
Disable |
Lines 406-411
Link Here
|
406 |
indicates a willingness to decrypt |
406 |
indicates a willingness to decrypt |
407 |
the data stream. |
407 |
the data stream. |
408 |
.Xr issue.net 5 ) . |
408 |
.Xr issue.net 5 ) . |
|
|
409 |
.El |
409 |
.Sh FILES |
410 |
.Sh FILES |
410 |
.Pa /etc/services , |
411 |
.Pa /etc/services , |
411 |
.Pa /etc/issue.net |
412 |
.Pa /etc/issue.net |
Lines 458-463
Link Here
|
458 |
Telnet Environment Option Interoperability Issues |
459 |
Telnet Environment Option Interoperability Issues |
459 |
.It Cm RFC-1572 |
460 |
.It Cm RFC-1572 |
460 |
Telnet Environment Option |
461 |
Telnet Environment Option |
|
|
462 |
.El |
461 |
.Sh BUGS |
463 |
.Sh BUGS |
462 |
Some |
464 |
Some |
463 |
.Tn TELNET |
465 |
.Tn TELNET |
464 |
-- netkit-telnet-0.17.orig/telnetd/telnetd.c |
466 |
++ netkit-telnet-0.17/telnetd/telnetd.c |
Lines 43-54
Link Here
|
43 |
|
43 |
|
44 |
#include "../version.h" |
44 |
#include "../version.h" |
45 |
|
45 |
|
|
|
46 |
#include <sys/socket.h> |
46 |
#include <netdb.h> |
47 |
#include <netdb.h> |
47 |
#include <termcap.h> |
48 |
#include <termcap.h> |
48 |
#include <netinet/in.h> |
49 |
#include <netinet/in.h> |
49 |
/* #include <netinet/ip.h> */ /* Don't think this is used at all here */ |
50 |
/* #include <netinet/ip.h> */ /* Don't think this is used at all here */ |
50 |
#include <arpa/inet.h> |
51 |
#include <arpa/inet.h> |
51 |
#include <assert.h> |
52 |
#include <assert.h> |
|
|
53 |
#include <poll.h> |
54 |
#include <fcntl.h> |
55 |
#include <unistd.h> |
52 |
#include "telnetd.h" |
56 |
#include "telnetd.h" |
53 |
#include "pathnames.h" |
57 |
#include "pathnames.h" |
54 |
#include "setproctitle.h" |
58 |
#include "setproctitle.h" |
Lines 68-74
Link Here
|
68 |
#define HAS_IPPROTO_IP |
72 |
#define HAS_IPPROTO_IP |
69 |
#endif |
73 |
#endif |
70 |
|
74 |
|
71 |
static void doit(struct sockaddr_in *who); |
75 |
static void doit(struct sockaddr *who, socklen_t who_len); |
72 |
static int terminaltypeok(const char *s); |
76 |
static int terminaltypeok(const char *s); |
73 |
|
77 |
|
74 |
/* |
78 |
/* |
Lines 82-96
Link Here
|
82 |
|
86 |
|
83 |
int debug = 0; |
87 |
int debug = 0; |
84 |
int keepalive = 1; |
88 |
int keepalive = 1; |
|
|
89 |
#ifdef LOGIN_WRAPPER |
90 |
char *loginprg = LOGIN_WRAPPER; |
91 |
#else |
85 |
char *loginprg = _PATH_LOGIN; |
92 |
char *loginprg = _PATH_LOGIN; |
86 |
char *progname; |
93 |
#endif |
87 |
|
94 |
|
88 |
extern void usage(void); |
95 |
extern void usage(void); |
89 |
|
96 |
|
|
|
97 |
static void |
98 |
wait_for_connection(const char *service) |
99 |
{ |
100 |
struct addrinfo hints; |
101 |
struct addrinfo *res, *addr; |
102 |
struct pollfd *fds, *fdp; |
103 |
int nfds; |
104 |
int i; |
105 |
int error; |
106 |
int on = 1; |
107 |
|
108 |
memset(&hints, 0, sizeof(hints)); |
109 |
hints.ai_family = PF_UNSPEC; |
110 |
hints.ai_flags = AI_PASSIVE; |
111 |
hints.ai_socktype = SOCK_STREAM; |
112 |
error = getaddrinfo(NULL, service, &hints, &res); |
113 |
if (error) { |
114 |
char *p; |
115 |
error = asprintf(&p, "getaddrinfo: %s\n", gai_strerror(error)); |
116 |
fatal(2, error >= 0 ? p : ""); |
117 |
} |
118 |
|
119 |
for (addr = res, nfds = 0; addr; addr = addr->ai_next, nfds++) |
120 |
; |
121 |
fds = malloc(sizeof(struct pollfd) * nfds); |
122 |
for (addr = res, fdp = fds; addr; addr = addr->ai_next, fdp++) { |
123 |
int s; |
124 |
|
125 |
if (addr->ai_family == AF_LOCAL) { |
126 |
nextaddr: |
127 |
fdp--; |
128 |
nfds--; |
129 |
continue; |
130 |
} |
131 |
|
132 |
s = socket(addr->ai_family, SOCK_STREAM, 0); |
133 |
if (s < 0) { |
134 |
if (errno == EAFNOSUPPORT || errno == EINVAL) { |
135 |
goto nextaddr; |
136 |
} |
137 |
fatalperror(2, "socket"); |
138 |
} |
139 |
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) { |
140 |
fatalperror(2, "setsockopt"); |
141 |
} |
142 |
if (bind(s, addr->ai_addr, addr->ai_addrlen)) { |
143 |
#ifdef linux |
144 |
if (fdp != fds && errno == EADDRINUSE) { |
145 |
close(s); |
146 |
goto nextaddr; |
147 |
} |
148 |
#endif |
149 |
fatalperror(2, "bind"); |
150 |
} |
151 |
if (listen(s, 1)) { |
152 |
fatalperror(2, "listen"); |
153 |
} |
154 |
if (fcntl(s, F_SETFL, O_NONBLOCK)) { |
155 |
fatalperror(2, "fcntl"); |
156 |
} |
157 |
|
158 |
fdp->fd = s; |
159 |
fdp->events = POLLIN; |
160 |
} |
161 |
|
162 |
freeaddrinfo(res); |
163 |
|
164 |
while (1) { |
165 |
if (poll(fds, nfds, -1) < 0) { |
166 |
if (errno == EINTR) { |
167 |
continue; |
168 |
} |
169 |
fatalperror(2, "poll"); |
170 |
} |
171 |
|
172 |
for (i = 0, fdp = fds; i < nfds; i++, fdp++) { |
173 |
int fd; |
174 |
|
175 |
if (!(fdp->revents & POLLIN)) { |
176 |
continue; |
177 |
} |
178 |
|
179 |
fd = accept(fdp->fd, 0, 0); |
180 |
if (fd >= 0) { |
181 |
dup2(fd, 0); |
182 |
close(fd); |
183 |
goto out; |
184 |
} |
185 |
if (errno != EAGAIN) { |
186 |
fatalperror(2, "accept"); |
187 |
} |
188 |
} |
189 |
} |
190 |
|
191 |
out: |
192 |
for (i = 0, fdp = fds; i < nfds; i++, fdp++) { |
193 |
close(fdp->fd); |
194 |
} |
195 |
free(fds); |
196 |
} |
197 |
|
90 |
int |
198 |
int |
91 |
main(int argc, char *argv[], char *env[]) |
199 |
main(int argc, char *argv[], char *env[]) |
92 |
{ |
200 |
{ |
93 |
struct sockaddr_in from; |
201 |
struct sockaddr_storage from; |
94 |
int on = 1; |
202 |
int on = 1; |
95 |
socklen_t fromlen; |
203 |
socklen_t fromlen; |
96 |
register int ch; |
204 |
register int ch; |
Lines 103-114
Link Here
|
103 |
|
211 |
|
104 |
pfrontp = pbackp = ptyobuf; |
212 |
pfrontp = pbackp = ptyobuf; |
105 |
netip = netibuf; |
213 |
netip = netibuf; |
106 |
nfrontp = nbackp = netobuf; |
|
|
107 |
#if defined(ENCRYPT) |
108 |
nclearto = 0; |
109 |
#endif |
110 |
|
111 |
progname = *argv; |
112 |
|
214 |
|
113 |
while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:")) != EOF) { |
215 |
while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:")) != EOF) { |
114 |
switch(ch) { |
216 |
switch(ch) { |
Lines 249-322
Link Here
|
249 |
argv += optind; |
351 |
argv += optind; |
250 |
|
352 |
|
251 |
if (debug) { |
353 |
if (debug) { |
252 |
int s, ns; |
354 |
if (argc > 1) { |
253 |
socklen_t foo; |
355 |
usage(); |
254 |
struct servent *sp; |
356 |
/* NOTREACHED */ |
255 |
struct sockaddr_in sn; |
|
|
256 |
|
257 |
memset(&sn, 0, sizeof(sn)); |
258 |
sn.sin_family = AF_INET; |
259 |
|
260 |
if (argc > 1) { |
261 |
usage(); |
262 |
/* NOTREACHED */ |
263 |
} else if (argc == 1) { |
264 |
if ((sp = getservbyname(*argv, "tcp"))!=NULL) { |
265 |
sn.sin_port = sp->s_port; |
266 |
} |
267 |
else { |
268 |
int pt = atoi(*argv); |
269 |
if (pt <= 0) { |
270 |
fprintf(stderr, "telnetd: %s: bad port number\n", |
271 |
*argv); |
272 |
usage(); |
273 |
/* NOTREACHED */ |
274 |
} |
275 |
sn.sin_port = htons(pt); |
276 |
} |
277 |
} else { |
278 |
sp = getservbyname("telnet", "tcp"); |
279 |
if (sp == 0) { |
280 |
fprintf(stderr, "telnetd: tcp/telnet: unknown service\n"); |
281 |
exit(1); |
282 |
} |
357 |
} |
283 |
sn.sin_port = sp->s_port; |
|
|
284 |
} |
285 |
|
358 |
|
286 |
s = socket(AF_INET, SOCK_STREAM, 0); |
359 |
wait_for_connection((argc == 1) ? *argv : "telnet"); |
287 |
if (s < 0) { |
|
|
288 |
perror("telnetd: socket");; |
289 |
exit(1); |
290 |
} |
291 |
(void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
292 |
if (bind(s, (struct sockaddr *)&sn, sizeof(sn)) < 0) { |
293 |
perror("bind"); |
294 |
exit(1); |
295 |
} |
296 |
if (listen(s, 1) < 0) { |
297 |
perror("listen"); |
298 |
exit(1); |
299 |
} |
300 |
foo = sizeof(sn); |
301 |
ns = accept(s, (struct sockaddr *)&sn, &foo); |
302 |
if (ns < 0) { |
303 |
perror("accept"); |
304 |
exit(1); |
305 |
} |
306 |
(void) dup2(ns, 0); |
307 |
(void) close(ns); |
308 |
(void) close(s); |
309 |
} else if (argc > 0) { |
310 |
usage(); |
311 |
/* NOT REACHED */ |
312 |
} |
360 |
} |
313 |
|
361 |
|
314 |
openlog("telnetd", LOG_PID | LOG_ODELAY, LOG_DAEMON); |
362 |
openlog("telnetd", LOG_PID | LOG_ODELAY, LOG_DAEMON); |
315 |
fromlen = sizeof (from); |
363 |
fromlen = sizeof (from); |
316 |
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) { |
364 |
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) { |
317 |
fprintf(stderr, "%s: ", progname); |
365 |
fatalperror(2, "getpeername"); |
318 |
perror("getpeername"); |
|
|
319 |
_exit(1); |
320 |
} |
366 |
} |
321 |
if (keepalive && |
367 |
if (keepalive && |
322 |
setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) { |
368 |
setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) { |
Lines 339-345
Link Here
|
339 |
} |
385 |
} |
340 |
#endif /* defined(HAS_IPPROTO_IP) && defined(IP_TOS) */ |
386 |
#endif /* defined(HAS_IPPROTO_IP) && defined(IP_TOS) */ |
341 |
net = 0; |
387 |
net = 0; |
342 |
doit(&from); |
388 |
netopen(); |
|
|
389 |
doit((struct sockaddr *)&from, fromlen); |
343 |
/* NOTREACHED */ |
390 |
/* NOTREACHED */ |
344 |
return 0; |
391 |
return 0; |
345 |
} /* end of main */ |
392 |
} /* end of main */ |
Lines 354-360
Link Here
|
354 |
#ifdef BFTPDAEMON |
401 |
#ifdef BFTPDAEMON |
355 |
fprintf(stderr, " [-B]"); |
402 |
fprintf(stderr, " [-B]"); |
356 |
#endif |
403 |
#endif |
357 |
fprintf(stderr, " [-debug]"); |
404 |
fprintf(stderr, " [-debug port]"); |
358 |
#ifdef DIAGNOSTICS |
405 |
#ifdef DIAGNOSTICS |
359 |
fprintf(stderr, " [-D (options|report|exercise|netdata|ptydata)]\n\t"); |
406 |
fprintf(stderr, " [-D (options|report|exercise|netdata|ptydata)]\n\t"); |
360 |
#endif |
407 |
#endif |
Lines 373-379
Link Here
|
373 |
#ifdef AUTHENTICATE |
420 |
#ifdef AUTHENTICATE |
374 |
fprintf(stderr, " [-X auth-type]"); |
421 |
fprintf(stderr, " [-X auth-type]"); |
375 |
#endif |
422 |
#endif |
376 |
fprintf(stderr, " [port]\n"); |
423 |
fprintf(stderr, "\n"); |
377 |
exit(1); |
424 |
exit(1); |
378 |
} |
425 |
} |
379 |
|
426 |
|
Lines 608-661
Link Here
|
608 |
* Get a pty, scan input lines. |
655 |
* Get a pty, scan input lines. |
609 |
*/ |
656 |
*/ |
610 |
static void |
657 |
static void |
611 |
doit(struct sockaddr_in *who) |
658 |
doit(struct sockaddr *who, socklen_t who_len) |
612 |
{ |
659 |
{ |
613 |
const char *host; |
660 |
const char *host; |
614 |
struct hostent *hp; |
|
|
615 |
int level; |
661 |
int level; |
616 |
char user_name[256]; |
662 |
char user_name[256]; |
|
|
663 |
int i; |
664 |
struct addrinfo hints, *res; |
617 |
|
665 |
|
618 |
/* |
666 |
/* |
619 |
* Find an available pty to use. |
667 |
* Find an available pty to use. |
620 |
*/ |
668 |
*/ |
621 |
pty = getpty(); |
669 |
pty = getpty(); |
622 |
if (pty < 0) |
670 |
if (pty < 0) |
623 |
fatal(net, "All network ports in use"); |
671 |
fatalperror(net, "getpty"); |
624 |
|
672 |
|
625 |
/* get name of connected client */ |
673 |
/* get name of connected client */ |
626 |
hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr), |
674 |
if (getnameinfo(who, who_len, remote_host_name, |
627 |
who->sin_family); |
675 |
sizeof(remote_host_name), 0, 0, 0)) { |
628 |
if (hp) |
676 |
syslog(LOG_ERR, "doit: getnameinfo: %m"); |
629 |
host = hp->h_name; |
677 |
*remote_host_name = 0; |
630 |
else |
678 |
} |
631 |
host = inet_ntoa(who->sin_addr); |
679 |
|
632 |
|
680 |
/* Disallow funnies. */ |
633 |
/* |
681 |
for (i=0; remote_host_name[i]; i++) { |
634 |
* We must make a copy because Kerberos is probably going |
682 |
if (remote_host_name[i]<=32 || remote_host_name[i]>126) |
635 |
* to also do a gethost* and overwrite the static data... |
683 |
remote_host_name[i] = '?'; |
636 |
*/ |
|
|
637 |
{ |
638 |
int i; |
639 |
strncpy(remote_host_name, host, sizeof(remote_host_name)-1); |
640 |
remote_host_name[sizeof(remote_host_name)-1] = 0; |
641 |
|
642 |
/* Disallow funnies. */ |
643 |
for (i=0; remote_host_name[i]; i++) { |
644 |
if (remote_host_name[i]<=32 || remote_host_name[i]>126) |
645 |
remote_host_name[i] = '?'; |
646 |
} |
647 |
} |
684 |
} |
648 |
host = remote_host_name; |
685 |
host = remote_host_name; |
649 |
|
686 |
|
650 |
/* Get local host name */ |
687 |
/* Get local host name */ |
651 |
{ |
688 |
gethostname(host_name, sizeof(host_name)); |
652 |
struct hostent *h; |
689 |
memset(&hints, 0, sizeof(hints)); |
653 |
gethostname(host_name, sizeof(host_name)); |
690 |
hints.ai_family = PF_UNSPEC; |
654 |
h = gethostbyname(host_name); |
691 |
hints.ai_flags = AI_CANONNAME; |
655 |
if (h) { |
692 |
if ((i = getaddrinfo(host_name, 0, &hints, &res))) |
656 |
strncpy(host_name, h->h_name, sizeof(host_name)); |
693 |
syslog(LOG_WARNING, "doit: getaddrinfo: %s", gai_strerror(i)); |
657 |
host_name[sizeof(host_name)-1] = 0; |
694 |
else { |
658 |
} |
695 |
strncpy(host_name, res->ai_canonname, sizeof(host_name)-1); |
|
|
696 |
host_name[sizeof(host_name)-1] = 0; |
659 |
} |
697 |
} |
660 |
|
698 |
|
661 |
#if defined(AUTHENTICATE) || defined(ENCRYPT) |
699 |
#if defined(AUTHENTICATE) || defined(ENCRYPT) |
Lines 892-898
Link Here
|
892 |
* Never look for input if there's still |
930 |
* Never look for input if there's still |
893 |
* stuff in the corresponding output buffer |
931 |
* stuff in the corresponding output buffer |
894 |
*/ |
932 |
*/ |
895 |
if (nfrontp - nbackp || pcc > 0) { |
933 |
if (netbuflen(1) || pcc > 0) { |
896 |
FD_SET(f, &obits); |
934 |
FD_SET(f, &obits); |
897 |
if (f >= hifd) hifd = f+1; |
935 |
if (f >= hifd) hifd = f+1; |
898 |
} |
936 |
} |
Lines 1033-1038
Link Here
|
1033 |
} |
1071 |
} |
1034 |
#endif /* LINEMODE */ |
1072 |
#endif /* LINEMODE */ |
1035 |
if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) { |
1073 |
if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) { |
|
|
1074 |
static const char msg[] = { IAC, DM }; |
1036 |
netclear(); /* clear buffer back */ |
1075 |
netclear(); /* clear buffer back */ |
1037 |
#ifndef NO_URGENT |
1076 |
#ifndef NO_URGENT |
1038 |
/* |
1077 |
/* |
Lines 1041-1048
Link Here
|
1041 |
* royally if we send them urgent |
1080 |
* royally if we send them urgent |
1042 |
* mode data. |
1081 |
* mode data. |
1043 |
*/ |
1082 |
*/ |
1044 |
netoprintf("%c%c", IAC, DM); |
1083 |
sendurg(msg, sizeof(msg)); |
1045 |
neturg = nfrontp-1; /* off by one XXX */ |
|
|
1046 |
#endif |
1084 |
#endif |
1047 |
} |
1085 |
} |
1048 |
if (his_state_is_will(TELOPT_LFLOW) && |
1086 |
if (his_state_is_will(TELOPT_LFLOW) && |
Lines 1058-1080
Link Here
|
1058 |
} |
1096 |
} |
1059 |
} |
1097 |
} |
1060 |
|
1098 |
|
1061 |
while (pcc > 0) { |
1099 |
while (pcc > 0 && !netbuflen(0)) { |
1062 |
if ((&netobuf[BUFSIZ] - nfrontp) < 2) |
|
|
1063 |
break; |
1064 |
c = *ptyip++ & 0377, pcc--; |
1100 |
c = *ptyip++ & 0377, pcc--; |
1065 |
if (c == IAC) |
1101 |
if (c == IAC) |
1066 |
*nfrontp++ = c; |
1102 |
putc(c, netfile); |
1067 |
*nfrontp++ = c; |
1103 |
putc(c, netfile); |
1068 |
if ((c == '\r' ) && (my_state_is_wont(TELOPT_BINARY))) { |
1104 |
if ((c == '\r' ) && (my_state_is_wont(TELOPT_BINARY))) { |
1069 |
if (pcc > 0 && ((*ptyip & 0377) == '\n')) { |
1105 |
if (pcc > 0 && ((*ptyip & 0377) == '\n')) { |
1070 |
*nfrontp++ = *ptyip++ & 0377; |
1106 |
putc(*ptyip++ & 0377, netfile); |
1071 |
pcc--; |
1107 |
pcc--; |
1072 |
} |
1108 |
} |
1073 |
else *nfrontp++ = '\0'; |
1109 |
else putc('\0', netfile); |
1074 |
} |
1110 |
} |
1075 |
} |
1111 |
} |
1076 |
|
1112 |
|
1077 |
if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0) |
1113 |
if (FD_ISSET(f, &obits)) |
1078 |
netflush(); |
1114 |
netflush(); |
1079 |
if (ncc > 0) |
1115 |
if (ncc > 0) |
1080 |
telrcv(); |
1116 |
telrcv(); |
1081 |
-- netkit-telnet-0.17.orig/telnetd/utility.c |
1117 |
++ netkit-telnet-0.17/telnetd/utility.c |
Lines 41-46
Link Here
|
41 |
|
41 |
|
42 |
#include <stdarg.h> |
42 |
#include <stdarg.h> |
43 |
#include <sys/utsname.h> |
43 |
#include <sys/utsname.h> |
|
|
44 |
#include <sys/time.h> |
44 |
|
45 |
|
45 |
#ifdef AUTHENTICATE |
46 |
#ifdef AUTHENTICATE |
46 |
#include <libtelnet/auth.h> |
47 |
#include <libtelnet/auth.h> |
Lines 48-81
Link Here
|
48 |
|
49 |
|
49 |
#include "telnetd.h" |
50 |
#include "telnetd.h" |
50 |
|
51 |
|
51 |
/* |
52 |
struct buflist { |
52 |
* utility functions performing io related tasks |
53 |
struct buflist *next; |
53 |
*/ |
54 |
char *buf; |
54 |
|
55 |
size_t len; |
55 |
void |
56 |
}; |
56 |
netoprintf(const char *fmt, ...) |
57 |
|
57 |
{ |
58 |
static struct buflist head = { next: &head, buf: 0, len: 0 }; |
58 |
int len, maxsize; |
59 |
static struct buflist *tail = &head; |
59 |
va_list ap; |
60 |
static size_t skip; |
60 |
int done=0; |
61 |
static int trailing; |
61 |
|
62 |
static size_t listlen; |
62 |
while (!done) { |
63 |
static int doclear; |
63 |
maxsize = sizeof(netobuf) - (nfrontp - netobuf); |
64 |
static struct buflist *urg; |
64 |
|
|
|
65 |
va_start(ap, fmt); |
66 |
len = vsnprintf(nfrontp, maxsize, fmt, ap); |
67 |
va_end(ap); |
68 |
|
69 |
if (len<0 || len==maxsize) { |
70 |
/* didn't fit */ |
71 |
netflush(); |
72 |
} |
73 |
else { |
74 |
done = 1; |
75 |
} |
76 |
} |
77 |
nfrontp += len; |
78 |
} |
79 |
|
65 |
|
80 |
/* |
66 |
/* |
81 |
* ttloop |
67 |
* ttloop |
Lines 92-100
Link Here
|
92 |
|
78 |
|
93 |
DIAG(TD_REPORT, netoprintf("td: ttloop\r\n");); |
79 |
DIAG(TD_REPORT, netoprintf("td: ttloop\r\n");); |
94 |
|
80 |
|
95 |
if (nfrontp-nbackp) { |
81 |
netflush(); |
96 |
netflush(); |
|
|
97 |
} |
98 |
ncc = read(net, netibuf, sizeof(netibuf)); |
82 |
ncc = read(net, netibuf, sizeof(netibuf)); |
99 |
if (ncc < 0) { |
83 |
if (ncc < 0) { |
100 |
syslog(LOG_INFO, "ttloop: read: %m\n"); |
84 |
syslog(LOG_INFO, "ttloop: read: %m\n"); |
Lines 168-200
Link Here
|
168 |
* character. |
152 |
* character. |
169 |
*/ |
153 |
*/ |
170 |
static |
154 |
static |
171 |
char * |
155 |
const char * |
172 |
nextitem(char *current) |
156 |
nextitem( |
173 |
{ |
157 |
const unsigned char *current, const unsigned char *end, |
174 |
if ((*current&0xff) != IAC) { |
158 |
const unsigned char *next, const unsigned char *nextend |
175 |
return current+1; |
159 |
) { |
176 |
} |
160 |
if (*current++ != IAC) { |
177 |
switch (*(current+1)&0xff) { |
161 |
while (current < end && *current++ != IAC) |
178 |
case DO: |
162 |
; |
179 |
case DONT: |
163 |
goto out; |
180 |
case WILL: |
164 |
} |
181 |
case WONT: |
165 |
|
182 |
return current+3; |
166 |
if (current >= end) { |
183 |
case SB: /* loop forever looking for the SE */ |
167 |
current = next; |
184 |
{ |
168 |
if (!current) { |
185 |
register char *look = current+2; |
169 |
return 0; |
186 |
|
|
|
187 |
for (;;) { |
188 |
if ((*look++&0xff) == IAC) { |
189 |
if ((*look++&0xff) == SE) { |
190 |
return look; |
191 |
} |
192 |
} |
170 |
} |
193 |
} |
171 |
end = nextend; |
|
|
172 |
next = 0; |
194 |
} |
173 |
} |
195 |
default: |
174 |
|
196 |
return current+2; |
175 |
switch (*current++) { |
197 |
} |
176 |
case DO: |
|
|
177 |
case DONT: |
178 |
case WILL: |
179 |
case WONT: |
180 |
current++; |
181 |
break; |
182 |
case SB: /* loop forever looking for the SE */ |
183 |
for (;;) { |
184 |
int iac; |
185 |
|
186 |
while (iac = 0, current < end) { |
187 |
if (*current++ == IAC) { |
188 |
if (current >= end) { |
189 |
iac = 1; |
190 |
break; |
191 |
} |
192 |
iac: |
193 |
if (*current++ == SE) { |
194 |
goto out; |
195 |
} |
196 |
} |
197 |
} |
198 |
|
199 |
current = next; |
200 |
if (!current) { |
201 |
return 0; |
202 |
} |
203 |
end = nextend; |
204 |
next = 0; |
205 |
if (iac) { |
206 |
goto iac; |
207 |
} |
208 |
} |
209 |
} |
210 |
|
211 |
out: |
212 |
return next ? next + (current - end) : current; |
198 |
} /* end of nextitem */ |
213 |
} /* end of nextitem */ |
199 |
|
214 |
|
200 |
|
215 |
|
Lines 216-360
Link Here
|
216 |
*/ |
231 |
*/ |
217 |
void netclear(void) |
232 |
void netclear(void) |
218 |
{ |
233 |
{ |
219 |
register char *thisitem, *next; |
234 |
doclear++; |
220 |
char *good; |
235 |
netflush(); |
221 |
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \ |
236 |
doclear--; |
222 |
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) |
237 |
} /* end of netclear */ |
223 |
|
238 |
|
224 |
#if defined(ENCRYPT) |
239 |
static void |
225 |
thisitem = nclearto > netobuf ? nclearto : netobuf; |
240 |
netwritebuf(void) |
226 |
#else |
241 |
{ |
227 |
thisitem = netobuf; |
242 |
struct iovec *vector; |
228 |
#endif |
243 |
struct iovec *v; |
|
|
244 |
struct buflist *lp; |
245 |
ssize_t n; |
246 |
size_t len; |
247 |
int ltrailing = trailing; |
229 |
|
248 |
|
230 |
while ((next = nextitem(thisitem)) <= nbackp) { |
249 |
vector = malloc(listlen * sizeof(struct iovec)); |
231 |
thisitem = next; |
250 |
if (!vector) { |
232 |
} |
251 |
return; |
|
|
252 |
} |
233 |
|
253 |
|
234 |
/* Now, thisitem is first before/at boundary. */ |
254 |
len = listlen - (doclear & ltrailing); |
|
|
255 |
v = vector; |
256 |
lp = head.next; |
257 |
while (lp != &head) { |
258 |
if (lp == urg) { |
259 |
len = v - vector; |
260 |
if (!len) { |
261 |
n = send(net, lp->buf, 1, MSG_OOB); |
262 |
if (n > 0) { |
263 |
urg = 0; |
264 |
} |
265 |
goto epi; |
266 |
} |
267 |
break; |
268 |
} |
269 |
v->iov_base = lp->buf; |
270 |
v->iov_len = lp->len; |
271 |
v++; |
272 |
lp = lp->next; |
273 |
} |
235 |
|
274 |
|
236 |
#if defined(ENCRYPT) |
275 |
vector->iov_base = (char *)vector->iov_base + skip; |
237 |
good = nclearto > netobuf ? nclearto : netobuf; |
276 |
vector->iov_len -= skip; |
238 |
#else |
277 |
|
239 |
good = netobuf; /* where the good bytes go */ |
278 |
n = writev(net, vector, len); |
240 |
#endif |
|
|
241 |
|
279 |
|
242 |
while (nfrontp > thisitem) { |
280 |
epi: |
243 |
if (wewant(thisitem)) { |
281 |
free(vector); |
244 |
int length; |
282 |
|
245 |
|
283 |
if (n < 0) { |
246 |
next = thisitem; |
284 |
if (errno != EWOULDBLOCK && errno != EINTR) |
247 |
do { |
285 |
cleanup(0); |
248 |
next = nextitem(next); |
286 |
return; |
249 |
} while (wewant(next) && (nfrontp > next)); |
|
|
250 |
length = next-thisitem; |
251 |
bcopy(thisitem, good, length); |
252 |
good += length; |
253 |
thisitem = next; |
254 |
} else { |
255 |
thisitem = nextitem(thisitem); |
256 |
} |
287 |
} |
257 |
} |
|
|
258 |
|
288 |
|
259 |
nbackp = netobuf; |
289 |
len = n + skip; |
260 |
nfrontp = good; /* next byte to be sent */ |
|
|
261 |
neturg = 0; |
262 |
} /* end of netclear */ |
263 |
|
290 |
|
264 |
/* |
291 |
lp = head.next; |
265 |
* netflush |
292 |
while (lp->len <= len) { |
266 |
* Send as much data as possible to the network, |
293 |
if (lp == tail && ltrailing) { |
267 |
* handling requests for urgent data. |
294 |
break; |
268 |
*/ |
295 |
} |
269 |
extern int not42; |
|
|
270 |
void |
271 |
netflush(void) |
272 |
{ |
273 |
int n; |
274 |
|
296 |
|
275 |
if ((n = nfrontp - nbackp) > 0) { |
297 |
len -= lp->len; |
276 |
DIAG(TD_REPORT, |
298 |
|
277 |
{ netoprintf("td: netflush %d chars\r\n", n); |
299 |
head.next = lp->next; |
278 |
n = nfrontp - nbackp; /* update count */ |
300 |
listlen--; |
279 |
}); |
301 |
free(lp->buf); |
280 |
#if defined(ENCRYPT) |
302 |
free(lp); |
281 |
if (encrypt_output) { |
303 |
|
282 |
char *s = nclearto ? nclearto : nbackp; |
304 |
lp = head.next; |
283 |
if (nfrontp - s > 0) { |
305 |
if (lp == &head) { |
284 |
(*encrypt_output)((unsigned char *)s, nfrontp-s); |
306 |
tail = &head; |
285 |
nclearto = nfrontp; |
307 |
break; |
286 |
} |
308 |
} |
287 |
} |
309 |
} |
288 |
#endif |
|
|
289 |
/* |
290 |
* if no urgent data, or if the other side appears to be an |
291 |
* old 4.2 client (and thus unable to survive TCP urgent data), |
292 |
* write the entire buffer in non-OOB mode. |
293 |
*/ |
294 |
if ((neturg == 0) || (not42 == 0)) { |
295 |
n = write(net, nbackp, n); /* normal write */ |
296 |
} else { |
297 |
n = neturg - nbackp; |
298 |
/* |
299 |
* In 4.2 (and 4.3) systems, there is some question about |
300 |
* what byte in a sendOOB operation is the "OOB" data. |
301 |
* To make ourselves compatible, we only send ONE byte |
302 |
* out of band, the one WE THINK should be OOB (though |
303 |
* we really have more the TCP philosophy of urgent data |
304 |
* rather than the Unix philosophy of OOB data). |
305 |
*/ |
306 |
if (n > 1) { |
307 |
n = send(net, nbackp, n-1, 0); /* send URGENT all by itself */ |
308 |
} else { |
309 |
n = send(net, nbackp, n, MSG_OOB); /* URGENT data */ |
310 |
} |
311 |
} |
312 |
} |
313 |
if (n < 0) { |
314 |
if (errno == EWOULDBLOCK || errno == EINTR) |
315 |
return; |
316 |
cleanup(0); |
317 |
} |
318 |
nbackp += n; |
319 |
#if defined(ENCRYPT) |
320 |
if (nbackp > nclearto) |
321 |
nclearto = 0; |
322 |
#endif |
323 |
if (nbackp >= neturg) { |
324 |
neturg = 0; |
325 |
} |
326 |
if (nbackp == nfrontp) { |
327 |
nbackp = nfrontp = netobuf; |
328 |
#if defined(ENCRYPT) |
329 |
nclearto = 0; |
330 |
#endif |
331 |
} |
332 |
return; |
333 |
} /* end of netflush */ |
334 |
|
310 |
|
|
|
311 |
skip = len; |
312 |
} |
335 |
|
313 |
|
336 |
/* |
314 |
/* |
337 |
* writenet |
315 |
* netflush |
338 |
* |
316 |
* Send as much data as possible to the network, |
339 |
* Just a handy little function to write a bit of raw data to the net. |
317 |
* handling requests for urgent data. |
340 |
* It will force a transmit of the buffer if necessary |
|
|
341 |
* |
342 |
* arguments |
343 |
* ptr - A pointer to a character string to write |
344 |
* len - How many bytes to write |
345 |
*/ |
318 |
*/ |
346 |
void writenet(register unsigned char *ptr, register int len) |
319 |
void |
|
|
320 |
netflush(void) |
347 |
{ |
321 |
{ |
348 |
/* flush buffer if no room for new data) */ |
322 |
if (fflush(netfile)) { |
349 |
if ((&netobuf[BUFSIZ] - nfrontp) < len) { |
323 |
/* out of memory? */ |
350 |
/* if this fails, don't worry, buffer is a little big */ |
324 |
cleanup(0); |
351 |
netflush(); |
|
|
352 |
} |
325 |
} |
353 |
|
326 |
if (listlen) { |
354 |
bcopy(ptr, nfrontp, len); |
327 |
netwritebuf(); |
355 |
nfrontp += len; |
328 |
} |
356 |
|
329 |
} |
357 |
} /* end of writenet */ |
|
|
358 |
|
330 |
|
359 |
|
331 |
|
360 |
/* |
332 |
/* |
Lines 391-408
Link Here
|
391 |
fatal(f, buf); |
363 |
fatal(f, buf); |
392 |
} |
364 |
} |
393 |
|
365 |
|
394 |
char editedhost[32]; |
366 |
char *editedhost; |
395 |
struct utsname kerninfo; |
367 |
struct utsname kerninfo; |
396 |
|
368 |
|
397 |
void |
369 |
void |
398 |
edithost(const char *pat, const char *host) |
370 |
edithost(const char *pat, const char *host) |
399 |
{ |
371 |
{ |
400 |
char *res = editedhost; |
372 |
char *res; |
401 |
|
373 |
|
402 |
uname(&kerninfo); |
374 |
uname(&kerninfo); |
403 |
|
375 |
|
404 |
if (!pat) |
376 |
if (!pat) |
405 |
pat = ""; |
377 |
pat = ""; |
|
|
378 |
|
379 |
res = realloc(editedhost, strlen(pat) + strlen(host) + 1); |
380 |
if (!res) { |
381 |
if (editedhost) { |
382 |
free(editedhost); |
383 |
editedhost = 0; |
384 |
} |
385 |
fprintf(stderr, "edithost: Out of memory\n"); |
386 |
return; |
387 |
} |
388 |
editedhost = res; |
389 |
|
406 |
while (*pat) { |
390 |
while (*pat) { |
407 |
switch (*pat) { |
391 |
switch (*pat) { |
408 |
|
392 |
|
Lines 420-437
Link Here
|
420 |
*res++ = *pat; |
404 |
*res++ = *pat; |
421 |
break; |
405 |
break; |
422 |
} |
406 |
} |
423 |
if (res == &editedhost[sizeof editedhost - 1]) { |
|
|
424 |
*res = '\0'; |
425 |
return; |
426 |
} |
427 |
pat++; |
407 |
pat++; |
428 |
} |
408 |
} |
429 |
if (*host) |
409 |
if (*host) |
430 |
(void) strncpy(res, host, |
410 |
(void) strcpy(res, host); |
431 |
sizeof editedhost - (res - editedhost) -1); |
|
|
432 |
else |
411 |
else |
433 |
*res = '\0'; |
412 |
*res = '\0'; |
434 |
editedhost[sizeof editedhost - 1] = '\0'; |
|
|
435 |
} |
413 |
} |
436 |
|
414 |
|
437 |
static char *putlocation; |
415 |
static char *putlocation; |
Lines 475-481
Link Here
|
475 |
break; |
453 |
break; |
476 |
|
454 |
|
477 |
case 'h': |
455 |
case 'h': |
478 |
putstr(editedhost); |
456 |
if (editedhost) { |
|
|
457 |
putstr(editedhost); |
458 |
} |
479 |
break; |
459 |
break; |
480 |
|
460 |
|
481 |
case 'd': |
461 |
case 'd': |
Lines 1118-1128
Link Here
|
1118 |
char xbuf[30]; |
1098 |
char xbuf[30]; |
1119 |
|
1099 |
|
1120 |
while (cnt) { |
1100 |
while (cnt) { |
1121 |
/* flush net output buffer if no room for new data) */ |
|
|
1122 |
if ((&netobuf[BUFSIZ] - nfrontp) < 80) { |
1123 |
netflush(); |
1124 |
} |
1125 |
|
1126 |
/* add a line of output */ |
1101 |
/* add a line of output */ |
1127 |
netoprintf("%s: ", tag); |
1102 |
netoprintf("%s: ", tag); |
1128 |
for (i = 0; i < 20 && cnt; i++) { |
1103 |
for (i = 0; i < 20 && cnt; i++) { |
Lines 1143-1145
Link Here
|
1143 |
} |
1118 |
} |
1144 |
} |
1119 |
} |
1145 |
#endif /* DIAGNOSTICS */ |
1120 |
#endif /* DIAGNOSTICS */ |
1146 |
-- netkit-telnet-0.17.orig/telnetlogin/telnetlogin.8 |
1121 |
|
|
|
1122 |
static struct buflist * |
1123 |
addbuf(const char *buf, size_t len) |
1124 |
{ |
1125 |
struct buflist *bufl; |
1126 |
|
1127 |
bufl = malloc(sizeof(struct buflist)); |
1128 |
if (!bufl) { |
1129 |
return 0; |
1130 |
} |
1131 |
bufl->next = tail->next; |
1132 |
bufl->buf = malloc(len); |
1133 |
if (!bufl->buf) { |
1134 |
free(bufl); |
1135 |
return 0; |
1136 |
} |
1137 |
bufl->len = len; |
1138 |
|
1139 |
tail = tail->next = bufl; |
1140 |
listlen++; |
1141 |
|
1142 |
memcpy(bufl->buf, buf, len); |
1143 |
return bufl; |
1144 |
} |
1145 |
|
1146 |
static ssize_t |
1147 |
netwrite(void *cookie, const char *buf, size_t len) |
1148 |
{ |
1149 |
size_t ret; |
1150 |
const char *const end = buf + len; |
1151 |
int ltrailing = trailing; |
1152 |
int ldoclear = doclear; |
1153 |
|
1154 |
#define wewant(p) ((*p&0xff) == IAC) && \ |
1155 |
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL) |
1156 |
|
1157 |
ret = 0; |
1158 |
|
1159 |
if (ltrailing) { |
1160 |
const char *p; |
1161 |
size_t l; |
1162 |
size_t m = tail->len; |
1163 |
|
1164 |
p = nextitem(tail->buf, tail->buf + tail->len, buf, end); |
1165 |
ltrailing = !p; |
1166 |
if (ltrailing) { |
1167 |
p = end; |
1168 |
} |
1169 |
|
1170 |
l = p - buf; |
1171 |
tail->len += l; |
1172 |
tail->buf = realloc(tail->buf, tail->len); |
1173 |
if (!tail->buf) { |
1174 |
return -1; |
1175 |
} |
1176 |
|
1177 |
memcpy(tail->buf + m, buf, l); |
1178 |
buf += l; |
1179 |
len -= l; |
1180 |
ret += l; |
1181 |
trailing = ltrailing; |
1182 |
} |
1183 |
|
1184 |
if (ldoclear) { |
1185 |
struct buflist *lpprev; |
1186 |
|
1187 |
skip = 0; |
1188 |
lpprev = &head; |
1189 |
for (;;) { |
1190 |
struct buflist *lp; |
1191 |
|
1192 |
lp = lpprev->next; |
1193 |
|
1194 |
if (lp == &head) { |
1195 |
tail = lpprev; |
1196 |
break; |
1197 |
} |
1198 |
|
1199 |
if (lp == tail && ltrailing) { |
1200 |
break; |
1201 |
} |
1202 |
|
1203 |
if (!wewant(lp->buf)) { |
1204 |
lpprev->next = lp->next; |
1205 |
listlen--; |
1206 |
free(lp->buf); |
1207 |
free(lp); |
1208 |
} else { |
1209 |
lpprev = lp; |
1210 |
} |
1211 |
} |
1212 |
} |
1213 |
|
1214 |
while (len) { |
1215 |
const char *p; |
1216 |
size_t l; |
1217 |
|
1218 |
p = nextitem(buf, end, 0, 0); |
1219 |
ltrailing = !p; |
1220 |
if (ltrailing) { |
1221 |
p = end; |
1222 |
} else if (ldoclear) { |
1223 |
if (!wewant(buf)) { |
1224 |
l = p - buf; |
1225 |
goto cont; |
1226 |
} |
1227 |
} |
1228 |
|
1229 |
l = p - buf; |
1230 |
if (!addbuf(buf, l)) { |
1231 |
return ret ? ret : -1; |
1232 |
} |
1233 |
trailing = ltrailing; |
1234 |
|
1235 |
cont: |
1236 |
buf += l; |
1237 |
len -= l; |
1238 |
ret += l; |
1239 |
} |
1240 |
|
1241 |
netwritebuf(); |
1242 |
return ret; |
1243 |
} |
1244 |
|
1245 |
void |
1246 |
netopen() { |
1247 |
static const cookie_io_functions_t funcs = { |
1248 |
read: 0, write: netwrite, seek: 0, close: 0 |
1249 |
}; |
1250 |
|
1251 |
netfile = fopencookie(0, "w", funcs); |
1252 |
} |
1253 |
|
1254 |
extern int not42; |
1255 |
void |
1256 |
sendurg(const char *buf, size_t len) { |
1257 |
if (!not42) { |
1258 |
fwrite(buf, 1, len, netfile); |
1259 |
return; |
1260 |
} |
1261 |
|
1262 |
urg = addbuf(buf, len); |
1263 |
} |
1264 |
|
1265 |
size_t |
1266 |
netbuflen(int flush) { |
1267 |
if (flush) { |
1268 |
netflush(); |
1269 |
} |
1270 |
return listlen != 1 ? listlen : tail->len - skip; |
1271 |
} |
|
|
1272 |
++ netkit-telnet-0.17/telnetlogin/telnetlogin.8 |
Lines 40-45
Link Here
|
40 |
.Nm telnetlogin |
40 |
.Nm telnetlogin |
41 |
.Op Fl h Ar host |
41 |
.Op Fl h Ar host |
42 |
.Op Fl p |
42 |
.Op Fl p |
|
|
43 |
.Op Ar username |
43 |
.Sh DESCRIPTION |
44 |
.Sh DESCRIPTION |
44 |
.Nm telnetlogin |
45 |
.Nm telnetlogin |
45 |
is a setuid wrapper that runs |
46 |
is a setuid wrapper that runs |
Lines 62-71
Link Here
|
62 |
.Nm telnetd 8 |
63 |
.Nm telnetd 8 |
63 |
normally provides them in. |
64 |
normally provides them in. |
64 |
.Nm telnetlogin |
65 |
.Nm telnetlogin |
65 |
also only accepts the environment variables |
66 |
also does sanity checks on the environment variables |
66 |
.Ev TERM , |
67 |
.Ev TERM , |
67 |
.Ev DISPLAY , |
|
|
68 |
.Ev POSIXLY_CORRECT , |
69 |
and |
68 |
and |
70 |
.Ev REMOTEHOST . |
69 |
.Ev REMOTEHOST . |
71 |
It also insists that the standard input, output, and error streams are |
70 |
It also insists that the standard input, output, and error streams are |
Lines 83-89
Link Here
|
83 |
.Nm telnetlogin |
82 |
.Nm telnetlogin |
84 |
does not permit the |
83 |
does not permit the |
85 |
.Fl f |
84 |
.Fl f |
86 |
option to login, and does not permit passing a username, so will not |
85 |
option to login, so will not |
87 |
work with telnetds that perform authentication via Kerberos or SSL. |
86 |
work with telnetds that perform authentication via Kerberos or SSL. |
88 |
.Pp |
87 |
.Pp |
89 |
THIS IS PRESENTLY EXPERIMENTAL CODE; USE WITH CAUTION. |
88 |
THIS IS PRESENTLY EXPERIMENTAL CODE; USE WITH CAUTION. |
90 |
-- netkit-telnet-0.17.orig/telnetlogin/telnetlogin.c |
89 |
++ netkit-telnet-0.17/telnetlogin/telnetlogin.c |
Lines 51-70
Link Here
|
51 |
#include <string.h> |
51 |
#include <string.h> |
52 |
#include <stdarg.h> |
52 |
#include <stdarg.h> |
53 |
#include <stdio.h> |
53 |
#include <stdio.h> |
|
|
54 |
#include <syslog.h> |
54 |
|
55 |
|
55 |
#ifndef _PATH_LOGIN |
56 |
#ifndef _PATH_LOGIN |
56 |
#define _PATH_LOGIN "/bin/login" |
57 |
#define _PATH_LOGIN "/bin/login" |
57 |
#endif |
58 |
#endif |
58 |
|
59 |
|
|
|
60 |
extern char **environ; |
61 |
|
59 |
static const char *remhost = NULL; |
62 |
static const char *remhost = NULL; |
60 |
|
63 |
|
|
|
64 |
static void die(const char *, ...) __attribute__ ((noreturn)); |
65 |
|
61 |
static void die(const char *fmt, ...) { |
66 |
static void die(const char *fmt, ...) { |
62 |
va_list ap; |
67 |
va_list ap; |
63 |
fprintf(stderr, "telnetlogin: "); |
68 |
openlog("telnetlogin", LOG_PID, LOG_AUTHPRIV); |
64 |
va_start(ap, fmt); |
69 |
va_start(ap, fmt); |
65 |
vfprintf(stderr, fmt, ap); |
70 |
vsyslog(LOG_CRIT, fmt, ap); |
66 |
va_end(ap); |
71 |
va_end(ap); |
67 |
fprintf(stderr, "\n"); |
|
|
68 |
exit(1); |
72 |
exit(1); |
69 |
} |
73 |
} |
70 |
|
74 |
|
Lines 86-126
Link Here
|
86 |
return 0; |
90 |
return 0; |
87 |
} |
91 |
} |
88 |
|
92 |
|
89 |
static int check_display(char *disp) { |
|
|
90 |
char *colon, *s; |
91 |
struct hostent *hp; |
92 |
int num; |
93 |
|
94 |
colon = strchr(disp, ':'); |
95 |
if (!colon) return -1; |
96 |
*colon = 0; /* temporarily */ |
97 |
|
98 |
if (check_a_hostname(disp)) return -1; |
99 |
|
100 |
hp = gethostbyname(disp); |
101 |
if (!hp) return -1; |
102 |
|
103 |
*colon = ':'; |
104 |
s = colon+1; |
105 |
while (*s && isdigit(*s)) s++; |
106 |
if (*s) { |
107 |
if (*s!='.') return -1; |
108 |
s++; |
109 |
while (*s && isdigit(*s)) s++; |
110 |
} |
111 |
if (*s) return -1; |
112 |
|
113 |
num = atoi(colon+1); |
114 |
if (num<0 || num>99) return -1; |
115 |
|
116 |
return 0; |
117 |
} |
118 |
|
119 |
static int check_posixly_correct(char *val) { |
120 |
if (strlen(val)==0 || !strcmp(val, "1")) return 0; |
121 |
return -1; |
122 |
} |
123 |
|
124 |
static int check_remotehost(char *val) { |
93 |
static int check_remotehost(char *val) { |
125 |
if (check_a_hostname(val)) return -1; |
94 |
if (check_a_hostname(val)) return -1; |
126 |
if (remhost && strcmp(val, remhost)) return -1; |
95 |
if (remhost && strcmp(val, remhost)) return -1; |
Lines 132-139
Link Here
|
132 |
int (*validator)(char *); |
101 |
int (*validator)(char *); |
133 |
} legal_envs[] = { |
102 |
} legal_envs[] = { |
134 |
{ "TERM", check_term }, |
103 |
{ "TERM", check_term }, |
135 |
{ "DISPLAY", check_display }, |
|
|
136 |
{ "POSIXLY_CORRECT", check_posixly_correct }, |
137 |
{ "REMOTEHOST", check_remotehost }, |
104 |
{ "REMOTEHOST", check_remotehost }, |
138 |
{ NULL, NULL } |
105 |
{ NULL, NULL } |
139 |
}; |
106 |
}; |
Lines 166-175
Link Here
|
166 |
static char argv0[] = "login"; |
133 |
static char argv0[] = "login"; |
167 |
int argn, i, j; |
134 |
int argn, i, j; |
168 |
const char *rh = NULL; |
135 |
const char *rh = NULL; |
169 |
char **envs = __environ; |
136 |
char **envs = environ; |
170 |
|
|
|
171 |
/* make as sure as possible no library routines or anything can use it */ |
172 |
__environ = NULL; |
173 |
|
137 |
|
174 |
/* first, make sure our stdin/stdout/stderr are aimed somewhere */ |
138 |
/* first, make sure our stdin/stdout/stderr are aimed somewhere */ |
175 |
i = open("/", O_RDONLY); |
139 |
i = open("/", O_RDONLY); |
Lines 194-199
Link Here
|
194 |
if (argn < argc && !strcmp(argv[argn], "-p")) { |
158 |
if (argn < argc && !strcmp(argv[argn], "-p")) { |
195 |
argn++; |
159 |
argn++; |
196 |
} |
160 |
} |
|
|
161 |
if (argn < argc && argv[argn][0] != '-') { |
162 |
argn++; |
163 |
} |
197 |
if (argn < argc) die("Illegal args: too many args"); |
164 |
if (argn < argc) die("Illegal args: too many args"); |
198 |
argv[0] = argv0; |
165 |
argv[0] = argv0; |
199 |
|
166 |
|
Lines 201-221
Link Here
|
201 |
if (envs) for (i=0; envs[i]; i++) { |
168 |
if (envs) for (i=0; envs[i]; i++) { |
202 |
char *testenv = envs[i]; |
169 |
char *testenv = envs[i]; |
203 |
size_t testlen = strlen(testenv); |
170 |
size_t testlen = strlen(testenv); |
204 |
int ok = 0; |
171 |
for (j=0; legal_envs[j].name; j++) { |
205 |
for (j=0; legal_envs[j].name && !ok; j++) { |
|
|
206 |
const char *okenv = legal_envs[j].name; |
172 |
const char *okenv = legal_envs[j].name; |
207 |
size_t oklen = strlen(okenv); |
173 |
size_t oklen = strlen(okenv); |
|
|
174 |
int sign; |
208 |
|
175 |
|
209 |
if (testlen < oklen) continue; |
176 |
if (testlen < oklen) continue; |
210 |
if (testenv[oklen]!='=') continue; |
177 |
if (testenv[oklen]!='=') continue; |
211 |
if (memcmp(testenv, okenv, oklen)) continue; |
178 |
if ((sign = memcmp(testenv, okenv, oklen)) < 0) { |
|
|
179 |
continue; |
180 |
} else if (sign > 0) { |
181 |
break; |
182 |
} |
212 |
if (legal_envs[j].validator(testenv+oklen+1)) { |
183 |
if (legal_envs[j].validator(testenv+oklen+1)) { |
213 |
die("Invalid environment: bad value for %s", okenv); |
184 |
die("Invalid environment: bad value for %s", okenv); |
214 |
} |
185 |
} |
215 |
ok = 1; |
186 |
break; |
216 |
} |
|
|
217 |
if (!ok) { |
218 |
die("Illegal environment: forbidden variable"); |
219 |
} |
187 |
} |
220 |
} |
188 |
} |
221 |
|
189 |
|
Lines 234-239
Link Here
|
234 |
* but, should we insist that ruid==nobody? |
202 |
* but, should we insist that ruid==nobody? |
235 |
*/ |
203 |
*/ |
236 |
|
204 |
|
|
|
205 |
#ifdef debian |
206 |
/* |
207 |
* Debian's /bin/login doesn't work properly unless we're really root. |
208 |
*/ |
209 |
setuid(0); |
210 |
#endif |
211 |
|
237 |
/* |
212 |
/* |
238 |
* don't do anything with limits, itimers, or process priority either |
213 |
* don't do anything with limits, itimers, or process priority either |
239 |
*/ |
214 |
*/ |
240 |
-- netkit-telnet-0.17.orig/__conftest.cc |
215 |
++ netkit-telnet-0.17/__conftest.cc |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/changelog |
1 |
#include <stdio.h> |
|
|
2 |
int main() { |
3 |
void *x = (void *)snprintf; |
4 |
printf("%lx", (long)x); |
5 |
return 0; |
6 |
} |
7 |
|
|
|
8 |
++ netkit-telnet-0.17/debian/changelog |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/control |
1 |
netkit-telnet (0.17-25) unstable; urgency=low |
|
|
2 |
|
3 |
* telnet/commands.cc: Fix buffer overflow when $HOME is too big. Thanks |
4 |
Josh Martin. (Closes: #264846) |
5 |
|
6 |
-- Robert Millan <rmh@debian.org> Fri, 13 Aug 2004 04:21:36 +0200 |
7 |
|
8 |
netkit-telnet (0.17-24) unstable; urgency=low |
9 |
|
10 |
* New maintainer. (Closes: #249714) |
11 |
- control (Maintainer): Set myself. |
12 |
|
13 |
-- Robert Millan <rmh@debian.org> Wed, 19 May 2004 02:10:38 +0200 |
14 |
|
15 |
netkit-telnet (0.17-23) unstable; urgency=low |
16 |
|
17 |
* Accept numeric telnet options in telnet (closes: #242018). |
18 |
* Added telnet dependency on netbase for /etc/services. |
19 |
|
20 |
-- Herbert Xu <herbert@debian.org> Sat, 15 May 2004 17:13:42 +1000 |
21 |
|
22 |
netkit-telnet (0.17-22) unstable; urgency=low |
23 |
|
24 |
* Use colon as separator for chown (closes: #217404). |
25 |
|
26 |
-- Herbert Xu <herbert@debian.org> Sat, 6 Dec 2003 08:45:30 +1100 |
27 |
|
28 |
netkit-telnet (0.17-21) unstable; urgency=low |
29 |
|
30 |
* Removed build-stamp/install-stamp from debian/rules. |
31 |
* Removed obsolete warning options from configure. |
32 |
* Disable 8-bit mode if parity bit is enabled (closes: #203544). |
33 |
* Disabled trigraph warnings. |
34 |
* Commented out tokens after endif. |
35 |
* Added -b option to telnet (closes: #194736). |
36 |
|
37 |
-- Herbert Xu <herbert@debian.org> Sat, 18 Oct 2003 14:38:04 +1000 |
38 |
|
39 |
netkit-telnet (0.17-20) unstable; urgency=low |
40 |
|
41 |
* Use 8-bit mode without binary option as default (OpenBSD via |
42 |
Xisco Calafat). |
43 |
* Added port specification to telnetrc (closes: #144921). |
44 |
|
45 |
-- Herbert Xu <herbert@debian.org> Sun, 25 May 2003 19:02:35 +1000 |
46 |
|
47 |
netkit-telnet (0.17-19) unstable; urgency=low |
48 |
|
49 |
* Applied Hurd patch (Robert Millan, closes: #149325). |
50 |
* Fixed telnetlogin path in telnetd manpage (closes: #150812). |
51 |
* Do not abort if user/group does not exist in prerm (closes: #149181). |
52 |
|
53 |
-- Herbert Xu <herbert@debian.org> Sun, 22 Sep 2002 15:05:20 +1000 |
54 |
|
55 |
netkit-telnet (0.17-18) unstable; urgency=low |
56 |
|
57 |
* Added missing El's in telnetd(8). |
58 |
* -S now accepts a number (closes: #136804). |
59 |
* Show the machine we are connected instead of the first (closes: #137554). |
60 |
|
61 |
-- Herbert Xu <herbert@debian.org> Sun, 7 Apr 2002 09:41:12 +1000 |
62 |
|
63 |
netkit-telnet (0.17-17) unstable; urgency=high |
64 |
|
65 |
* Provide telnet-server (closes: #120180). |
66 |
* Fixed IAC+SB crash (closes: #122313, #128988). |
67 |
|
68 |
-- Herbert Xu <herbert@debian.org> Fri, 18 Jan 2002 20:13:23 +1100 |
69 |
|
70 |
netkit-telnet (0.17-16) unstable; urgency=low |
71 |
|
72 |
* Set resolv_hostp outside the source routing ifdef in telnetd. |
73 |
* Documented telnet options -4 and -6 (closes: #109636). |
74 |
|
75 |
-- Herbert Xu <herbert@debian.org> Sun, 16 Sep 2001 14:38:05 +1000 |
76 |
|
77 |
netkit-telnet (0.17-15) unstable; urgency=low |
78 |
|
79 |
* Don't ignore all EADDRINUSE errors in telnet. |
80 |
* Don't clear the environment in telnetlogin (closes: #108872). |
81 |
|
82 |
-- Herbert Xu <herbert@debian.org> Thu, 16 Aug 2001 19:38:11 +1000 |
83 |
|
84 |
netkit-telnet (0.17-14) unstable; urgency=high |
85 |
|
86 |
* Fixed netobuf buffer overflows. |
87 |
|
88 |
-- Herbert Xu <herbert@debian.org> Sat, 11 Aug 2001 17:52:25 +1000 |
89 |
|
90 |
netkit-telnet (0.17-13) unstable; urgency=medium |
91 |
|
92 |
* Updated devpts check to include devfs as well. |
93 |
|
94 |
-- Herbert Xu <herbert@debian.org> Sat, 19 May 2001 15:33:41 +1000 |
95 |
|
96 |
netkit-telnet (0.17-12) unstable; urgency=low |
97 |
|
98 |
* Added include <sys/time.h> to telnetd/utility.c (closes: #96803). |
99 |
|
100 |
-- Herbert Xu <herbert@debian.org> Wed, 9 May 2001 21:17:12 +1000 |
101 |
|
102 |
netkit-telnet (0.17-11) unstable; urgency=low |
103 |
|
104 |
* Added exit 0 to telnetd.postrm (closes: #93934). |
105 |
* Changed misleading help message (closes: #94231). |
106 |
|
107 |
-- Herbert Xu <herbert@debian.org> Sat, 21 Apr 2001 22:52:11 +1000 |
108 |
|
109 |
netkit-telnet (0.17-10) unstable; urgency=low |
110 |
|
111 |
* Renamed member printf to xprintf (closes: #91351). |
112 |
* Use new in C++ compiler test (closes: #91353). |
113 |
|
114 |
-- Herbert Xu <herbert@debian.org> Fri, 13 Apr 2001 19:34:12 +1000 |
115 |
|
116 |
netkit-telnet (0.17-9) unstable; urgency=low |
117 |
|
118 |
* Fixed path to license file (Christoph Martin, closes: #86476). |
119 |
* Added missing #DEBHELPER# tag to telnet.prerm (Hiroyuki YAMAMORI, |
120 |
closes: #86894). |
121 |
* Only call update-alternatives in prerm if removing or deconfiguring |
122 |
(closes: #87330). |
123 |
|
124 |
-- Herbert Xu <herbert@debian.org> Sun, 25 Feb 2001 00:00:59 +1100 |
125 |
|
126 |
netkit-telnet (0.17-8) unstable; urgency=low |
127 |
|
128 |
* Removed remnant of suidregister from telnetd (closes: #85882). |
129 |
* Fixed handling of sockaddr lengths (closes: #86177). |
130 |
* Dynamically allocate editedhost (closes: #86080). |
131 |
|
132 |
-- Herbert Xu <herbert@debian.org> Sat, 17 Feb 2001 12:53:11 +1100 |
133 |
|
134 |
netkit-telnet (0.17-7) unstable; urgency=low |
135 |
|
136 |
* Added includes for gcc 2.97 (Randolph Chung, closes: #83337). |
137 |
* Avoid DNS lookups if the address is numerical (closes: #83828). |
138 |
* Added menu hint (closes: #80161). |
139 |
|
140 |
-- Herbert Xu <herbert@debian.org> Mon, 29 Jan 2001 21:10:59 +1100 |
141 |
|
142 |
netkit-telnet (0.17-6) unstable; urgency=low |
143 |
|
144 |
* Added menu entry for telnet (closes: #74845). |
145 |
|
146 |
-- Herbert Xu <herbert@debian.org> Sat, 21 Oct 2000 11:08:44 +1100 |
147 |
|
148 |
netkit-telnet (0.17-5) unstable; urgency=low |
149 |
|
150 |
* Fixed a memory allocation bug. |
151 |
|
152 |
-- Herbert Xu <herbert@debian.org> Fri, 22 Sep 2000 23:12:57 +1100 |
153 |
|
154 |
netkit-telnet (0.17-4) unstable; urgency=low |
155 |
|
156 |
* Relaxed telnetlogin a bit. |
157 |
* Provide telnet-client (closes: #70549). |
158 |
|
159 |
-- Herbert Xu <herbert@debian.org> Sat, 9 Sep 2000 17:42:53 +1100 |
160 |
|
161 |
netkit-telnet (0.17-3) unstable; urgency=low |
162 |
|
163 |
* Check for EAFNOSUPPORT after calling socket(2) in telnet. |
164 |
* Added IPv6 support for telnetd. |
165 |
|
166 |
-- Herbert Xu <herbert@debian.org> Sun, 27 Aug 2000 11:28:48 +1100 |
167 |
|
168 |
netkit-telnet (0.17-2) unstable; urgency=low |
169 |
|
170 |
* Install telnetlogin ourselves (closes: #69773). |
171 |
* Fixed alternatives typo (closes: #69597). |
172 |
|
173 |
-- Herbert Xu <herbert@debian.org> Wed, 23 Aug 2000 20:01:38 +1000 |
174 |
|
175 |
netkit-telnet (0.17-1) unstable; urgency=low |
176 |
|
177 |
* New upstream release. |
178 |
* Applied a modified version of Jason Gunthorpe's IPv6 patch for telnet |
179 |
(closes: #68998). |
180 |
* Read /etc/telnetrc before .telnetrc if it exists. The idea was from |
181 |
Robert Luberda. Documented the special hostname DEFAULT (closes: #69113). |
182 |
* Use alternatives for /usr/bin/telnet (closes: #56754). |
183 |
|
184 |
-- Herbert Xu <herbert@debian.org> Sat, 19 Aug 2000 14:06:48 +1000 |
185 |
|
186 |
netkit-telnet (0.16-6) unstable; urgency=low |
187 |
|
188 |
* Handle localchars correctly (closes: #66039). |
189 |
|
190 |
-- Herbert Xu <herbert@debian.org> Mon, 26 Jun 2000 15:01:42 +1000 |
191 |
|
192 |
netkit-telnet (0.16-5) unstable; urgency=low |
193 |
|
194 |
* Fixed a bug in responses to TTYPE queries where a (null) could be sent |
195 |
instead of the correct terminal type (closes: #63155). |
196 |
|
197 |
-- Herbert Xu <herbert@debian.org> Sat, 6 May 2000 09:42:58 +1000 |
198 |
|
199 |
netkit-telnet (0.16-4) frozen unstable; urgency=low |
200 |
|
201 |
* Disabled signal handling that does not work (closes: #62388). Patches |
202 |
that provide correct signal handling are welcome. |
203 |
|
204 |
-- Herbert Xu <herbert@debian.org> Mon, 24 Apr 2000 16:58:22 +1000 |
205 |
|
206 |
netkit-telnet (0.16-3) frozen unstable; urgency=medium |
207 |
|
208 |
* Restored the default to not being 8-bit clean since it breaks SunOS |
209 |
(closes: #60352, #60386). People who need 8-bit cleanness should use -8. |
210 |
* Made FHS compliant. |
211 |
|
212 |
-- Herbert Xu <herbert@debian.org> Wed, 15 Mar 2000 10:39:00 +1100 |
213 |
|
214 |
netkit-telnet (0.16-2) frozen unstable; urgency=low |
215 |
|
216 |
* Recompiled with libncurses5. |
217 |
* Changed the permission of /usr/lib/telnetd/login to 4754 (closes: #58786). |
218 |
* telnet is now 8-bit clean by default since it appeared to be so in slink, |
219 |
albeit unintentionally (closes: #57685). |
220 |
|
221 |
-- Herbert Xu <herbert@debian.org> Sun, 12 Mar 2000 21:10:47 +1100 |
222 |
|
223 |
netkit-telnet (0.16-1) frozen unstable; urgency=low |
224 |
|
225 |
* New upstream release with security fixes. |
226 |
* Run as root if devpts is not present. |
227 |
|
228 |
-- Herbert Xu <herbert@debian.org> Thu, 3 Feb 2000 13:42:29 +1100 |
229 |
|
230 |
netkit-telnet (0.14-9) unstable; urgency=low |
231 |
|
232 |
* Compile login with -g -O2 -Wall. |
233 |
* Fixed path to default login in in.telnetd(8). |
234 |
* Fixed usage() output (closes: #51498). |
235 |
|
236 |
-- Herbert Xu <herbert@debian.org> Tue, 30 Nov 1999 22:43:39 +1100 |
237 |
|
238 |
netkit-telnet (0.14-8) unstable; urgency=low |
239 |
|
240 |
* Call fatalperror() instead of fatal() when getpty() fails. |
241 |
* Delete telnetd group before creating telnetd (closes: #46659). |
242 |
|
243 |
-- Herbert Xu <herbert@debian.org> Tue, 5 Oct 1999 17:52:36 +1000 |
244 |
|
245 |
netkit-telnet (0.14-7) unstable; urgency=low |
246 |
|
247 |
* Redirect stderr for group existence check to /dev/null. |
248 |
|
249 |
-- Herbert Xu <herbert@debian.org> Sat, 25 Sep 1999 22:00:31 +1000 |
250 |
|
251 |
netkit-telnet (0.14-6) unstable; urgency=low |
252 |
|
253 |
* Check for existence of user/group before removing (fixes #45651). |
254 |
|
255 |
-- Herbert Xu <herbert@debian.org> Tue, 21 Sep 1999 21:07:18 +1000 |
256 |
|
257 |
netkit-telnet (0.14-5) unstable; urgency=low |
258 |
|
259 |
* Depend on base-files (>= 2.1.8) for group utmp (fixes #44687). |
260 |
|
261 |
-- Herbert Xu <herbert@debian.org> Sat, 11 Sep 1999 12:53:08 +1000 |
262 |
|
263 |
netkit-telnet (0.14-4) unstable; urgency=low |
264 |
|
265 |
* Rebuilt with working fakeroot (fixes #44043, #44044). |
266 |
|
267 |
-- Herbert Xu <herbert@debian.org> Fri, 3 Sep 1999 20:32:28 +1000 |
268 |
|
269 |
netkit-telnet (0.14-3) unstable; urgency=medium |
270 |
|
271 |
* telnetd is now a member of utmp (fixes #43543). |
272 |
* Call adduser with --quiet (fixes #43587). |
273 |
* configure now works with egcs 2.95 (fixes #43580, #43747) |
274 |
|
275 |
-- Herbert Xu <herbert@debian.org> Thu, 2 Sep 1999 21:18:06 +1000 |
276 |
|
277 |
netkit-telnet (0.14-2) unstable; urgency=low |
278 |
|
279 |
* telnetd now depends on adduser and passwd (fixes #43515). |
280 |
|
281 |
-- Herbert Xu <herbert@debian.org> Thu, 26 Aug 1999 14:49:25 +1000 |
282 |
|
283 |
netkit-telnet (0.14-1) unstable; urgency=low |
284 |
|
285 |
* New upstream release. |
286 |
* Installed the login wrapper (fixes #42092). |
287 |
* Reopen logging if necessary (fixes #36149). |
288 |
|
289 |
-- Herbert Xu <herbert@debian.org> Tue, 24 Aug 1999 09:17:24 +1000 |
290 |
|
291 |
netkit-telnet (0.12-6) unstable; urgency=low |
292 |
|
293 |
* Applied patch from Matt McLean for openpty support (fixes #35629). |
294 |
* Use glibc versions of logout/logwtmp. |
295 |
|
296 |
-- Herbert Xu <herbert@debian.org> Tue, 29 Jun 1999 14:16:14 +1000 |
297 |
|
298 |
netkit-telnet (0.12-5) unstable; urgency=low |
299 |
|
300 |
* Fixed a bug with hostnames longer than 64 characters (fixes #33559). |
301 |
|
302 |
-- Herbert Xu <herbert@debian.org> Tue, 16 Mar 1999 15:24:36 +1100 |
303 |
|
304 |
netkit-telnet (0.12-4) frozen unstable; urgency=low |
305 |
|
306 |
* Uploaded to slink. |
307 |
|
308 |
-- Herbert Xu <herbert@debian.org> Sun, 15 Nov 1998 15:04:40 +1100 |
309 |
|
310 |
netkit-telnet (0.12-3) unstable; urgency=low |
311 |
|
312 |
* Rebuilt with libncurses4. |
313 |
|
314 |
-- Herbert Xu <herbert@debian.org> Sun, 1 Nov 1998 19:38:49 +1100 |
315 |
|
316 |
netkit-telnet (0.12-2) unstable; urgency=low |
317 |
|
318 |
* Rebuilt with libstdc++2.9 (fixes #27789). |
319 |
|
320 |
-- Herbert Xu <herbert@debian.org> Thu, 15 Oct 1998 22:32:04 +1000 |
321 |
|
322 |
netkit-telnet (0.12-1) unstable; urgency=low |
323 |
|
324 |
* Initial Release. |
325 |
|
326 |
-- Herbert Xu <herbert@debian.org> Mon, 28 Sep 1998 16:50:43 +1000 |
327 |
|
|
|
328 |
++ netkit-telnet-0.17/debian/control |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/copyright |
1 |
Source: netkit-telnet |
|
|
2 |
Section: net |
3 |
Priority: standard |
4 |
Maintainer: Robert Millan <rmh@debian.org> |
5 |
Standards-Version: 3.6.1 |
6 |
Build-Depends: debhelper, libncurses-dev |
7 |
|
8 |
Package: telnet |
9 |
Architecture: any |
10 |
Depends: netbase, ${shlibs:Depends} |
11 |
Replaces: netstd |
12 |
Provides: telnet-client |
13 |
Description: The telnet client. |
14 |
The telnet command is used for interactive communication with another host |
15 |
using the TELNET protocol. |
16 |
|
17 |
Package: telnetd |
18 |
Architecture: any |
19 |
Priority: optional |
20 |
Depends: adduser, base-files (>= 2.1.8), dpkg (>= 1.7.0), netbase, passwd, ${shlibs:Depends} |
21 |
Replaces: netstd |
22 |
Provides: telnet-server |
23 |
Conflicts: suidmanager (<< 0.50) |
24 |
Description: The telnet server. |
25 |
The in.telnetd program is a server which supports the DARPA telnet interactive |
26 |
communication protocol. |
27 |
|
|
|
28 |
++ netkit-telnet-0.17/debian/copyright |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/dirs |
1 |
This package was split from netstd by Herbert Xu herbert@debian.org on |
|
|
2 |
Mon, 28 Sep 1998 16:50:43 +1000. |
3 |
|
4 |
netstd was created by Peter Tobias tobias@et-inf.fho-emden.de on |
5 |
Wed, 20 Jul 1994 17:23:21 +0200. |
6 |
|
7 |
It was downloaded from ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/. |
8 |
|
9 |
Copyright: |
10 |
|
11 |
Copyright (c) 1988, 1993 The Regents of the University of California. |
12 |
Copyright (c) 1995 David A. Holland |
13 |
Copyright (c) 1994 Peter Tobias (issue.net(5)) |
14 |
Copyright (c) 1983, 1995 Eric P. Allman (setproctitle.[ch]) |
15 |
|
16 |
The license can be found at /usr/share/common-licenses/BSD. |
17 |
|
18 |
$Id: copyright,v 1.4 2001/02/18 20:28:33 herbert Exp $ |
|
|
19 |
++ netkit-telnet-0.17/debian/dirs |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/docs |
1 |
usr/bin |
|
|
2 |
usr/share/doc/telnet |
3 |
usr/share/man/man1 |
|
|
4 |
++ netkit-telnet-0.17/debian/docs |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/menu |
1 |
BUGS |
|
|
2 |
README |
|
|
3 |
++ netkit-telnet-0.17/debian/menu |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/postinst |
1 |
?package(telnet): \ |
|
|
2 |
needs="text" section="Apps/Net" title="Telnet" command="telnet" \ |
3 |
hints="Terminal" |
|
|
4 |
++ netkit-telnet-0.17/debian/postinst |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/prerm |
1 |
#!/bin/sh -e |
|
|
2 |
# $Id: postinst,v 1.4 2000/08/23 10:08:42 herbert Exp $ |
3 |
|
4 |
update-alternatives --install /usr/bin/telnet telnet /usr/bin/telnet.netkit \ |
5 |
100 --slave /usr/share/man/man1/telnet.1.gz telnet.1.gz \ |
6 |
/usr/share/man/man1/telnet.netkit.1.gz |
7 |
|
8 |
#DEBHELPER# |
|
|
9 |
++ netkit-telnet-0.17/debian/prerm |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/rules |
1 |
#!/bin/sh |
|
|
2 |
|
3 |
if [ "$1" = remove ] || [ "$1" = deconfigure ]; then |
4 |
update-alternatives --remove telnet /usr/bin/telnet.netkit |
5 |
fi |
6 |
|
7 |
#DEBHELPER# |
|
|
8 |
++ netkit-telnet-0.17/debian/rules |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/telnetd.dirs |
1 |
#!/usr/bin/make -f |
|
|
2 |
# $Id: rules,v 1.12 2003/10/18 03:37:54 herbert Exp $ |
3 |
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. |
4 |
|
5 |
# Uncomment this to turn on verbose mode. |
6 |
#export DH_VERBOSE=1 |
7 |
|
8 |
build: |
9 |
dh_testdir |
10 |
|
11 |
if [ ! -f MCONFIG ]; then \ |
12 |
./configure; \ |
13 |
sed -e 's/^CFLAGS=\(.*\)$$/CFLAGS= -Ddebian -D_GNU_SOURCE -g \1/' \ |
14 |
-e 's/^CXXFLAGS=\(.*\)$$/CXXFLAGS= -Ddebian -D_GNU_SOURCE -g \1/' \ |
15 |
MCONFIG > MCONFIG.new; \ |
16 |
mv MCONFIG.new MCONFIG; \ |
17 |
fi |
18 |
$(MAKE) |
19 |
|
20 |
clean: |
21 |
dh_testdir |
22 |
dh_testroot |
23 |
|
24 |
-$(MAKE) distclean |
25 |
|
26 |
dh_clean |
27 |
|
28 |
install: build |
29 |
dh_testdir |
30 |
dh_testroot |
31 |
dh_clean -k |
32 |
dh_installdirs |
33 |
|
34 |
$(MAKE) -C telnet INSTALLROOT=`pwd`/debian/tmp MANDIR=/usr/share/man \ |
35 |
install |
36 |
mv debian/tmp/usr/bin/telnet debian/tmp/usr/bin/telnet.netkit |
37 |
mv debian/tmp/usr/share/man/man1/telnet.1 \ |
38 |
debian/tmp/usr/share/man/man1/telnet.netkit.1 |
39 |
cp telnet/README debian/tmp/usr/share/doc/telnet/README.telnet |
40 |
cp telnet/README.old debian/tmp/usr/share/doc/telnet/README.telnet.old |
41 |
$(MAKE) -C telnetd INSTALLROOT=`pwd`/debian/telnetd \ |
42 |
MANDIR=/usr/share/man install |
43 |
cp telnetlogin/telnetlogin.8 debian/telnetd/usr/share/man/man8 |
44 |
cp telnetlogin/telnetlogin debian/telnetd/usr/lib |
45 |
|
46 |
# Build architecture-independent files here. |
47 |
binary-indep: build install |
48 |
# We have nothing to do by default. |
49 |
|
50 |
# Build architecture-dependent files here. |
51 |
binary-arch: build install |
52 |
# dh_testversion |
53 |
dh_testdir |
54 |
dh_testroot |
55 |
dh_installdocs |
56 |
dh_installexamples |
57 |
dh_installmenu |
58 |
# dh_installemacsen |
59 |
# dh_installinit |
60 |
dh_installcron |
61 |
# dh_installmanpages |
62 |
# dh_undocumented |
63 |
dh_installchangelogs ChangeLog |
64 |
dh_strip |
65 |
dh_compress |
66 |
dh_fixperms |
67 |
dh_installdeb |
68 |
dh_shlibdeps |
69 |
dh_gencontrol |
70 |
# dh_makeshlibs |
71 |
dh_md5sums |
72 |
dh_builddeb |
73 |
|
74 |
source diff: |
75 |
@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false |
76 |
|
77 |
binary: binary-indep binary-arch |
78 |
.PHONY: build clean binary-indep binary-arch binary |
|
|
79 |
++ netkit-telnet-0.17/debian/telnetd.dirs |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/telnetd.docs |
1 |
usr/lib |
|
|
2 |
usr/share/man/man5 |
3 |
usr/share/man/man8 |
4 |
usr/sbin |
|
|
5 |
++ netkit-telnet-0.17/debian/telnetd.docs |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/telnetd.postinst |
1 |
BUGS |
|
|
2 |
README |
|
|
3 |
++ netkit-telnet-0.17/debian/telnetd.postinst |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/telnetd.postrm |
1 |
#!/bin/sh -e |
|
|
2 |
# $Id: telnetd.postinst,v 1.15 2003/10/24 12:52:18 herbert Exp $ |
3 |
|
4 |
update_inetd_entry() { |
5 |
if [ $2 ]; then |
6 |
update-inetd --remove "$rootent" |
7 |
update-inetd --group STANDARD --add "$telnetdent" |
8 |
else |
9 |
update-inetd --remove "$telnetdent" |
10 |
update-inetd --group STANDARD --add "$rootent" |
11 |
fi |
12 |
} |
13 |
|
14 |
if ! id -u telnetd >/dev/null 2>&1; then |
15 |
if sg telnetd -c true 2>/dev/null; then |
16 |
adduser --quiet --system --ingroup telnetd --home / telnetd |
17 |
else |
18 |
adduser --quiet --system --group --home / telnetd |
19 |
fi |
20 |
fi |
21 |
adduser --quiet telnetd utmp |
22 |
|
23 |
if [ -z "$(dpkg-statoverride --list /usr/lib/telnetlogin)" ]; then |
24 |
chown root:telnetd /usr/lib/telnetlogin |
25 |
chmod 4754 /usr/lib/telnetlogin |
26 |
fi |
27 |
|
28 |
rootent="telnet stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd" |
29 |
telnetdent="telnet stream tcp nowait telnetd.telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd" |
30 |
|
31 |
if egrep -q "^(devpts /dev/pts|devfs /dev) " /proc/mounts; then |
32 |
devpts=yes |
33 |
else |
34 |
devpts= |
35 |
fi |
36 |
|
37 |
case "$1" in |
38 |
abort-upgrade | abort-deconfigure | abort-remove) |
39 |
update-inetd --enable telnet |
40 |
;; |
41 |
configure) |
42 |
if [ -z "$2" ] || dpkg --compare-versions "$2" lt 0.17-13; then |
43 |
update_inetd_entry "$2" $devpts |
44 |
else |
45 |
update-inetd --enable telnet |
46 |
fi |
47 |
;; |
48 |
*) |
49 |
printf "$0: incorrect arguments: $*\n" >&2 |
50 |
exit 1 |
51 |
;; |
52 |
esac |
53 |
|
54 |
#DEBHELPER# |
|
|
55 |
++ netkit-telnet-0.17/debian/telnetd.postrm |
Line 0
Link Here
|
0 |
-- netkit-telnet-0.17.orig/debian/telnetd.prerm |
1 |
#!/bin/sh -e |
|
|
2 |
# $Id: telnetd.postrm,v 1.10 2002/09/22 04:51:49 herbert Exp $ |
3 |
|
4 |
case "$1" in |
5 |
abort-install | abort-upgrade | upgrade | failed-upgrade) |
6 |
;; |
7 |
remove | disappear) |
8 |
home=~telnetd |
9 |
set +e |
10 |
userdel telnetd |
11 |
err=$? |
12 |
set -e |
13 |
case $err in |
14 |
0) |
15 |
if [ "$home" = /usr/lib/telnetd ]; then |
16 |
rmdir --ignore-fail-on-non-empty /usr/lib/telnetd |
17 |
fi |
18 |
;; |
19 |
6) |
20 |
;; |
21 |
*) |
22 |
exit $err |
23 |
;; |
24 |
esac |
25 |
|
26 |
set +e |
27 |
groupdel telnetd |
28 |
err=$? |
29 |
set -e |
30 |
case $err in |
31 |
0 | 6) |
32 |
;; |
33 |
*) |
34 |
exit $err |
35 |
;; |
36 |
esac |
37 |
;; |
38 |
purge) |
39 |
# If netbase is not installed, then we don't need to do the remove. |
40 |
if command -v update-inetd >/dev/null 2>&1; then |
41 |
update-inetd --remove "telnet .* /usr/sbin/in.telnetd" |
42 |
fi |
43 |
;; |
44 |
*) |
45 |
echo "$0: incorrect arguments: $*" >&2 |
46 |
exit 1 |
47 |
;; |
48 |
esac |
49 |
|
50 |
#DEBHELPER# |
51 |
|
52 |
exit 0 |
|
|
53 |
++ netkit-telnet-0.17/debian/telnetd.prerm |
Line 0
Link Here
|
|
|
1 |
#!/bin/sh -e |
2 |
# $Id: telnetd.prerm,v 1.3 2001/03/15 20:38:36 herbert Exp $ |
3 |
|
4 |
update-inetd --disable telnet |
5 |
|
6 |
#DEBHELPER# |