[comp.unix.i386] Spawning a login on a pty

heimir@hafro.is (Heimir Sverrisson) (08/01/90)

I've been trying to start up a login process on the slave side
of a pty from an application that controls the master side.
I need this for an application that must take the user through
the getty->login->sh phase.

My approach was simply to fork-exec a '/etc/getty /dev/ttypX'
and talk to the '/dev/ptypX' device.  This was fine until the
'sh' was about to be started -- then I got this strange message
of 'no utmp entry' and to 'exec from the login shell'.  

I did try to double-fork to make the /etc/getty an orphan, then
I made it a process group leader (using setpgrp(2)) -- still w.o.
any luck.

At last I got the damn thing to work by writing a 'fake' utmp
entry to /etc/utmp using pututline(3). Then the problem is to keep
the utmp-entry up to date, i.e. when the user logs out of the pty.

My question to the net is:  Is this the way to go?  How do window-
managers, telnetd and rlogind do this?  How portable is it, will it
work in BSD environment, POSIX, AIX, MACH ?

I'll summarize if I get any usable answers.
--
Heimir Thor Sverrisson		heimir@hafro.is
-- 
---
Heimir Thor Sverrisson			Uucp: mcsun!isgate!hafro!heimir 
					Internet: heimir@hafro.is

michael@fts1.uucp (Michael Richardson) (08/14/90)

In article <177@hafro.is> heimir@hafro.is (Heimir Sverrisson) writes:
>I did try to double-fork to make the /etc/getty an orphan, then
>I made it a process group leader (using setpgrp(2)) -- still w.o.
>any luck.

  That isn't enough.

>At last I got the damn thing to work by writing a 'fake' utmp
>entry to /etc/utmp using pututline(3). Then the problem is to keep
>the utmp-entry up to date, i.e. when the user logs out of the pty.

  You have to go to that extent, which (if you don't want your
program to be setuid root, or at least setgid sys) means a writtable
/etc/utmp.

  I have yet to figure out how to mark a utmp entry as 'unused' -- I have
a feeling that /etc/init rewrites the file. After mucking about with things,
I managed to leave a bogus utmp entry for /dev/ttyd0, and that screwed up 
uucico (LOGNAME didn't match...)

>My question to the net is:  Is this the way to go?  How do window-
>managers, telnetd and rlogind do this?  How portable is it, will it
>work in BSD environment, POSIX, AIX, MACH ?

  Suns usually have writtable /etc/utmp files, at least for SunTools.
I've noticed that Shell Layers (shl) CHANGES the utmp entry. Unfortunately,
it changes it to 'sxt001' (instead of 'sxt/001', of course, /bin/tty is broken
anyway, unless you link /dev/sxt/* to /dev/sxt*)

>I'll summarize if I get any usable answers.

  None from me. Maybe someone has the answer...

-- 
   :!mcr!:            | < political commentary currently undergoing Senate >
   Michael Richardson | < committee review. Returning next house session.  >
 Play: mcr@julie.UUCP Work: michael@fts1.UUCP Fido: 1:163/109.10 1:163/138
    Amiga----^     - Pay attention only to _MY_ opinions. -   ^--Amiga--^