init.app/getty.app/login.app/gemsh.app

authors: Ulrich Kaiser (U_Kaiser@t-online.de)
         Holger Kleinschmidt

state: freeware, no warranty, use at your own risk


introduction:
-------------
init.app allows you  to  login  under  GEM  e.g.  as  a  non-root user. The 
environment variable $HOME will be set according to current user, and more.

installation:
-------------
Experts may skip the following lines:

At first you  should  build	 an	 UNIX-alike	 directory	structure. For this
purpose just copy the directories

bin
usr
etc
var
home

from the GEM-init archive into the root	directory of a drive of	your choice
(best a minixfs partition), e.g. drive m:.

IF THESE DIRECTORIES AND ITS FILES ALREADY	EXIST, YOU WILL	HAVE TO	FILL UP
THE	MISSING	DIRECTORIES	AND	FILES STEP BY STEP WITHOUT OVERWRITING EXISTING
FILES.

Next thing to do is	to let	these  directories appear in drive u:. This	may
be done by inserting the following lines into MiNT.Cnf:

# m: is assumed to be a Minixfs partition
echo setting symbolic links...
sln m:\bin u:\bin
sln m:\usr u:\usr
sln m:\home u:\home
sln m:\etc u:\etc
sln m:\var u:\var

and  reboot  the  system.   If   you   have   done   all  right,  the  file 
...anywhere...\GEM-init\usr\sbin\init.app    shall    be     found    under 
u:\usr\sbin\init.app.

The directories boot, doc and misc from this archive need not be installed. 
They may stay where they currently are.

KGMD-user  only  need  to  copy   all   the   files  to  the  corresponding 
KGMD-directories, as /bin, /usr, ... should already exist.

Edit $HOME/.desktop an insert the  full  path  to your desktop application. 
Alternatively, edit gemsh.rsc and write  the  complete path to your desktop 
into the free string "DESKTOP" (default is u:\usr\sbin\desktop.app).

Under N.AES 1.1.7. 1.0.0 and  1.1.0  you  have  to copy or link all desktop 
applications including all its files (resource files, global config. files, 
...) to u:\usr\bin\GEM. You should also  adjust  the path to the desktop in 
~/.desktop.

You	should have	installed  correct	versions  of  the files	/etc/passwd	and
/etc/group.

For	the	sake of	security  install  init.app	 with  the	s-bit set (chmod +s
init.app) if GEM has not been started by the root. Then:

a) SingleAES:
   install boot.app as GEM auto-start program
   (#Z 01 U:\USR\SBIN\BOOT.APP@ in NEWDESK.INF)

   comment the entries for INIT= and GEM= of MINT.CNF
   run MINTNP.PRG, NOT MINT.PRG from your AUTO folder

b) AES 4.x:
   invoke boot.app with the following line in GEM.CNF:
   shell u:\usr\sbin\boot.app

   DO NOT INSTALL IT AS GEM AUTO START!

   pay attention to the line with GEM= which contains the complete path to
   AES 4.x; comment the line with INIT=

c) Geneva:
   invoke boot.app with the following line in GEM.CNF:
   shell u:\usr\sbin\boot.app

   DO NOT INSTALL IT AS GEM AUTO START!

   pay attention to the line with INIT= which contains the complete path to
   Geneva; comment the line with GEM=

d) N.AES 1.0.0 and N.AES 1.1.0:
   1. insert the following line in your MINT.CNF:
      exec u:\bin\rm -v u:\usr\bin\GEM\desktop.app
      exec u:\bin\cp -v u:\usr\sbin\boot.app u:\usr\bin\GEM\desktop.app

      pay attention to the line with GEM= which contains the complete path 
      tothe N.AES binary; comment the line with INIT=

   2. install the temporary desktop u:\usr\bin\GEM\desktop.app in N_AES.CNF 
      as shell:
      shell u:\usr\bin\GEM\desktop.app

      At boot time of N.AES, this file must not exist (reason for 1.)

e) N.AES 1.1.7 (= 2.x):
      see d)

f) XaAES:
   start init.app with the following line in XAAES.CNF:
   run u:\usr\sbin\boot.app

g) oAESis:
   install boot.app with the following line in OAESIS.CNF as shell:
   shell u:\usr\sbin\boot.app

h) MagiC: invoke boot.app as shell with the following line in MAGX.INF:
   #_SHL u:\usr\sbin\boot.app
   where the line with #_SHL has to be written before the line with #_CTR
   (pontrol panel entries)
   (but you need either a version of MagiC for MiNT or a desktop which
   handles MagiC+MiNT or a version of MiNT for MagiC or a version of 
   MagiC supporting all important MiNT functions or a suitable patch
   program...)

