[comp.unix.xenix] Supporting dial-in and out modem under SCO Xenix

paul@csnz.nz (Paul Gillingwater) (07/27/88)

My original posting requested information on supporting a modem for
both dial-in and dial-out use under SCO Xenix.  I would like to thank 
everyone who took the time out to reply, especially Sid for the script
he submitted.

Here is my summary of the replies I received:

(Several replies follow)
----------------------------------------------------------------------
From: tkevans@fallst.uucp (Tim Evans)

My SCO Xenix 386 (Version 2.2) manuals are very specific about NOT using
tty1a (little a) for modems; they insist on using tty1A (BIG A) since
little-a is a serial port for DIRECT control (not modem control)

Again, my Xenix has 'ungetty' (note the 'n' not a 'u'), which does
exactly what you're looking for.

Check your documentation, especially the separate section on UUCP in
the USER GUIDE.

On 'pcomm' I understand Emett Gray (the author) is working on a new
release that will properly deal with 80286 architecture.  Mail to
him:  egray@fthood

----------------------------------------------------------------------
From: rosso@uunet.UU.NET (Ross Oliver)
Organization: SCO Technical Support

If you have SCO XENIX 2.2.0 or later, shared dialin/dialout is
already built into the operating system.  cu/uucp will automatically
suspend any getty running on the shared port, and restart it
when the call is complete.  See the "Using Peripheral Devices"
chapter of the Operations Guide for more information.

----------------------------------------------------------------------
Apparently-From: killer!wpg!rdgame!dick

The latest release i.e. 2.1.1 includes uugetty! If the modem control
port (i.e. tty1A) is used then both cu and uucp will ungetty the login
port and re-getty the port when the session is over.

Pcomm source is on the net. I've seen but don't know just where. If
you can't find it, E-mail me and I'll try to find it for you.

----------------------------------------------------------------------
Robert E. Seastrom              101010101010 <== 12 bit machines forever!

> What I would like is a version of uugetty for SCO/Xenix, that can
> recognise when a modem port is being used, and not issue any login
> prompt to that port.  Can someone tell me if such a thing exists?

