Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Oct 1998 12:10:33 -0400
From:      "Steve Friedrich" <SteveFriedrich@Hot-Shot.com>
To:        "Daniel Mahoney" <root@suffolk.lib.ny.us>, "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: zero-intervention logins?
Message-ID:  <199810071611.MAA06429@laker.net>

next in thread | raw e-mail | index | archive | help
On Wed, 7 Oct 1998 07:35:19 -0400 (EDT), Daniel Mahoney wrote:

>Hi.  This may sound wierd, as I've asked on several IRC channels
>(inlcuding #freebsd), but I was wondering if there's some driver that
>allows serial (or virtual) consoles to do automatic logins.  This would be
>used where I simply want a terminal to sit in a location and drop to a
>minimal shell no matter what the user does (like a library card catalog). 
>I did a little snooping, and realize that I need getty to handle terminal
>setup, and that getty passes the username argument to login (so I can't
>rename the getty login program variable, it wouldn't help. 
>
>Thus far, my only solution has been to prepare to hack a version of getty. 
>I don't like this option at all because I'm SURE someone's already found a
>better way, and because I'm not all that c-savvy.  I'd wind up gutting the
>program and not passing things as cleanly as they could be. 
>
>(Naturally, the above assumes the user has a null password and a HIGHLY
>restricted shell (like bin/lynx (with the lynx anon defines)) or
>something). 
>
>Any help is GREATLY appreciated.  And, btw...Nice OS...

I created a user called cards with no password via adduser:
cards:*:1003:1003:Card Catalog Menu
System:/home/cards:/usr/local/friedrich/mainmenu

Then I compiled a mainmenu, just as an example, you can replace it with
a real menu system.
cat mainmenu.c
#include <stdio.h>
#include <unistd.h>

#ifndef TRUE
#define TRUE    1
#endif

main()
{
        u_int   secs=5;

        while (TRUE){
                printf("Hello, world\n");
                sleep(secs);
        }
}                                           

And if you're not (yet) a C programmer, you can compile it with cc
mainmenu.c -o mainmenu
I put the source and the compiled binary in /usr/local/friedrich
(because everyone NOT local uses /usr/local)

All this program does is:
When a user uses the "cards" user ID to login, they will not be
prompted for a password, but the system will start the mainmenu
program, which in this case simply prints out "Hello, world" every 5
seconds.  If the user enters Control-C to break out of the program,
they will be logged out.  If, in your program, you open any files in
"write mode", you'll want to "trap" the Control-C so you can close the
files before exiting. I'm not 100% sure that the C library would
actually throw away anything if you didn't, but it's good programming
practice to close files before you exit.

Hope this is a good start for you...

FYI, I also tried putting mainmenu in place of a getty in /etc/ttys,
but I couldn't get it to work.  Someone else may know the secret, but I
prefer the above example because then any tty can be used and it's not
DEDICATED.  Which is really helpful for sysadmins... 
Unix systems measure "uptime" in years, Winblows measures it in minutes.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810071611.MAA06429>