WLOGIN: a console getty replacement

Boyd Ostroff ostroff at cboard.UUCP
Sun Jun 18 16:08:25 AEST 1989


Here's WLOGIN, a program which lets you login to multiple overlapping windows
on the system console without the problems associated with multiple getty's.

#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive.  Save this into a file, edit it
# and delete all lines above this comment.  Then give this
# file to sh by executing the command "sh file".  The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -rw-r--r--  1 ostroff prog       3916 Jun 18 00:50 README
# -rw-r--r--  1 ostroff prog       3480 Jun 14 01:44 wlogin.1m
# -rw-r--r--  1 ostroff prog       3090 Jun 18 00:44 wlogin.c
# -rw-rw-r-x  1 ostroff prog        590 Jun 18 00:35 Makefile
# -rw-r--r--  1 ostroff prog       3049 Jun  7 21:40 font.uuenc
#
echo 'x - README'
if test -f README; then echo 'shar: not overwriting README'; else
sed 's/^X//' << '________This_Is_The_END________' > README
X
XThis is WLOGIN, a program which allows you to run multiple login sessions
Xin small, overlapping 24x80-character windows.  Each window will have a
Xproper utmp entry and will behave just as though you were logged in on
Xseparate tty lines.
X
XPlease read the following notes before installing it on your system.
XInstallation is simple, but it does require modifying your /etc/inittab.
X
X* BE SURE THAT YOU HAVE A BACKUP OF /ETC/INITTAB BEFORE PROCEEDING *  
X
XIf you seriously damage your inittab, you may not be able to login to your
Xsystem!  If you *really* want to play it safe, provide an alternate way to 
Xlogin, such as a terminal plugged into the serial port, or a PC with a modem. 
X
XTo install WLOGIN, follow these steps:
X
X1)  make
X
X2)  Read through the manual pages and this README file.
X
X3)  su
X
X4)  make install
X    
XFinally, you will need to arrange to run WLOGIN from your inittab.  First
Xyou must decide how you wish to use it.  A good start would be to leave
Xthe existing system console getty alone and run one WLOGIN window to see
Xif it works properly, as in the following example:
X
Xis:2:initdefault:
Xrc::bootwait:/etc/rc > /dev/null 2>&1
X vid:2:respawn:/etc/getty window 9600
X:ph0:2:respawn:/etc/getty ph0 1200
X ph1:2:respawn:/etc/getty ph1 1200
X 000:2:respawn:/etc/getty tty000 2400
X v1:2:respawn:/etc/wlogin
X
XIn this example, WLOGIN will spawn a window in the upper left-hand corner
Xof the screen, overlapping the phone mgr and time display line.
X
XIf you wish to totally eliminate the standard console getty, your inittab 
Xmight look like this:
X
Xis:2:initdefault:
Xrc::bootwait:/etc/rc > /dev/null 2>&1
X:ph0:2:respawn:/etc/getty ph0 1200
X ph1:2:respawn:/etc/getty ph1 1200
X 000:2:respawn:/etc/getty tty000 2400
X v1:2:respawn:/etc/wlogin 0 0
X v2:2:respawn:/etc/wlogin 100 10
X v3:2:respawn:/etc/wlogin 200 20
X
XThis example would provide you with 3 overlapping WLOGIN windows.  Be sure
Xto read the manual page for further information on the use of the program.
X
XFinally, double check to make sure that the program and font are properly 
Xlocated and named, then type:
X
X     init q
X
XThis should cause WLOGIN to spawn it's window(s).  If instead, windows start
Xopening and closing and/or you get lots of disk thrashing, you've either
Xmucked up the inittab entries or not followed the instructions above properly.
XDon't panic!  If INIT notices it is continuously respawning the same
Xentry for too long, it will quit (see the INIT(1M) man page).  Alternately,
Xyou could login either through the standard console window or via a serial
Xterminal (as per the suggestion above).  Once logged in, copy your BACKUP
Xversion of /etc/inittab over the modified version and then try again.
X
XI have also added the following two aliases to my .kshrc:
X
X    alias small='clear;windy -w 482 -h 240 -f 300;\
X                 setf 0;setf /usr/lib/wfont/122.ft 0'
X
X    alias big='clear;setf /usr/lib/wfont/system.8.ft 0;windy'
X
XThis way, if you get tired of looking at a little window, you can just
Xtype "big" and return to a full-screen shell.  To get back to a small
Xbordered window, type "small" (these both require the program "windy" 
Xfrom the STORE).
X
XThe WLOGIN source is pretty simple and could be easily modified to make the 
Xprogram suit your particular needs.  See the WINDOW(7) manual pages in 
XVolume 1 of the User's Manual for more information.
X
XThanks to Muhammad S. Benten for posting the 122 x 28 font some time ago.
XCredit is also due to Andy Fyfe for his window.c posting, which gave me
Xthe idea to write this.
X
X:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
X:: Boyd Ostroff, Technical Director ::::: System Operator, "The CallBoard" ::::
X:::: Dept of Theatre, SUNY Oswego :::::: (315) 947-6414 300/1200/2400 baud ::::
X::::: ostroff at oswego.Oswego.EDU :::::: rochester!kodak!gizzmo!cboard!ostroff ::
X:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
________This_Is_The_END________
if test `wc -l < README` -ne 95; then
  echo 'shar: README was damaged during transit (should have been 95 bytes)'