For	experts: of	course,	you	 may  write	 something	into the INIT= entry of
MINT.CNF. But to get to	GEM	and	 so	 to	GEM-init, the INIT=	program	must be
terminated or you have to run GEM right	from there (by means of	special	GEM
starters).

If your computer has  lots  of  RAM  you may re-use your KGMD-configuration 
where AES 4.x is called from /etc/ttytab:

console "/usr/etc/execmtos"	st52 on	secure

After logging out you  will  not  return  to  the  KGMD-login prompt but to 
GEM-init's login.app (or you have been able to terminate AES properly).

ATTENTION:  init.app  absolutely  depends   on  the  file  /etc/ttytab.gem. 
ttytab.gem  tells  init.app,  which   program   is  responsible  for  which 
interface. It should contain at least one entry for the console:

console "/usr/etc/getty.app console" vt52 on secure

That means that	/usr/etc/getty.app is responsible  for the console,	for	the
other  interfaces  like	 /dev/ttya	is	/usr/etc/getty	(part  of  the KGMD
distribution).	Later,	the	 parameter	vt52  should  appear  in  $TERM, if
everything went	ok.	You	may	 use  something	 else  than	 vt52, e.g.	tt52 or
vt100. MiniWin seems to evaluate tw, tw52 and st52.

If not	yet	 existing  you	should	create	two	 empty	files /etc/utmp	and
/var/adm/wtmp or else the UNIX commands who, ac and last will not work.

The file /etc/hostname should contain the hostname of your computer.

Furthermore, the directory /bin should contain an UNIX shell named sh.

Hint: if you want to run programs  as overlays of the desktop (under single
AES) there must	be a copy or  link	of	the	desktop	with its original name.
For	example, the  file	name  of  Ease	4.00  must	be	written	as EASE.PRG
(capital letters).

You	may	omit the renaming of the desktop into desktop.app or the editing of
gemsh.rsc. In this case,  an  alert	 will  appear  and	you	may	select your
desktop using the file selector (" open... ^O ").

working:
--------
init.app runs getty.app  and  login.app  in  an  endless  loop. login reads 
/etc/passwd and compares the dialog input  with the entries in /etc/passwd. 
After a successfull login $HOME will be set and gemsh.app will be launched. 
gemsh starts the desktop.  After  the  termination  of the desktop the next 
user may login. The whole procedure shown in a
graphic way:

    root: init
           |
    root: spawn(WAIT,/bin/sh,/etc/rc.gem)
           |
   ------->|
  |        |
  | root: fork()----------
  |        |              |
  | root: wait()  root: exec(/usr/etc/getty.app) (->/etc/ttytab.gem)
  |        |              |
  | root: wait()  root: exec(/usr/bin/login.app)
  |        |              |
  | root: wait()  root: setsid()
  |        |              |
  | root: wait()  root: setgid()
  |        |              |
  | root: wait()  root: setuid()
  |        |              |
  | root: wait()  user: spawn(WAIT,login shell,~/.gemlogin) *)
  |        |              |
  | root: wait()  user: exec(/bin/gemsh.app)
  |        |              |
  | root: wait()  user: spawn(WAIT,desktop) *)
  |        |              |
  | root: wait()  user: exec(/bin/GEM/logout.app)
  |        |              |
  | root: wait()  user: spawn(WAIT,login shell,~/.gemlogout)
  |        |              |
  |        |<-------------
  |        |
   --------

*) Under 4.x the login shell is executed in parallel mode. This may be done 
by /bin/loginsh (part of this distribution):

             |
   user: shel_write(/bin/loginsh)
             |             |
             |     user: fork()----------
             |             |             |
             |                  user: exec(login shell)
             |                                   |
   user: shel_write(desktop)                     |
             |         |                         |

Or you use /bin/loginsh.app  (renamed  file  of  tw-call.app  of TosWin 2.0 
(CF)). /bin/loginsh  has  the  higher  priority  if  both  /bin/loginsh and 
/bin/loginsh.app exist. -  Under  AES  4.x  the  desktop  will be called by 
shel_write().

Furthermore, under  AES  4.x  init.app  tries  to  open  a  console  window 
(messages window). The search for  the  messages to be installed is handled 
with the following priority:
1. /bin/terminal.app "u:\bin\messages": messages (= CONSOLE.TTP) runs 
   within a window of terminal.app where terminal.app may be a copy or link 
   of MiniWin.App
2. /bin/messages.app: messages has a window of its own (T-CON.APP)
3. /bin/messages: messages (= CONSOLE.TTP) runs within the standard TOSRUN 
   application


sound:
------
GEM-init   tries   to    play    different    sound    files    using   the 
/usr/local/bin/showaudio script. Allowed extensions are: snd, au, svx, avr, 
iff, hsn, wav, voc, sam. The extensions will be checked by GEM-init. So, it 
does not try to play things like ~/login.sh.

