-
-#if 0
- case EMU_RLOGIN:
- /*
- * Rlogin emulation
- * First we accumulate all the initial option negotiation,
- * then fork_exec() rlogin according to the options
- */
- {
- int i, i2, n;
- char *ptr;
- char args[100];
- char term[100];
- struct sbuf *so_snd = &so->so_snd;
- struct sbuf *so_rcv = &so->so_rcv;
-
- /* First check if they have a priveladged port, or too much data has arrived */
- if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
- (m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
- memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
- so_snd->sb_wptr += 18;
- so_snd->sb_cc += 18;
- tcp_sockclosed(sototcpcb(so));
- m_free(m);
- return 0;
- }
-
- /* Append the current data */
- memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
- so_rcv->sb_wptr += m->m_len;
- so_rcv->sb_rptr += m->m_len;
- m_free(m);
-
- /*
- * Check if we have all the initial options,
- * and build argument list to rlogin while we're here
- */
- n = 0;
- ptr = so_rcv->sb_data;
- args[0] = 0;
- term[0] = 0;
- while (ptr < so_rcv->sb_wptr) {
- if (*ptr++ == 0) {
- n++;
- if (n == 2) {
- sprintf(args, "rlogin -l %s %s",
- ptr, inet_ntoa(so->so_faddr));
- } else if (n == 3) {
- i2 = so_rcv->sb_wptr - ptr;
- for (i = 0; i < i2; i++) {
- if (ptr[i] == '/') {
- ptr[i] = 0;
-#ifdef HAVE_SETENV
- sprintf(term, "%s", ptr);
-#else
- sprintf(term, "TERM=%s", ptr);
-#endif
- ptr[i] = '/';
- break;
- }
- }
- }
- }
- }
-
- if (n != 4)
- return 0;
-
- /* We have it, set our term variable and fork_exec() */
-#ifdef HAVE_SETENV
- setenv("TERM", term, 1);
-#else
- putenv(term);
-#endif
- fork_exec(so, args, 2);
- term[0] = 0;
- so->so_emu = 0;
-
- /* And finally, send the client a 0 character */
- so_snd->sb_wptr[0] = 0;
- so_snd->sb_wptr++;
- so_snd->sb_cc++;
-
- return 0;
- }
-
- case EMU_RSH:
- /*
- * rsh emulation
- * First we accumulate all the initial option negotiation,
- * then rsh_exec() rsh according to the options
- */
- {
- int n;
- char *ptr;
- char *user;
- char *args;
- struct sbuf *so_snd = &so->so_snd;
- struct sbuf *so_rcv = &so->so_rcv;
-
- /* First check if they have a priveladged port, or too much data has arrived */
- if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
- (m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
- memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
- so_snd->sb_wptr += 18;
- so_snd->sb_cc += 18;
- tcp_sockclosed(sototcpcb(so));
- m_free(m);
- return 0;
- }
-
- /* Append the current data */
- memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
- so_rcv->sb_wptr += m->m_len;
- so_rcv->sb_rptr += m->m_len;
- m_free(m);
-
- /*
- * Check if we have all the initial options,
- * and build argument list to rlogin while we're here
- */
- n = 0;
- ptr = so_rcv->sb_data;
- user="";
- args="";
- if (so->extra==NULL) {
- struct socket *ns;
- struct tcpcb* tp;
- int port=atoi(ptr);
- if (port <= 0) return 0;
- if (port > 1023 || port < 512) {
- memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
- so_snd->sb_wptr += 18;
- so_snd->sb_cc += 18;
- tcp_sockclosed(sototcpcb(so));
- return 0;
- }
- if ((ns=socreate()) == NULL)
- return 0;
- if (tcp_attach(ns)<0) {
- free(ns);
- return 0;
- }
-
- ns->so_laddr=so->so_laddr;
- ns->so_lport=htons(port);
-
- (void) tcp_mss(sototcpcb(ns), 0);