See ssh(1) for information about using ssh. --- loader/Makefile.am | 3 +- loader/linuxrc.s390 | 3 +- loader/loader.c | 6 - loader/loader.h | 3 +- loader/telnet.c | 273 -------------------------------------------------- loader/telnet.h | 40 -------- loader/telnetd.c | 256 ---------------------------------------------- loader/telnetd.h | 25 ----- scripts/upd-instroot | 3 +- 9 files changed, 5 insertions(+), 607 deletions(-) delete mode 100644 loader/telnet.c delete mode 100644 loader/telnet.h delete mode 100644 loader/telnetd.c delete mode 100644 loader/telnetd.h diff --git a/loader/Makefile.am b/loader/Makefile.am index 0d52fe7..a11b569 100644 --- a/loader/Makefile.am +++ b/loader/Makefile.am @@ -53,8 +53,7 @@ loader_SOURCES = loader.c copy.c moduleinfo.c loadermisc.c \ selinux.c mediacheck.c kickstart.c driverselect.c \ getparts.c dirbrowser.c fwloader.c ibft.c hardware.c \ method.c cdinstall.c hdinstall.c nfsinstall.c \ - urlinstall.c net.c urls.c telnet.c telnetd.c \ - rpmextract.c readvars.c + urlinstall.c net.c urls.c rpmextract.c readvars.c init_CFLAGS = $(COMMON_CFLAGS) $(GLIB_CFLAGS) init_LDADD = $(GLIB_LIBS) $(top_srcdir)/pyanaconda/isys/libisys.la diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390 index c272e5b..dc7f289 100644 --- a/loader/linuxrc.s390 +++ b/loader/linuxrc.s390 @@ -2963,7 +2963,8 @@ if [ -z "$testing" ]; then for i in $RESOLVDNS; do echo "nameserver $i"; done >> /etc/resolv.conf fi - # make sure we have an /etc/hosts file (originally required for telnetd) + # make sure we have an /etc/hosts file (originally required for telnetd, + # which is no longer included) if [ ! -z "$HOSTNAME" -a ! -z "$IPADDR" ]; then echo -e "$IPADDR\t$HOSTNAME $(echo $HOSTNAME | cut -d '.' -f 1)" >> /etc/hosts fi diff --git a/loader/loader.c b/loader/loader.c index 639c9c9..3ea8f79 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -89,7 +89,6 @@ #include "ibft.h" #include "net.h" -#include "telnetd.h" #include "readvars.h" #include <selinux/selinux.h> @@ -964,8 +963,6 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, flags |= LOADER_FLAGS_MEDIACHECK; } else if (!strcasecmp(k, "allowwireless")) { flags |= LOADER_FLAGS_ALLOW_WIRELESS; - } else if (!strcasecmp(k, "telnet")) { - flags |= LOADER_FLAGS_TELNETD; } else if (!strcasecmp(k, "noprobe")) { flags |= LOADER_FLAGS_NOPROBE; } else if (!strcasecmp(k, "text")) { @@ -2226,9 +2223,6 @@ int main(int argc, char ** argv) { kickstartNetworkUp(&loaderData, &iface); } - if (FL_TELNETD(flags)) - startTelnetd(&loaderData); - url = doLoaderMain(&loaderData, modInfo); /* unlink dirs and link to the ones in /mnt/runtime */ diff --git a/loader/loader.h b/loader/loader.h index 78d4821..1c54c52 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -46,7 +46,7 @@ /* #16 unused */ #define LOADER_FLAGS_NOSHELL (((uint64_t) 1) << 17) /* #18 unused */ -#define LOADER_FLAGS_TELNETD (((uint64_t) 1) << 19) +/* #19 unused */ #define LOADER_FLAGS_NOPASS (((uint64_t) 1) << 20) /* #21 unused */ #define LOADER_FLAGS_MEDIACHECK (((uint64_t) 1) << 22) @@ -84,7 +84,6 @@ #define FL_UPDATES(a) ((a) & LOADER_FLAGS_UPDATES) #define FL_KSFILE(a) ((a) & LOADER_FLAGS_KSFILE) #define FL_NOSHELL(a) ((a) & LOADER_FLAGS_NOSHELL) -#define FL_TELNETD(a) ((a) & LOADER_FLAGS_TELNETD) #define FL_NOPASS(a) ((a) & LOADER_FLAGS_NOPASS) #define FL_MEDIACHECK(a) ((a) & LOADER_FLAGS_MEDIACHECK) #define FL_ASKMETHOD(a) ((a) & LOADER_FLAGS_ASKMETHOD) diff --git a/loader/telnet.c b/loader/telnet.c deleted file mode 100644 index 9f9a0f5..0000000 --- a/loader/telnet.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * telnet.c -- basic telnet protocol handling for ttywatch - * - * Copyright (C) 2001 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Author(s): Michael K. Johnson <johnsonm@xxxxxxxxxx> - */ - -/* Shamelessly stolen from ttywatch -- oot */ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include "telnet.h" -#include "../pyanaconda/isys/log.h" - -#define IAC "\xff" -#define DONT "\xfe" -#define WONT "\xfc" -#define WILL "\xfb" -#define DO "\xfd" -#define SB "\xfa" -#define SE "\xf0" -#define ECHO "\x01" -#define SUPPRESS_GO_AHEAD "\x03" -#define TERMINAL_TYPE "\x18" -#define NAWS "\x1f" -#define LINEMODE "\x22" -#define NEWENVIRON "\x27" -#define MODE "\x01" - -/* Make a request. Not intended to be RFC-compatible, just enough - * to convince telnet clients to do what we want... To do this - * right, we would have to honestly negotiate, not speak blind. - * - * For now, assume all responses will be favorable and stripped - * out in telnet_process_input()... Sending it all in a single - * write makes it more efficient because it will all go out in a - * single packet, and the responses are more likely to all come - * back in a single packet (and thus, practically, a single read) - * too. - */ -void -telnet_negotiate(int socket, char ** term_type_ptr, int * heightPtr, - int * widthPtr) { - char ch; - int done = 0; - char * termType = NULL; - int termLength = 0, termAlloced = 0; - enum { ST_NONE, ST_TERMTYPE, ST_WINDOWSIZE } state; - char sizeBuf[4]; - int height = -1, width = -1; - char * sizePtr = sizeBuf; - char request[]= - IAC DONT ECHO - IAC WILL ECHO - IAC WILL NAWS - IAC WILL SUPPRESS_GO_AHEAD - IAC DO SUPPRESS_GO_AHEAD - IAC DONT NEWENVIRON - IAC WONT NEWENVIRON - IAC WONT LINEMODE - IAC DO NAWS - IAC SB TERMINAL_TYPE "\x01" IAC SE - ; - int ret; - - ret = write(socket, request, sizeof(request)-1); - - /* Read from the terminal until we get the terminal type. This will - do bad things if the client doesn't send the terminal type, but - those clients have existed for aeons (right?) */ - - do { - ret = read(socket, &ch, 1); - if (ch != '\xff') { - abort(); - } - - ret = read(socket, &ch, 1); /* command */ - - if (ch != '\xfa') { - ret = read(socket, &ch, 1); /* verb */ - continue; - } - - ret = read(socket, &ch, 1); /* suboption */ - if (ch == '\x18') { - state = ST_TERMTYPE; - ret = read(socket, &ch, 1); /* should be 0x0! */ - done = 1; - } else if (ch == '\x1f') { - state = ST_WINDOWSIZE; - } else { - state = ST_NONE;; - } - - ret = read(socket, &ch, 1); /* data */ - while (ch != '\xff') { - if (state == ST_TERMTYPE) { - if (termAlloced == termLength) { - termAlloced += 10; - termType = realloc(termType, termAlloced + 1); - } - - termType[termLength++] = tolower(ch); - } else if (state == ST_WINDOWSIZE) { - if ((sizePtr - sizeBuf) < (int)sizeof(sizeBuf)) - *sizePtr++ = ch; - } - - ret = read(socket, &ch, 1); /* data */ - } - - ret = read(socket, &ch, 1); /* should be a SE */ - - } while (!done); - - termType[termLength] = '\0'; - - if (sizePtr - sizeBuf == sizeof(sizeBuf)) { - width = (sizeBuf[0] << 8) + sizeBuf[1]; - height = (sizeBuf[2] << 8) + sizeBuf[3]; - } - - if (heightPtr) *heightPtr = height; - if (widthPtr) *widthPtr = width; - - if (term_type_ptr) *term_type_ptr = termType; -} - -int -telnet_process_input(telnet_state * ts, char *data, int len) { - char *s, *d; /* source, destination */ - -# if DEBUG_TELNET - printf("\nprinting packet:"); - for (s=data; s<data+len; s++) { - if (!((s-data)%10)) - printf("\n %03d: ", s-data); - printf("%02x ", *s & 0x000000FF); - } - printf("\n"); -# endif /* DEBUG_TELNET */ - - for (s=data, d=data; s<data+len; s++) { - switch (*ts) { - case TS_DATA: - if (*s == '\xff') { /* IAC */ - *ts = TS_IAC; - continue; - } -#if DEBUG_TELNET - printf("copying data element '%c'\n", *s); -#endif /* DEBUG_TELNET */ - if (s>d) { - *(d++) = *s; - } else { - d++; - } - break; - - case TS_IAC: - if (*s == '\xfa') { /* SB */ - *ts = TS_SB; - continue; - } - /* if not SB, skip IAC verb object */ -# if DEBUG_TELNET - printf("skipping verb/object (offset %d)...\n", s-data-1); -# endif /* DEBUG_TELNET */ - s += 1; - *ts = TS_DATA; - break; - - case TS_SB: -# if DEBUG_TELNET - printf("skipping SB (offset %d)...\n", s-data-1); -# endif /* DEBUG_TELNET */ - while (s < (data+(len-1))) { - if (*s == '\xff') { - break; /* fall through to TS_SB_IAC setting below */ - } else { - s++; - } - } - if (*s == '\xff') { - *ts = TS_SB_IAC; - } - break; - - case TS_SB_IAC: - if (*s == '\xf0') { /* SE */ -# if DEBUG_TELNET - printf("SE ends SB (offset %d)...\n", s-data-1); -# endif /* DEBUG_TELNET */ - *ts = TS_DATA; - } else { -# if DEBUG_TELNET - printf("IAC without SE in SB (offset %d)\n", s-data-1); -# endif /* DEBUG_TELNET */ - *ts = TS_SB; - } - break; - - default: - logMessage(WARNING, "unknown telnet state %d for data element %c", - *ts, *s); - *ts = TS_DATA; - break; - } - } - - /* calculate new length after copying data around */ - len = d - data; -#if DEBUG_TELNET - printf("returning len: %d of packet:", len); - for (s=data; s<data+len; s++) { - if (!((s-data)%10)) - printf("\n %03d: ", s-data); - printf("%02x ", *s & 0x000000FF); - } - printf("\n"); -#endif /* DEBUG_TELNET */ - - return len; -} - -/* The telnet protocol requires CR/NL instead of just NL - * We normally deal with Unix, which just uses NL, so we need to translate. - * - * It would be easy to go through line-by-line and write each line, but - * that would create more packet overhead by sending out one packet - * per line, and over things like slow PPP connections, that is painful. - * Therefore, instead, we create a modified copy of the data and write - * the whole modified copy at once. - */ -void -telnet_send_output(int sock, char *data, int len) { - char *s, *d; /* source, destination */ - char *buf; - int ret; - - buf = alloca((len*2)+1); /* max necessary size */ - - /* just may need to add CR before NL (but do not double existing CRs) */ - for (s=data, d=buf; d-buf<len; s++, d++) { - if ((*s == '\n') && (s == data || (*(s-1) != '\r'))) { - /* NL without preceding CR */ - *(d++) = '\r'; - len++; - } - *d = *s; - } - - /* now send it... */ - ret = write(sock, buf, len); -} diff --git a/loader/telnet.h b/loader/telnet.h deleted file mode 100644 index 5c34154..0000000 --- a/loader/telnet.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * telnet.h -- basic telnet protocol handling for ttywatch - * - * Copyright (C) 2001 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Author(s): Michael K. Johnson <johnsonm@xxxxxxxxxx> - */ - -#ifndef __TELNET_H__ -#define __TELNET_H__ - -typedef enum { - TS_DATA = 0, - TS_IAC, - TS_SB, - TS_SB_IAC, -} telnet_state; - -void -telnet_negotiate(int socket, char ** term_type_ptr, int * heightPtr, - int * widthPtr); -int -telnet_process_input(telnet_state * ts, char *data, int len); -void -telnet_send_output(int sock, char *data, int len); - -#endif /* __TELNET_H__ */ diff --git a/loader/telnetd.c b/loader/telnetd.c deleted file mode 100644 index e4730bb..0000000 --- a/loader/telnetd.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * telnetd.c - glue to tie telnet.c from ttywatch to the loader - * - * Copyright (C) 2002 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Author(s): Erik Troan <ewt@xxxxxxxxxx> - * Jeremy Katz <katzj@xxxxxxxxxx> - */ - -#include <arpa/inet.h> -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <netinet/in.h> -#include <newt.h> -#include <pty.h> -#include <stdlib.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/poll.h> -#include <sys/signal.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <unistd.h> - -#include "../pyanaconda/isys/log.h" - -#include "lang.h" -#include "loader.h" -#include "modules.h" -#include "net.h" -#include "telnet.h" -#include "windows.h" - -#ifndef IPPORT_TELNET -#define IPPORT_TELNET 23 -#endif - -/* boot flags */ -extern uint64_t flags; - -/* Forks, keeping the loader as our child (so we know when it dies). */ -int beTelnet(void) { - int sock; - int conn; - socklen_t addrLength; - pid_t child; - int i; - int masterFd, ttyFd; - struct sockaddr_in address; - char buf[4096]; - struct pollfd fds[3]; - telnet_state ts = TS_DATA; - char * termType; - int height, width; - struct winsize ws; - - if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - logMessage(ERROR, "socket: %s", strerror(errno)); - return -1; - } - - address.sin_family = AF_INET; - address.sin_port = htons(IPPORT_TELNET); - memset(&address.sin_addr, 0, sizeof(address.sin_addr)); - addrLength = sizeof(address); - - /* Let the kernel reuse the socket address. This lets us run - twice in a row, without waiting for the (ip, port) tuple - to time out. Makes testing much easier*/ - conn = 1; - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &conn, sizeof(conn)); - - bind(sock, (struct sockaddr *) &address, sizeof(address)); - listen(sock, 5); - - winStatus(45, 3, _("Telnet"), _("Waiting for telnet connection.")); - - if ((conn = accept(sock, (struct sockaddr *) &address, &addrLength)) < 0) { - newtWinMessage(_("Error"), _("OK"), "accept failed: %s", - strerror(errno)); - close(sock); - return -1; - } - - stopNewt(); - close(sock); - telnet_negotiate(conn, &termType, &height, &width); - -#ifdef DEBUG_TELNET - printf("got term type %s\n", termType); -#endif - - masterFd = open("/dev/ptmx", O_RDWR); - if (masterFd < 0) { - logMessage(CRITICAL, "cannot open /dev/ptmx"); - close(conn); - return -1; - } - - if (height != -1 && width != -1) { -#ifdef DEBUG_TELNET - printf("setting window size to %d x %d\n", width, height); -#endif - ws.ws_row = height; - ws.ws_col = width; - ioctl(masterFd, TIOCSWINSZ, &ws); - } - - - child = fork(); - - if (child) { -#ifndef DEBUG_TELNET - startNewt(); - winStatus(45, 3, _("Telnet"), _("Running anaconda via telnet.")); -#endif - - fds[0].events = POLLIN; - fds[0].fd = masterFd; - - fds[1].events = POLLIN; - fds[1].fd = conn; - - while ((i = poll(fds, 2, -1)) > 0) { - if (fds[0].revents) { - i = read(masterFd, buf, sizeof(buf)); -#ifdef DEBUG_TELNET - { - int j; - int row; - - for (row = 0; row < (i / 12) + 1; row++) { - printf("wrote:"); - - for (j = (row * 12); j < i && j < ((row + 1) * 12); j++) - printf(" 0x%2x", (unsigned char) buf[j]); - - printf("\nwrote:"); - - for (j = (row*12); j < i && j < ((row+1)*12); j++) { - if (isprint(buf[j])) - printf(" %c ", buf[j]); - else - printf(" "); - } - - printf("\n"); - } - } -#endif - /* child died */ - if (i < 0) - break; - - telnet_send_output(conn, buf, i); - } - - if (fds[1].revents) { - int ret; - i = read(conn, buf, sizeof(buf)); - - /* connection went away */ - if (!i) - break; - - i = telnet_process_input(&ts, buf, i); - ret = write(masterFd, buf, i); -#ifdef DEBUG_TELNET - { - int j; - - printf("got:"); - for (j = 0; j < i; j++) - printf(" 0x%x", (unsigned char) buf[j]); - printf("\n"); - } -#endif - } - } - - if (i < 0) { - logMessage(ERROR, "poll: %s", strerror(errno)); - } - -#ifndef DEBUG_TELNET - stopNewt(); -#endif - - kill(child, SIGTERM); - close(conn); - doExit(0); - } - - unlockpt(masterFd); - grantpt(masterFd); - ttyFd = open(ptsname(masterFd), O_RDWR); - close(masterFd); - setsid(); - close(0); - close(1); - close(2); - - if (ttyFd != 0) { - dup2(ttyFd, 0); - close(ttyFd); - } - - dup2(0, 1); - dup2(0, 2); - - /* brand new tty! */ - setenv("TERM", termType, 1); - - startNewt(); - - return 0; -} - -void startTelnetd(struct loaderData_s * loaderData) { - char *ipaddr = NULL; - iface_t iface; - - iface_init_iface_t(&iface); - - if (kickstartNetworkUp(loaderData, &iface)) { - logMessage(ERROR, "unable to bring up network"); - return; - } - - ipaddr = iface_ip2str(iface.device, AF_INET); - if (ipaddr == NULL) { - logMessage(ERROR, "%s (%d): no IP address found for %s", - __func__, __LINE__, iface.device); - return; - } - - logMessage(INFO, "going to beTelnet for %s", ipaddr); - if (!beTelnet()) - flags |= LOADER_FLAGS_TEXT | LOADER_FLAGS_NOSHELL; - - return; -} diff --git a/loader/telnetd.h b/loader/telnetd.h deleted file mode 100644 index fedb0fa..0000000 --- a/loader/telnetd.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * telnetd.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef TELNETD_H -#define TELNETD_H - -void startTelnetd(struct loaderData_s * loaderData); - -#endif diff --git a/scripts/upd-instroot b/scripts/upd-instroot index ebb01a6..97a0e62 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -198,7 +198,7 @@ PACKAGES="GConf2 NetworkManager NetworkManager-gnome ORBit2 acl anaconda specspo sqlite startup-notification strace synaptics system-config-date system-config-keyboard ${brandpkgname}-logos ${brandpkgname}-release - sysvinit-tools taipeifonts tcp_wrappers tcp_wrappers-libs telnet + sysvinit-tools taipeifonts tcp_wrappers tcp_wrappers-libs tigervnc-server tigervnc-server-module tzdata udev un-core-dotum-fonts urw-fonts usbutils util-linux-ng vconfig vlgothic-fonts vim-minimal @@ -581,7 +581,6 @@ usr/bin/syslinux usr/bin/tac usr/bin/tail usr/bin/tee -usr/bin/telnet usr/bin/tilo usr/bin/top usr/bin/wc -- 1.7.1.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list