Xref: utzoo comp.sys.att:9068 unix-pc.general:5067 Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!sunybcs!oswego!news From: ostroff@Oswego.EDU (Boyd Ostroff) Newsgroups: comp.sys.att,unix-pc.general Subject: Re: Who is "logged in" when you are running multiple login windows? Keywords: unixpc, 3b1, multiple windows, login, knot, Gordian Message-ID: <1990Mar22.152927.27934@oswego.Oswego.EDU> Date: 22 Mar 90 15:29:27 GMT References: <871@galaxia.Newport.RI.US> <19773@cs.yale.edu> Reply-To: ostroff@oswego.Oswego.EDU (Boyd Ostroff) Organization: Instructional Computing Center, SUNY at Oswego, Oswego, NY Lines: 46 I'm still a little confused over the original problem here, but I've also had problems telling who the user is when running multiple windows on the system console. (Note: I've been using a very simple UA replacement which provides multiple 24x80 console windows in a small font for over a year without problems - it's called "wlogin" and I posted it some time ago - write if interested). Anyway, I wrote this little function to use as a getlogin() replacement and include it here since it might be of use to someone. It just finds out your tty name then reads through the utmp file until it finds a matching entry. ||| Boyd Ostroff - Tech Director - Dept of Theatre - SUNY Oswego ||| Sys Admin - "The CallBoard" - (315) 947-6414 - 1200/2400 baud ||| ostroff@oswego.oswego.edu - cboard!ostroff@oswego.oswego.edu ------------------------- cut here --------------------------- #include #include #include #include #include #include char *get_login() /* added this function to replace getlogin() */ { /* which doesn't work properly with multiple */ struct utmp *getutent(); /* windows on the Unix-PC system console */ struct utmp *u; /* Boyd Ostroff (ostroff@oswego.oswego.edu) */ char *ttyname(); char *where; where = 1 + strrchr(ttyname(0), '/'); setutent(); while ((u = getutent()) != NULL) { if (u->ut_type == 7) { if (strcmp(where, u->ut_line) ==0) { return(u->ut_user); } } } endutent(); }