fi
fi                ; : end of overwriting check
echo 'x - wlogin.1m'
if test -f wlogin.1m; then echo 'shar: not overwriting wlogin.1m'; else
sed 's/^X//' << '________This_Is_The_END________' > wlogin.1m
X.TH WLOGIN 1M
X.SH NAME
Xwlogin - log in to a console window
X
X.SH SYNOPSIS
X.I /etc/wlogin [x-coordinate] [y-coordinate]
X
X.SH DESCRIPTION
X.I Wlogin 
X(for window-login)
Xis intended to be used as an alternative to /etc/getty for logging into the
Xsystem console on the AT&T UNIX-PC/3B1/7300.  When run from /etc/inittab,
X.I wlogin
Xputs up a moveable 24 x 80 character login window using a reduced
Xsize font.  Multiple instances of 
X.I wlogin
Xare possible in the inittab, allowing simultaneous logins in separate,
Xoverlapping windows.  /etc/utmp is properly updated so
X.I who
Xand
X.I ps
Xwill correctly note users and processes in different windows.  
XScreen-oriented programs such as 
X.I vi
Xbehave properly using the standard console s4 termcap.
X
X.SH USAGE
X.I Wlogin
Xmust be run from /etc/inittab.  It may be called with two optional arguments,
Xwhich are the x and y coordinates of the
X.I upper left-hand corner
Xof the login window.  In order to obtain a full 24 x 80 window, the value of
Xx must be in the range 0 to 200 and the value of y must be from 0 to 20.
XValues outside this range will result in a truncated window.  If no arguments
Xare given, x and y default to 0 and 0.
X
X.I Wlogin
Xmay be used to replace /etc/getty on /dev/window or in conjunction with it.
XThe resulting window will be titled with the line name, and an appropriate
Xentry will also be added to the window manager's menu.  Windows may be
Xselected in the customary way using either the mouse or Susp/Rsume keys.
X
X.bp
XThe following entries in /etc/inittab would spawn 3 overlapping
X.I wlogin
Xwindows:
X
X.nf
X   v1:2:respawn:/etc/wlogin 0 0
X   v2:2:respawn:/etc/wlogin 100 10
X  _v3:2:respawn:/etc/wlogin 200 20
X  ^
X  |
XImportant Note!
X  The first column in these inttab entries must be blank
X  or problems may result due to shell scripts which modify 
X  /etc/inittab!
X.fi
X
XThe labels "v1", "v2" and "v3" in the example above are arbitrary -
Xany desired id may be used as long as it is unique.
X
XBefore it puts up the login prompt,
X.I wlogin
Xwill display the file 
X.I /etc/wlog
Xif it is present.  This file serves the same purpose as /etc/issue does
Xfor getty, and allows a different message to be displayed on the system
Xconsole than the tty ports.  After displaying the the login "banner"
X.I wlogin
Xtransfers control to /bin/login via the EXECL(2) system call.
X
XThe reduced-size font file /usr/lib/wfont/122.ft must be present for 
X.I wlogin
Xto work.
X
X.I Wlogin
Xworks equally well with or without ua, smgr, wmgr, ph and getty. 
X
X.SH FILES
X.nf
X/etc/inittab            - controlling file
X/bin/login              - standard login program
X/etc/wlog               - console login message 
X/etc/utmp               - who's on the system
X/etc/wtmp               - who was on the system
X/dev/w?                 - console windows
X/etc/passwd             - password file
X/usr/lib/wfont/122.ft   - reduced size (122 x 28) font
X/etc/.fontload          - default system fonts
X.fi
X
X.SH BUGS
X.I Wlogin
Xcan spawn a window overlapping the top "status line" on the screen, but if
Xit is moved below this line with the mouse, it cannot be returned to its
Xoriginal position.  It isn't possible to spawn or move a window into the
Xbottom 4 screen lines, which are reserved for command prompts and function
Xkey labels.
X
X.bp
X.SH SEE ALSO
Xlogin(1M), init(1M), issue(4)
X
X.SH AUTHOR
X.nf
XBoyd Ostroff   ostroff at oswego.Oswego.EDU 
X               ...!rutgers!sunybcs!oswego!ostroff
X               ...!rutgers!rochester!kodak!gizzmo!cboard!ostroff
X.fi
________This_Is_The_END________
if test `wc -l < wlogin.1m` -ne 110; then
  echo 'shar: wlogin.1m was damaged during transit (should have been 110 bytes)'
