More Window Questions (was: ** Windows Answers **)

Boyd Ostroff ostroff at Oswego.EDU
Sat Sep 8 08:25:09 AEST 1990


In article <1199 at glyph.UUCP> ahh at glyph.UUCP (Andy Heffernan) writes:
>I'm no expert on this, but I've been doing the multiple console getty
>thing for awhile now and find it quite handy.  The biggest problem I've
>found, however, is that some library code (like getlogin(), cuserid() --
>basically the /etc/utmp grokkers) doesn't understand that this is possible.
>Apparently when they scan utmp looking for your login name when you're
>logged onto a console window, they stop after seeing the first user name 
>on any console window, even if it's the wrong window.

I'm also a big fan of multiple windows.  I wrote a little getty replacement for
the console (wlogin) which facilitates this by allowing multiple, overlapping 
24x80 windows that utilize a smaller font, and have been using it for a
couple years without problems.  Send me mail if you'd like a copy.

As far as the getlogin() problem, I did a quick hack to fix this awhile ago.
Substitute the following get_login() routine for the stock getlogin() and
it will fix your problems...

||| Boyd Ostroff - Tech Director - Dept of Theatre - SUNY Oswego 
||| Sys Admin - "The CallBoard" - (315) 947-6414 - 1200/2400 baud 
||| ostroff at oswego.oswego.edu - cboard!ostroff at oswego.oswego.edu 

#include <sys/types.h>
#include <utmp.h>
#include <time.h>
#include <stdio.h>
#include <pwd.h>
#include <string.h>


char *get_login()           /* this function replaces getlogin() */
{                           /* which doesn't work properly with multiple */
struct utmp *getutent();    /* windows on the Unix-PC system console */
struct utmp *u;             /* Boyd Ostroff (ostroff at oswego.oswego.edu) */
char *ttyname();
char *where;

    where = 1 + strrchr(ttyname(0), '/');
    setutent();
    while ((u = getutent()) != NULL)
        {
        if (u->ut_type == 7)    /* only check user processes */
            {
            if (strcmp(where, u->ut_line) ==0)
                {
                 return(u->ut_user);
                }
            }
        }
    endutent();
}



More information about the Comp.sys.att mailing list