in reply to Replacing getty with a perl script?

Non-Perl answer: I do a similar thing for a hardwired Linux serial console. I associate minicom to /dev/ttyS0 in my /etc/inittab file. I don't know OpenBSD boot well enough to advise on details, but it should be fairly easy to set up. The main problem I had was getting termcaps to agree.

After Compline,
Zaxo

  • Comment on Re: Replacing getty with a perl script?

Replies are listed 'Best First'.
Re: Re: Replacing getty with a perl script?
by ginseng (Pilgrim) on Jun 28, 2001 at 10:30 UTC

    I'm not sure what /etc/inittab has in it, but it's probably the same as /etc/ttys on my OpenBSD boxes.

    Here's the kluge I've been able to make work so far. In essence, I wrote a shell script, run as root (as that portion of the login must), and listed it in my gettytab as the program to run after getting a login name for a particular terminal type. Then I played with the /etc/shells file and the user's password file entry to get the perl program run as that user's shell.

    In more detail, my gettytab file uses the 'lo' prefix to identify the program to be run after receiving a username:

    from /etc/gettytab
    yrdterm:\
            :np:sp#9600:lo=/root/login:lm=Login? :
    

    That program (/root/login) does a forced login for a given user. (login -f user can only be run as root.)

    from /root/login
    #!/bin/sh
    /usr/bin/login -f yrd
    

    When the terminal gets set up (under init), it refers to /etc/ttys. This is probably the same as (or similar to) Linux's inittab.

    from /etc/ttys
    ttyC5   "/usr/libexec/getty yrdterm"        vt220   on
    

    (BTW, that's on console 5, not on the serial port, for simplicity in testing. I want to deal configuration of the server and configuration of the serial link separately ;)

    When /root/login drops the terminal to the user yrd's login, I want it to run the perl script as the shell. So i set the user's shell to the perl script, and added it to /etc/shells.

    from /etc/passwd
    yrd:*:1001:1001:yrd:/home/yrd:/home/yrd/weld
    

    Ultimately, I think this is an inelegant, convoluted, almost unacceptable solution :) I really should be able to run one program from /etc/ttys that changes UID to the appropriate user and runs the program. I just don't know how yet ;)