fi
fi                ; : end of overwriting check
echo 'x - wlogin.c'
if test -f wlogin.c; then echo 'shar: not overwriting wlogin.c'; else
sed 's/^X//' << '________This_Is_The_END________' > wlogin.c
X/* ======================================================================== */
X/* wlogin.c - run /bin/login in a small 24 x 80 bordered window             */ 
X/* ======================================================================== */
X/* this program must be run from /etc/inittab as follows:                   */
X/*                                                                          */
X/* v2:2:respawn:/etc/wlogin xxx yyy                                         */
X/*                                                                          */
X/* where xxx and yyy are the x & y coords of the upper left-hand            */
X/* corner of the window.  If x and y are omitted, they default to 0 0       */
X/*                                                                          */
X/* The file /usr/lib/wfont/122.ft must be present for this program to work  */
X/* ======================================================================== */
X/* by Boyd Ostroff (ostroff at oswego.Oswego.EDU) 6/7/89                       */
X/* This program may be freely distributed and modified as desired           */
X/* Inspired by Andy Fyfe's window.c program                                 */
X/* Thanks to Muhammad S. Benten for posting the small font                  */
X/* ======================================================================== */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/font.h>
X#include <sys/window.h>
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
Xint x, y;
X
X    x = (argc > 1) ? atoi(argv[1]) : 0;
X    y = (argc > 1) ? atoi(argv[2]) : 0;
X    mkwindow(x,y);                                     /* create the window */
X    login();                    /* display login banner and exec /bin/login */
X    exit(1);            /* we won't make it this far unless an error occurs */
X}
X
Xmkwindow(x,y)       /* open a window, set its size, font and name */
Xint x, y;
X{
Xstruct uwdata wnd;
Xstruct utdata txt;
Xstruct ufdata fnt;
Xchar *ttyname();
Xint fd;
X
X    if ((fd = open("/dev/window", O_RDWR)) < 0) exit(1);
X    wnd.uw_x = x;
X    wnd.uw_y = y;
X    wnd.uw_width = 482;
X    wnd.uw_height = 240;
X    if (ioctl(fd,WIOCSETD, &wnd) < 0) exit(1);
X    fnt.uf_slot = 0;
X    strcpy(fnt.uf_name, "/usr/lib/wfont/122.ft");
X    if (ioctl(fd,WIOCUFONT, &fnt) < 0) exit(1);   /* must do this, but why? */
X    if (ioctl(fd,WIOCLFONT, &fnt) < 0) exit(1);
X    txt.ut_num = WTXTLABEL; 
X    strcpy(txt.ut_text, ttyname(fd));
X    if (ioctl(fd,WIOCSETTEXT, &txt) < 0) exit(1);
X    txt.ut_num = WTXTUSER; 
X    if (ioctl(fd,WIOCSETTEXT, &txt) < 0) exit(1);
X    close(1);   /* assign stdout and stderr to new window */
X    dup(0);
X    close(2);
X    dup(0);
X}
X
Xlogin()     /* display the login message and exec /bin/login */
X{
Xchar username[128];
X
X    cat("/etc/wlog");
X    printf("Login: ");
X    gets(username);
X    execl("/bin/login", "login", username, (char *)0);  
X}
X
Xcat(filename)     /* print the file, if it exists */
Xchar *filename;
X{
XFILE *fp;
Xint ch;
X
X    if ( (fp=fopen(filename, "r")) != NULL)
X        {
X        while ( (ch=getc(fp)) != EOF) putchar(ch);
X        fclose(fp);
X        }
X}
________This_Is_The_END________
if test `wc -l < wlogin.c` -ne 88; then
  echo 'shar: wlogin.c was damaged during transit (should have been 88 bytes)'
