From montanaro@ausable.crd.ge.com Mon Feb 28 12:14:42 EST 1994 Article: 6098 of comp.os.linux.development Newsgroups: comp.os.linux.development,comp.os.linux.help Path: bigblue.oit.unc.edu!concert!corpgate!news.utdallas.edu!wupost!sdd.hp.com!saimiri.primate.wisc.edu!news.crd.ge.com!nntp!montnaro From: montnaro@spyder.crd.ge.com (Skip Montanaro) Subject: SOCKS patches for term 1.11 (enables Mosaic+term from behind firewall) To: socks@syl.dl.nec.com Message-ID: Sender: usenet@crdnns.crd.ge.com (USENET News System) Nntp-Posting-Host: spyder.crd.ge.com Reply-To: montanaro@ausable.crd.ge.com (Skip Montanaro) Organization: GE Corporate Research & Development, Schenectady, NY Date: Mon, 28 Feb 1994 04:22:03 GMT Lines: 224 Xref: bigblue.oit.unc.edu comp.os.linux.development:6098 comp.os.linux.help:21788 A couple days ago, I posted a note to comp.os.linux.help asking how I could use Mosaic+term when my remote term program was behind a firewall. Using Mosaic+term, I could retrieve stuff on the local net at work (like my home page), but couldn't get to external hosts. At our site, we run the ever impressive SOCKS daemon and clients (mostly Mosaic, ftp, and telnet), so I SOCKSified term 1.11 (using SOCKS 4.1). Worked like a charm, except for ftp. The patches are attached to this note for anyone interested. They've only been tested in the context I'm interested in - running Mosaic+term from home to a remote term behind a firewall. I believe ftp fails because Mosaic+term does not set PASV mode for ftp transfers. Term knows nothing about any ftp servers wanting to establish data connections on occasion, so data never gets transferred. Attempts to access anonymous ftp sites just spin Mosaic's globe. ---------- *** Makefile Sun Feb 27 22:37:31 1994 --- Makefile~ Sat Jan 8 01:23:32 1994 *************** *** 16,22 **** DEBUGFLAGS= $(DEBUG) -O - SOCKSFLAG = -DSOCKS - SOCKSLIB = -L/usr/local/lib -lsocks -lresolv - # # action --- 16,19 ---- *************** *** 24,28 **** # -DLOGIN_SHELL causes trsh to start a login shell by default ! CFLAGS= $(DEBUGFLAGS) -DLOGIN_SHELL $(OSFLAGS) $(SOCKSFLAG) LINKFLAGS=-O $(OSLINK) --- 21,25 ---- # -DLOGIN_SHELL causes trsh to start a login shell by default ! CFLAGS= $(DEBUGFLAGS) -DLOGIN_SHELL $(OSFLAGS) LINKFLAGS=-O $(OSLINK) *************** *** 79,83 **** sun: ! $(MAKE) AR="ar rc" RANLIB=ranlib LIBS="$(SOCKSLIB)" $(DO) sgi: --- 76,80 ---- sun: ! $(MAKE) AR="ar rc" RANLIB=ranlib $(DO) sgi: *************** *** 155,159 **** tupload: $(UPLOADOBJS) ! $(CC) $(LINKFLAGS) -o tupload $(UPLOADOBJS) $(LIBS) $(SOCKSLIB) tredir: $(REDIROBJS) --- 152,156 ---- tupload: $(UPLOADOBJS) ! $(CC) $(LINKFLAGS) -o tupload $(UPLOADOBJS) $(LIBS) tredir: $(REDIROBJS) *** connect.c Sun Feb 27 22:31:04 1994 --- connect.c~ Thu Jan 6 00:34:02 1994 *************** *** 123,132 **** } c = &cons[i]; - #ifdef SOCKS - c->client = Raccept(svs[loop], (struct sockaddr *) &dum, &sdum); - #else c->client = accept(svs[loop], (struct sockaddr *) &dum, &sdum); - #endif - if ((c->server = get_server(loop)) <0) { --- 123,127 ---- *** link.c Sun Feb 27 22:31:02 1994 --- link.c~ Tue Jan 4 07:11:56 1994 *************** *** 387,395 **** } /* try the actual accept(). */ - #ifdef SOCKS - s = Raccept(clients[s].fd , (struct sockaddr *) &dummy, &din); - #else s = accept(clients[s].fd , (struct sockaddr *) &dummy, &din); - #endif if (s < 0) { ret_fail(cl, local, 1, "Accept failed"); --- 387,391 ---- *************** *** 484,494 **** atoi(portname) ); - #ifdef SOCKS - if (Rconnect(s,(struct sockaddr *)&addr,sizeof(struct - sockaddr_in))<0) { - #else if (connect(s,(struct sockaddr *)&addr,sizeof(struct sockaddr_in))<0) { - #endif ret_fail(cl,local, 1, "connect() failed"); perror ("connect"); --- 480,485 ---- *************** *** 646,654 **** } k=sizeof(addr); - #ifdef SOCKS - if (Rgetsockname(s, &addr, &k) < 0) { - #else if (getsockname(s, &addr, &k) < 0) { - #endif ret_fail(cl, local, 1, "getsockname() failed"); DEBUG_FP(stderr, "%s:getsockname failed\n", term_server); --- 637,641 ---- *** main.c Sun Feb 27 22:27:51 1994 --- main.c~ Sat Jan 8 01:09:36 1994 *************** *** 328,333 **** fprintf(stderr, "Term version: %s\r\n", VERSION); - SOCKSinit(argv[0]); - /* initalize character escapeing. */ for (i = 0; i < 256;i++) { --- 328,331 ---- *************** *** 714,722 **** struct sockaddr_un dummy; int din = sizeof(dummy); - #ifdef SOCKS - i = Raccept(socket , (struct sockaddr *) &dummy, &din); - #else i = accept(socket , (struct sockaddr *) &dummy, &din); - #endif if (i >= 0) { /* a new client */ j = new_client(); --- 712,716 ---- *** redir.c Sun Feb 27 22:38:59 1994 --- redir.c~ Thu Jan 6 00:39:49 1994 *************** *** 44,50 **** int first, i; int svs[MAXREDIR]; - - SOCKSinit(argv[0]); - signal(SIGPIPE, SIG_IGN); first = client_options(argc, argv,"",NULL); --- 44,47 ---- *** socket.c Sun Feb 27 22:25:23 1994 --- socket.c~ Tue Oct 26 09:22:44 1993 *************** *** 56,66 **** /* this way.. We try a maximum of 100 */ /* times... */ - #ifdef SOCKS - while (Rbind(s, (struct sockaddr * ) &sin, - sizeof(sin), sin.sin_addr.s_addr) < 0) { /* while an error.. */ - #else while (bind(s, (struct sockaddr * ) &sin, sizeof(sin)) < 0) { /* while an error.. */ - #endif if (errno != EADDRINUSE) { /* if it wasn't in use */ close(s); --- 56,61 ---- *************** *** 71,79 **** } - #ifdef SOCKS - if (Rlisten(s, 5) == -1) { /* If we can't listen... */ - #else if (listen(s, 5) == -1) { /* If we can't listen... */ - #endif perror("listen"); /* then just dump. We can't handle */ /* errors here. */ --- 66,70 ---- *** tmon.c Sun Feb 27 22:39:27 1994 --- tmon.c~ Thu Feb 11 20:13:49 1993 *************** *** 139,144 **** struct tms Tbuf; - SOCKSinit(argv[0]); - timeout.tv_sec = 0; timeout.tv_usec = 0; --- 139,142 ---- *** trshell.c Sun Feb 27 22:38:12 1994 --- trshell.c~ Tue Mar 9 00:12:22 1993 *************** *** 86,91 **** char * f; - SOCKSinit(argv[0]); - priority = 2; --- 86,89 ---- *** xconn.c Sun Feb 27 22:38:33 1994 --- xconn.c~ Sat Jan 8 01:04:20 1994 *************** *** 37,42 **** #endif - SOCKSinit(argv[0]); - (void) client_options(argc, argv,"",NULL); --- 37,40 ---- ---------- -- Skip (montanaro@crd.ge.com)