5748439 [rkeene@sledge /home/rkeene/devel/old/rutil_tcpcgi-0.1.17]$ cat -n telnetd.c
 1 /*
 2     telnetd.c -- Small telnet daemon that gives a shell on a port.
 3     Copyright (C) 2003  Roy Keene
 4 
 5     This program is free software; you can redistribute it and/or modify
 6     it under the terms of the GNU General Public License as published by
 7     the Free Software Foundation; either version 2 of the License, or
 8     (at your option) any later version.
 9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19     email: tcpcgi@rkeene.org
20 
21 */
22 #include <sys/socket.h>
23 #include <sys/types.h>
24 #include <unistd.h>
25 #include <stdlib.h>
26 
27 #include "tcpnet.h"
28 
29 int main(void) {
30     int masterfd, clientfd;
31 
32     while ((masterfd=createlisten(5011, 1, SOCK_STREAM))<0) { sleep(1); }
33     while (1) {
34         clientfd=accept(masterfd, NULL, NULL);
35         dup2(clientfd, STDOUT_FILENO);
36         dup2(clientfd, STDERR_FILENO);
37         dup2(clientfd, STDIN_FILENO);
38         system("/usr/sbin/in.telnetd -h -L /bin/bash -n");
39     }
40     return(0);
41 }
5748440 [rkeene@sledge /home/rkeene/devel/old/rutil_tcpcgi-0.1.17]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2004-01-01 16:22:42