fi
fi                ; : end of overwriting check
echo 'x - Makefile'
if test -f Makefile; then echo 'shar: not overwriting Makefile'; else
sed 's/^X//' << '________This_Is_The_END________' > Makefile
X# Makefile for WLOGIN, a windowed getty replacement for the UNIX-PC
X
Xinclude $(MAKEINC)/Makepre.h
X
XCFLAGS= -O
XOBJ = wlogin.o
XDOC = >wlogin.doc
X
Xall: $(OBJ)
X	 $(LD) $(LDFLAGS) $(SHAREDLIB) $(OBJ) -o wlogin  
X	 strip wlogin
X	 uudecode font.uuenc
X	 nroff -man wlogin.1m $(DOC)
X
Xinstall: 	 
X		 cp wlogin /etc
X		 chown root /etc/wlogin
X		 chgrp bin /etc/wlogin
X		 chmod 700 /etc/wlogin
X		 cp 122.ft /usr/lib/wfont
X		 chown root /usr/lib/wfont/122.ft
X		 chgrp sys /usr/lib/wfont/122.ft
X		 chmod 644 /usr/lib/wfont/122.ft
X
Xclean:	
X	rm wlogin.o
X	rm wlogin
X	rm 122.ft
X
Xinclude $(MAKEINC)/Makepost.h
________This_Is_The_END________
if test `wc -l < Makefile` -ne 30; then
  echo 'shar: Makefile was damaged during transit (should have been 30 bytes)'