It sure does.  My release (2.2.1) has it; if you want it, i might be able to
mail it (on a disk, let's not waste net resources :-)) to you...  Let me know.

                                    ---R.E. Seastrom
----------------------------------------------------------------------
S. L. Millions                                            ..!uunet!mcl!stacy 

What version of Xenix do you have? In 2.2 SCO introduced a command
called ungetty (in /usr/lib/uucp) that will suspend the getty running
on a port. It is called fromt the dialer code, so if you just say

cu -s speed phone_number
......
~.

it will suspend the getty, dial out and when you are done will restart
the getty. Occasionaly you will see the restart fail. You can check for
this with the who command, if you see DIALOUT as being logged in on your
modem it failed. The command /usr/lib/uucp/ungetty -r /dev/??? will restore
the line (my experience has been less than 1% failure).

Hope this helps.

-stacy
----------------------------------------------------------------------
Peter Jeremy (VK2PJ)         peter%stca77@stcns3.stc.oz

>Hi - we'd like to provide remote support to our SCO/Xenix sites via
>modem, yet still allow them to call out to access databases.  Now
>this can be done with something like
>
>disable tty1a
>cu modem
>.... session
>~.
>enable tty1a

Or, it can be done simply by issuing a 'cu'.  SCO Xenix includes ungetty
as part of the uucp package and if you attempt to dialout on a line (either
using UUCP or cu) that is enabled for login, the getty will be automatically
inhibited and re-enabled.

I use this all the time with no problems. (At least under 2.2, it may not
have been part of 2.1).
----------------------------------------------------------------------

	I read your message on the net, and thought I would send you the
following information.  It is a product we have just released and it
seems that it would do what you want.

	Alternately, if you wait for SCO Xenix version 2.3 (later this
summer) it will have a full implementation of HDB UUCP.  However, the
HDB uugetty will not have the security features our product has.

Jonathan Bayer
Intelligent Software Products, Inc.
19 Virginia Ave.
Rockville Centre, NY   11570
uunet!ispi!jbayer
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[Press release deleted to reduce net exposure to commercial stuff...]
	    SUBJECT: `THE SENTINEL'...          CONTACT:  SAM BAYER, PRES.
		     SECURITY SOFTWARE          TEL. #:   (516) 766-2867
		     FOR XENIX/UNIX
		     OPERATING SYSTEM           DATE: JULY 11, 1988

----------------------------------------------------------------------

From: scowles%esd@lll-lcc.uucp
Subject: modem dualities...

paul,  the following comprises the solution i've chosen for my
xenix system for modem duality.  i've written front ends to the
communications packages (kermit, cu, uucico, logins) to control
the enabling/disabling of the getty's and setting up the lock
files.

users coming in are processed by /etc/profile or /etc/cshrc.
uucp coming in and going out is preprocessed by the
/usr/lib/uucp/uucico onionskin.  likewise, kermit is caught by
/bin/kermit.  outgoing cu (limited to root use), uses the
/bin/cu onionskin.

it's only one way to handle the problem.  so far, i've had no
difficulties.

sid cowles
======================================================================
s cowles                         att:  +1 415 423 0929
lawrence livermore national lab  uucp: {ihnp4,rutgers}!lll-lcc!scowles
environmental sciences division  internet: scowles@lll-lcc.llnl.gov
p. o. box 5507; L-524
livermore, california  94550
====/bin/cu:============================================================
:
#!/bin/sh
# cu:  cu onionskin for utilizing modem line for dial in and out
# sccsid:  @(#)cu	1.6	16:42:56	88/06/14

# USER SPECIFIED PARAMETERS:
cu=/bin/cu.2_2    # path for renamed cu executable
cp=2              # com port specification

# SCRIPT SPECIFIED PARAMETERS:
delay=20 # dis(en)able(C) advises waits between disable and enable calls
modout=tty${cp}a
modin=tty${cp}A
lockroot=/usr/spool/uucp/LCK..
lockfile=${lockroot}${modout}

# filter the line request, if present:
set -- `getopt s:l:a:hoe $*` ||
	{ echo "cu: -s{3|12|24}00 dir|#";exit 1; }
opts=
for parm in $*; do
	case $parm in
		-l) # regulate outgoing comport request
			opts="$opts $1$modemout"; shift 2;;
		-a) # regulate outgoing comport request
			opts="$opts $1$modemout"; shift 2;;
		-s) # speed is 2 args
			opts="$opts $1$2"; shift 2;;
		-h|-o|-e) opts="$opts $1"; shift;;
		--) #
			shift; break;;
	esac
done

# check if user can dis(en)able tty lines:
user=`who am i|awk '{print $1}'`
[ "$user" != "root" ] && { echo "must be root to invoke.";exit 1; }
# check current usage of outgoing modem line:
[ -f $lockfile ] && { echo "$modout in use.";exit 1; }

# invoke cu:
trap "enable $modin;rm -f $lockfile;exit 1" 1 2 3 13 15
# if using cu version 2.2:
{ touch $lockfile;disable $modin;sleep $delay;rm -f $lockfile; } > \
	/dev/null 2>&1
# if using cu version 2.1.3:
# { sleep 4;touch $lockfile; } &
$cu $opts $@
# if using cu version 2.1.3:
# { enable $modin;sleep $delay;rm -f $lockfile; } > /dev/null 2>&1
# if using cu version 2.2:
{ touch $lockfile;enable $modin;sleep $delay;rm -f $lockfile; } > \
	/dev/null 2>&1
====/bin/kermit:========================================================
:
#!/bin/sh
# kermit:  kermit onionskin for utilizing modem line for dial in
#          and out before kermit or for kermit service on an
#          incoming line.
# sccsid:  @(#)kermit	1.5	16:43:03	88/06/14

# USER SPECIFIED PARAMETERS:
kermit=/u/scowles/bin/kermit.xen  # path for renamed kermit executable
cp=2                              # com port specification

# SCRIPT SPECIFIED PARAMETERS:
delay=20 # dis(en)able(C) advises waits between disable and enable calls
lockroot=/usr/spool/uucp/LCK..

# who invoked kermit from which device:
tty=`who am i|awk '{print $2}'`>/dev/null 2>&1
port=`expr substr "$tty" 4 1`
mc=`expr substr "$tty" 5 1`
if   [ "$port"    = "s"  ]; then { IO=out;port=$cp; } # from console
elif [ "$port"    = "0"  ]; then { IO=out;port=$cp; } # from tty0[1-9]
elif [ "$port$mc" = "10" ]; then { IO=out;port=$cp; } # from tty10
elif [ "$mc"      = "A"  ]; then { IO=in;  }          # from getty
else { echo "unexpected port problem in kermit.";exit 1; }
fi

# needed parameters, after incoming port determination:
modout=tty${port}a
modin=tty${port}A
lockfile=${lockroot}${modout}

# is user legal and/or is line in use:
if [ "$IO" = "out" ]; then
	# check current line usage:
	[ -f $lockfile ] && { echo "$modout in use.";exit 1; }
	# check user legality:
	user=`who am i|awk '{print $1}'`
	[ "$user" != "root" ] &&
		{ echo "must be root to invoke.";exit 1; }
fi

if [ "$IO" = "in" ]; then
	# incoming kermit:
	trap "cd $HOME;mv ._kermrc .kermrc;exit 1" 1 2 3 15
	(cd $HOME;mv .kermrc ._kermrc)
	$kermit $@
	(cd $HOME;mv ._kermrc .kermrc)
else
	# outgoing kermit:
	trap "enable $modin;exit 1" 1 2 3 15
	{ touch $lockfile;disable $modin;sleep $delay;rm -f $lockfile; } > \
		/dev/null 2>&1
	$kermit $@
	{ touch $lockfile;enable $modin;sleep $delay;rm -f $lockfile; } > \
		/dev/null 2>&1
fi
====/usr/lib/uucp/uucico:===============================================
:
#!/bin/sh
# uucico:  uucico onionskin for utilizing modem line for dial in
#          and out
# sccsid:  %W%	%U%	%E%

# USER SPECIFIED PARAMETERS:
uucico=/usr/lib/uucp/uucico.2_2  # path for renamed uucico executable
cp=2                             # com port specification

# SCRIPT SPECIFIED PARAMETERS:
delay=20 # dis(en)able(C) advises waits between disable and enable calls
lockroot=/usr/spool/uucp/LCK..

# who invoked uucico from which device:
tty=`who am i 2>/dev/null|awk '{print $2}'`
[ -z "$tty" ] && port="" ||
	{ port=`expr substr "$tty" 4 1`;mc=`expr substr "$tty" 5 1`; }
if   [ "$port"    = ""   ]; then { IO=uucp;port=$cp; } # from cron
elif [ "$port"    = "s"  ]; then { IO=user; }          # from console
elif [ "$port"    = "0"  ]; then { IO=user; }          # from tty0[1-9]
elif [ "$port$mc" = "10" ]; then { IO=user; }          # from tty10
elif [ "$mc"      = "A"  ]; then { IO=in; }            # from getty
else { echo "unexpected port problem in uucico.";exit 1; }
fi

# needed parameters, after incoming port determination:
modout=tty${port}a
modin=tty${port}A
lockfile=${lockroot}${modout}

# is user allowed (can he dis(en)able the tty line?):
if [ "$IO" = "user" ]; then
	user=`who am i|awk '{print $1}'`
	[ "$user" != "root" ] &&
		{ echo "must be root or uucp to invoke.";exit 1; }
fi

if [ "$IO" = "in" ]; then
	# invoke for incoming uucp:
	touch $lockfile; chmod +w $lockfile
	trap "rm -f $lockfile;exit 1" 1 2 3 15
	$uucico
	rm -f $lockfile
else
	# invoke for outgoing uucp:
	[ -f $lockfile ] && {
		echo "uucico:  $modout in use.";exit 1; }
	trap "enable $modin;rm -f $lockfile;exit 1" 1 2 3 15
	{ touch $lockfile;disable $modin;sleep $delay;rm -f $lockfile; }
	$uucico $@
	{ touch $lockfile;enable $modin;sleep $delay;rm -f $lockfile; }
fi
====/etc/profile:=======================================================
:
# /etc/profile file for shell and shellV accounts.
# Commands here are executed for each login sh or shV.
#
TZ=PST8PDT
HZ=50
export TZ HZ

# local modifications:
stty -hupcl
[ "$0" = "-shV" ] && SHELL=/bin/shV || SHELL=/bin/sh
export SHELL
MAILCHECK=120
export MAILCHECK
lockroot=/usr/spool/uucp/LCK..

# Set up the terminal:  (xenix)
tty=`who am i|awk '{print $2}'`
port=`expr substr "$tty" 4 1`
mc=`expr substr "$tty" 5 1`
if [ "$mc" = "A" ]; then
	lockfile=${lockroot}tty${port}a
	touch $lockfile
	chmod +w $lockfile
fi

# Set up the logout conditions:
if [ "$0" = "-shV" ]; then
	trap "\
		cd
		clear
		echo 'bye\n'
		cat calendar
		tty=`who am i|awk '{print $2}'`
		mc=`expr substr "$tty" 5 1`
		[ "$mc" = "A" ] && {
			cat .exrc.base .exrc.ansi > .exrc
			rm -f $lockfile
		}
		exit 0
	" 0
else
	trap "cd;\
				clear;\
				echo 'bye\n';\
				cat calendar;\
				rm -f $lockfile;\
				exit 0;\
				" 0
fi
====/etc/cshrc:=========================================================
#
# /etc/cshrc file for C-Shell account.
# Commands here are executed for each login csh.
#
setenv TZ PST8PDT
setenv HZ 50
setenv SHELL /bin/csh
setenv MAIL /usr/spool/mail/`logname`

# local modifications:
stty -hupcl
set lockroot=/usr/spool/uucp/LCK..
set tty=`who am i|awk '{print $2}'`
set port=`expr substr "$tty" 4 1`
set mc=`expr substr "$tty" 5 1`
if("$mc" != "A") then
	unset lockroot tty port mc
	exit
endif
if( -e ~/.logout) then
	sed "/rm -f .*$lockroot:t/d" ~/.logout >! /tmp/logout.$$
	mv /tmp/logout.$$ ~/.logout
else
	touch ~/.logout
endif
set lockfile=${lockroot}tty${port}a
touch $lockfile; chmod +w $lockfile
echo "rm -f $lockfile" >> ~/.logout
unset lockroot tty port mc
========================================================================
-- 
Paul Gillingwater, Computer Sciences	Call this BBS - Magic Tower (24 hours)
paul@csnz.nz  (vuwcomp!dsiramd!csnz)	NZ +64 4 753 561 8N1 TowerNet software
P.O.Box 929, Wellington, NEW ZEALAND	V21/V23/V22/V22bis/Bell 103/Bell 212A
Vox: +64 4 846194, Fax: +64 4 843924	"All things must parse"-ancient proverb