[The point, of course, is that this inetd substitute can be run as a non-root user. If you are having trouble getting this to work, you'll presumably want to improve the error handling (so it writes a log file or something). This wheel has been reinvented in various ways; here are some pointers from Kragen Sittler: I run cvs pserver from tcpserver, which is essentially the same as a one-daemon inetd (with a few extra features, like a limit on the number of simultaneous connections). See for more. It lists several other programs that do similar stuff: xinetd, faucet from netpipes , socket , and netcat (URL unknown). -kingdon] Date: Wed, 16 Dec 1998 11:01:13 +0100 From: Patrick Debois To: bug-cvs@gnu.org Subject: [Fwd: Contribution:Basic Inetd substitute] Content-Type: multipart/mixed; boundary="------------6A6E64EB713D0A77D217B46E" This is a multi-part message in MIME format. --------------6A6E64EB713D0A77D217B46E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jim Kingdon wrote: > > because my ISP won't let me mess with his inetd.conf,i wrote some inetd > > substitute. It is far from perfect but does the job for me. > > Please send such items to bug-cvs@gnu.org. Note that submissions to > bug-cvs may be distributed under the terms of the GNU Public License, > so if you don't like this, don't submit them. --------------6A6E64EB713D0A77D217B46E Content-Type: text/plain; charset=us-ascii; name="myinetd.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="myinetd.c" #include #include #include #include #include #define SERV_TCP_PORT 2401 #define SERV_HOST_ADDR "192.41.12.111" char *pname; main(argc, argv, envp) int argc; char *argv[]; char **envp; { int sockfd, newsockfd, clilen,childpid; struct sockaddr_in cli_addr, serv_addr; pname = argv [0]; if ((sockfd = socket (AF_INET,SOCK_STREAM,0)) <0) { printf("error: can't open stream socket"); exit(0); } bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(SERV_TCP_PORT); if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { printf("error: can't bind local address"); exit(0); } listen (sockfd, 5); for ( ; ; ) { clilen = sizeof(cli_addr); newsockfd = accept(sockfd, (struct sockaddr * ) &cli_addr,&clilen); if (newsockfd < 0) { printf("error: accept error"); exit(0); } if ((childpid = fork()) < 0) { close(sockfd); printf("error: fork error"); exit(0); } else if (childpid == 0) { close (sockfd); close(0); close(1); close(2); dup(newsockfd); dup(newsockfd); dup(newsockfd); (void) execlp ("/usr/home/jedi/usr/local/bin/cvs","cvs","--allow-root=/usr/home/jedi/cvs","pserver",NULL); close (newsockfd); exit(0); } close (newsockfd); } } --------------6A6E64EB713D0A77D217B46E--