fi
fi                ; : end of overwriting check
echo 'x - font.uuenc'
if test -f font.uuenc; then echo 'shar: not overwriting font.uuenc'; else
sed 's/^X//' << '________This_Is_The_END________' > font.uuenc
Xbegin 644 122.ft
XM   !C@ &"@@                                &"P#W!@ "^@$( _@&
XM  ,( P,"^ 8  Q %" 'X!@ ##@0* ?@&  ,6! @!^ 8  R(%" 'X!@ #*@$#
XM _@&  ,R PD"^ 8  S #"0'X!@ #. at 4% ?H&  -$!04!^@8  T8"! +^!@ #
XM2 0! ?P&  -( @("_ at 8  T($" 'X!@ #/@0' ?D&  -& P<!^08  TP$!P'Y
XM!@ #4 at 0( ?D&  -8!0D!^ 8  V $" 'Y!@ #:@0( ?@&  -R! @!^08  WH$
XM" 'X!@ #@@0( ?D&  .* @8"^@8  Y("" +Z!@ #E at 0' ?D&  .>! ,!^P8 
XM Z0$!P'Y!@ #H at 0( ?@&  .H!0D!^ 8  [ $" 'X!@ #N at 4( ?@&  /"! @!
XM^ 8  \H$" 'X!@ #T at 0( ?@&  /:! @!^ 8  ^($" 'X!@ #Z at 0( ?@&  /R
XM P@"^ 8  _H$" 'X!@ $ @4( ?@&  0*! @!^ 8 !!(%" 'X!@ $&@4( ?@&
XM  0B! @!^ 8 !"H$" 'X!@ $, at 4) ?@&  0Z!0@!^ 8 !$0$" 'X!@ $3 4(
XM ?@&  14! @!^ 8 !%P%" 'X!@ $9 4( ?@&  1L!0@!^ 8 !'0%" 'X!@ $
XM? 0( ?@&  2$ PD"^ 8 !(P$" 'X!@ $E@,) ?@&  2>!0,!^ 8 !*@& 0  
XM!@ $I@,# ?@&  2@! 8!^@8 !)X$" 'X!@ $H at 0& ?H&  2J! @!^ 8 !*X$
XM!@'Z!@ $M at 4( ?@&  2Z! @!^@8 !,($" 'X!@ $R at 0( ?@&  32 PH!^ 8 
XM!-H%" 'X!@ $Y at 0( ?@&  3N!08!^@8 !/8$!@'Z!@ $^@0& ?H&  3^! @!
XM^@8 !0($" 'Z!@ %"@0& ?H&  42! 8!^@8 !18$" 'X!@ %&@0& ?H&  4B
XM!08!^@8 !28%!@'Z!@ %*@4& ?H&  4N!0@!^@8 !3($!@'Z!@ %. at 0) ?@&
XM  4^ 0L#]P8 !4@$"0'X!@ %5 at 4# ?L&  5@!@L ]P8 !5X             
XM                  $  0 !  $       $  0 %  4 !0 *  H 'P *  H 
XM'P *  H !  $  X  0 "  0 "  '  (  @ #  , "  $  (  0 ,  P !@ )
XM  D !@ 5  D "0 6  $  0 !  0  @ "  $  0 !  (  @ $  $  @ "  0 
XM!  $  (  @ !  0 %0 . !4 !  $  0 'P $  0  P #  (  0 /  ,  P (
XM  @ !  $  (  @ !  $ #@ )  D "0 )  D !P $  8 !0 $  0 !  $  < 
XM"  (  0  @ !  \ !P (  @ !@ (  @ "  '  (  @ *  H "@ ) !\ "  (
XM  \  0 !  < "  (  0  P ,  (  0 '  D "0 )  8 #P (  @ !  $  ( 
XM @ "  8 "0 )  8 "0 )  D !@ &  D "0 )  X "  $  ,  P #       #
XM  ,  P #       #  ,  @ !  @ !  "  $  @ $  @ #P    \  0 "  0 
XM"  $  (  0 '  @ "  $  (    "  ( #@ 1 !D %0 5 !T  0 !  X !@ )
XM  D "0 /  D "0 )  < "0 )  \ $0 1 !$ #P .  $  0 !  $  0 !  X 
XM!P )  D "0 )  D "0 '  \  0 !  <  0 !  $ #P /  $  0 !  <  0 !
XM  $ #@ !  $  0 -  D "0 .  D "0 )  \ "0 )  D "0 '  (  @ "  ( 
XM @ "  < "  (  @ "  )  D "0 &  D "0 %  4  P %  D $0 !  $  0 !
XM  $  0 !  \ $0 1 !L %0 5 !$ $0 1 !$ $P 5 !D $0 1 !$ $0 &  D 
XM"0 )  D "0 )  8 !P )  D "0 '  $  0 !  8 "0 )  D "0 )  4 "@ 0
XM  < "0 )  D !P %  D $0 .  $  0 "  0 "  (  < 'P $  0 !  $  0 
XM!  $  D "0 )  D "0 )  D !@ 1 !$ $0 1  H "@ $  0 $0 1 !$ %0 5
XM !4 "@ * !$ $0 *  0 !  * !$ $0 1 !$ "@ *  0 !  $  0 #P (  0 
XM!  "  (  0 /  <  0 !  $  0 !  $  0 '  $  0 "  ( !  $  @ "  '
XM  0 !  $  0 !  $  0 !P $  H $0 _  ,  @ $  < "  .  D "0 .  $ 
XM 0 '  D "0 )  D !P .  $  0 !  $ #@ (  @ #@ )  D "0 )  X !@ )
XM  \  0 !  X '  "  ( #P "  (  @ "  X "0 )  D #@ (  @ !P !  $ 
XM!P )  D "0 )  D !@    8 !  $  0 !  /  8    '  0 !  $  0 !  $
XM  ,  0 !  D "0 %  < "0 1  8 !  $  0 !  $  0 #P + !4 %0 5 !4 
XM$0 '  D "0 )  D "0 &  D "0 )  D !@ '  D "0 )  D !P !  $ #@ )
XM  D "0 )  X "  (  T  P !  $  0 !  X  0 "  0 "  '  (  @ /  ( 
XM @ "  ( #  )  D "0 )  D #@ 1 !$ $0 *  H !  1 !4 %0 5  H "@ 1
XM  H !  $  H $0 1 !$ "@ *  0 !  $  , #P $  0  @ "  \ "  $  0 
XM!  #  0 !  $  @  0 !  $  0 !     0 !  $  0 !  $  @ "  ( #  "
XB  (  @ ! !( %0 ) #\ /P _ #\ /P _ #\ /P _ #\ /P$ 
X 
Xend
________This_Is_The_END________
if test `wc -l < font.uuenc` -ne 52; then
  echo 'shar: font.uuenc was damaged during transit (should have been 52 bytes)'
fi
fi                ; : end of overwriting check
exit 0



More information about the Unix-pc.sources mailing list