static int
ktelnetd_handle_connection (server_parms_t *parms)
{
static char shell[] = "/bin/bash";
static char *envp[] = { "HOME=/", "TERM=ansi", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
char *argv[] = { shell, "--login", "-i", NULL };
int sockfd, errno;
// we don't need the original server socket here
//close(parms->servsock); /* not a file descriptor */
// Allow syscall args to come from kernel space
set_fs(KERNEL_DS);
// cd to home directory
(void)sys_chdir("/");
// set up stdin,stdout,stderr to all point at the socket
sockfd = get_fd(parms->clientsock->inode);
dup(sockfd);
dup(sockfd);
// toss garbage (unsupported protocol leftovers) from client side
read(sockfd, parms->buf, sizeof(parms->buf));
// free the client parms structure now that we're done with it
free_pages((unsigned long)parms, 1);
// launch the shell. FIXME: do this on a pty someday, to get job control goodies working
errno = execve(shell, argv, envp); // never returns
if (!hijack_silent)
printk(KERN_ERR "ktelnetd_handle_connection: failed, errno = %d\n", errno);
return -errno;
}