Newsgroups: comp.infosystems.gopher
Subject: Re: Unix client to auto-load after login: gopher (how?)
From: pmurray@watson.lib.muohio.edu (Peter Murray)
Date: 2 Sep 92 08:18:23 -0500
Distribution: comp
Organization: Miami University Libraries

P.C.Sutton@bradford.ac.uk (Paul Sutton) writes:
: On Fri, 21 Aug 1992, Dave Garaffa wrote:
: > Paul Lindner & The Gopher News Group,
: > Sorry if this is a dumb question (I am still very new to unix)... anyway I
: > would like to setup the unix gopher client in a similar fashion to the
: > client you have setup @ umn (ie: login: gopher will bring you directly
: > into the client) I know all unix's are *NOT* the same (I am running A/UX)
: > but could you point me in the right/general direction as to how to get my
: > system setup the same way? 
: 
: In a similar vein, does anyone have a `wrapper' for gopher for anonymous
: logins on a Unix (Sun) system? 
 
I've written a C wrapper for our public-access Gopher...It's included below.

: I what to set up an entry for gopher in our password file so that
: it can be used by anonymous telnet (and JANET X.25) callers; something
: like:
: 
: gopher::99:99:Anonymous:/gopher/anonbin/gopher/anonbin/gopherwrapper
: 
: where gopherwrapper is a program which:
:   - detects the terminal type of the called (if available) or
:     asks for a terminal type and sets it up

Doesn't do this yet...it assumes a VT100 terminal.  This is something I need
so if you or anyone else makes the modifications, please send it back.  :-)

:   - Sets up the environment for a secure gopher session (ie
:     sets the PAGER environment variable to be a secure version
:     of more, such as comes with gopher_tools)

Does this.  The restricted telnet is named 'rtelnet' (from Gopher_tools).
The PAGER is named 'rless', which is a modified-less program with the shell
and 'vi' escapes taken out, along with other things.  MAILER is set to 
'mush', which disallows tilde ('~') commands when reading the message from
standard input (removes a security risk).

:   - Sets up signals etc to make it secure

Couldn't think of any special signals.  If gopher client dies, the user dies.
Gopher doesn't understand SUSPEND, so there is no need to trap that.

:   - Invokes gopher -s

Does this...

:   - After gopher finishes, cleans up (specifically, if gopher fails
:     for any reason, the wrapper should ensure that the connection is
:     terminated securely)

See above.  Since this is a 'captive' account which does not run a shell,
when the Gopher client dies, the user is automatically logged out.
 

Here's the code (very simple, really...):

-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-

#include <stdio.h>

main()
{
	printf("Assuming a VT100 Terminal.\nStarting Gopher...\n");
	if (setenv("PATH","/usr/local/lib/gopher-data-olc2/bin:/usr/ucb/:/bin:/usr/bin:/usr/local/bin:/usr/etc",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (setenv("GOPHER_TELNET","/usr/local/bin/rtelnet",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (setenv("PAGER","/usr/local/bin/rless",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (setenv("LESS","-E -P -- %bb of %s characters (%pb\\%) [Press space to continue, 'q' to quit.] ",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (setenv("GOPHER_MAIL","/usr/local/bin/mush",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (setenv("TERM","vt100",1)==-1)
	{
		printf("Sorry, couldn't set the environment.  Contact the system manager.\n");
		sleep(5);
		exit(1);
	}
	if (execl("/usr/local/bin/gopher","gopher","-s","-t","Miami University Root Server","miamiu.acs.muohio.edu","70",(char *)0)==-1)
	{
		perror("startgopher: execl");
                sleep(5);
		exit(1);
	}
}

-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-

Hope this helps...


Peter
-- 
Peter Murray, Library Systems Manager        pmurray@watson.lib.muohio.edu
King Library Technical Support                      pemurray@miavx1.bitnet
Miami University, Oxford, Ohio                              W:513/529-2884