after booting: /etc/init.*
after login:   ~/login.*
after logout:  ~/logout.*, but only if /etc/logout.* does not exist. 
/etc/logout.* will be played a little later than ~/logou.*.


related files:
--------------
init.app, getty.app, login.app und gemsh.app will try to open the following
files:

/etc/passwd
/etc/group
/etc/hostname
/etc/utmp
/etc/shells                     future use
/etc/desktops                   future use
/etc/rc.gem   
/etc/motd                       
/etc/ttytab.gem
/etc/init.{snd,au,svx,avr,iff,hsn,wav,voc,sam}
/etc/logout.{snd,au,svx,avr,iff,hsn,wav,voc,sam}
/var/adm/wtmp
/var/adm/lastlog                
/var/spool/mail/*               (bash: /usr/spool/mail/*)
/dev/console
/dev/tty?                       acc. to /etc/ttytab.gem
/pipe/log                       future use
/bin/sh
/bin/terminal.app               only under AES 4.x
/bin/messages                   only under AES 4.x
/usr/etc/getty                  acc. to /etc/ttytab.gem
/usr/share/locale/{$LANG}/*.rsc 
/usr/local/bin/showaudio
~/.gemlogin
~/.gemlogout
~/.desktop
~/login.{snd,au,svx,avr,iff,hsn,wav,voc,sam}
~/logout.{snd,au,svx,avr,iff,hsn,wav,voc,sam}

Only to your information: getty tries to open the following files:
/etc/gettytab
/usr/bin/login
/bin/sh


department of rights:
---------------------
The following access rights are recommended:

file            owner group mode       comment
------------------------------------------------------------------
/etc            root  root  drwxrwxr-x
/bin            root  root  drwxrwxr-x
   init.app     root  root  srwx--x--- (srwx--x--x N.AES or XaAES)
   init.rsc     root  root   rw-rw---- ( rw-rw-r-- N.AES or XaAES)
/etc/passwd     root  root   rw-r-----
/etc/group      root  root   rw-r-----
/etc/hostname   root  root   rw-r--r--
/etc/utmp       root  root   rw-rw-rw-
/etc/ttytab.gem root  root   rw-rw-r--
/var/adm/wtmp   root  root   rw-rw-rw-
/etc/rc.gem     root  root   rw-rw----
/etc/desktops   root  root   rw-rw-r--
/etc/shells     root  root   rw-rw-r--
  getty.app     root  root   rwx--x--x
  getty.rsc     root  root   rw-rw-r--
  login.app     root  root   rwx--x--x
  login.rsc     root  root   rw-rw-r--
  gemsh.app     root  root   rwx--x--x
  gemsh.rsc     root  root   rw-rw-r--
desktop.app     root  root   rwx--x--x
desktop.*       root  root   rw-rw-r--
~               user  user  drwx------
~/.gemlogin     user  user   rw-------
~/$SCRAPDIR     user  user  drwx------


environmentals:
---------------
$LINES    set it in MiNT.Cnf
$COLUMNS  set it in MiNT.Cnf
$ROWS     use it alternatively to $LINES
$HOME     will be set by init.app corresponding with /etc/passwd
$PATH     currently it will be set by init.app to fixed values
          /bin:/usr/bin:/usr/local/bin:/usr/ucb:.
          the AES's PATH environment is not touched
$SHELL    will be set by init.app containing the path to the login shell
$TOSRUN   set it in GEM.Cnf/N_AES.Cnf, currently not used
$UNIXMODE set it in MiNT.Cnf, it has an influence to unix2dos()
$CLIPBRD  set by gemsh.app, contains the user's clipboard
$SCRAPDIR s. $CLIPBRD
$THINGDIR currently, gemsh.app sets it to $HOME
$HOSTNAME if this variable exists, /etc/hostname will not be evaluated
$LOGNAME  contains the login name
$USER     s. $LOGNAME
$FULLNAME contains the full user name (pw_gecos)
$TZ       set it in MiNT.Cnf
$TERM     will be set by init.app according to /etc/ttytab.gem
          caution: MinWin will set $TERM to tw52
$NLSPATH  set it in MiNT.Cnf

Or, in other words: the environmentvariables

$HOME
$SHELL
$TERM
$FULLNAME
$LOGNAME
$USER

need not be set neither in MINT.CNF  nor GEM.CNF/N_AES.CNF (but it will not 
hurt if you set them - they will be overwritten by GEM-init).

Caution: if	you	 boot  some	 program  to  set  the	AES's environment (like
SETENV.PRG), it	may	happen	that  the  environment	set	in MiNT.Cnf	will be
ignored. Better	set	 all  necessary	 environment  variables	 in	MiNT.Cnf or
GEM.Cnf/N_AES.Cnf.

