ftp.nice.ch/peanuts/GeneralData/Usenet/news/1990/CSN-90.tar.gz#/comp-sys-next/1990/Nov/User-loging-logout-records

This is User-loging-logout-records in view mode; [Up]


Date: Sun 05-Nov-1990 18:57:42 From: chouw@galaxy.cps.msu.edu (Wen Hwa Chou) Subject: User loging/logout records (/usr/adm/wtmp) Last time I posted a question about how to get the "w" and "who" commands straight. After that I received two suggestions from e-mail in the very next day. Thanks, you netters out there are really helpful. The first solution I received consists of two programs: 1. MOTD 2. ghostbuster The MOTD (available from most ftp sites) will make the console login records correct. And the ghostbuster are supposedly to clean the mess left by Shell and Terminal. I have got MOTD installed a few weeks ago, and it runs fine, except that voice alert won't work. But I cannot find "ghostbuster" from any ftp sites that I know. I know I should ask the person who e-mailed me. Unfortunately I forgot to save the mail after I replied. So if any of you knows where I can get it would you please let me know? Thanks. The second solution does not work on the /usr/adm/wtmp, however it does show who's on the system - ps -auxg | egrep -v '^(your_user_id|root)' BTW, anybody know why the Terminal and Shell is set to be suid? -- Wen
Date: Sun 06-Nov-1990 01:53:27 From: izumi@fugitive.berkeley.edu (Izumi Ohzawa) Subject: Re: User loging/logout records (/usr/adm/wtmp) In article <1990Nov5.185742.1004@msuinfo.cl.msu.edu> chouw@galaxy.cps.msu.edu (Wen Hwa Chou) writes: >Last time I posted a question about how to get the "w" and "who" >commands straight. After that I received two suggestions from e-mail >in the very next day. Thanks, you netters out there are really >helpful. > >The first solution I received consists of two programs: >1. MOTD >2. ghostbuster > >The MOTD (available from most ftp sites) will make the console login >records correct. And the ghostbuster are supposedly to clean the mess >left by Shell and Terminal. I have got MOTD installed a few weeks >ago, and it runs fine, except that voice alert won't work. But I ^^^^^^^^^^^^^^^^^^^^^^ Try the following to make voice alert work. Login as root with WorkSpace (not su from Terminal/Shell). Launch Preferences App. Click the cube button. Toggle the check mark for "voice alerts", i.e., turn it off first, then turn it back on again. Also, make sure that you have copied "mail.snd" and "newmail.snd" to /LocalLibrary/Sounds directory (after creating the dir if it doesn't exist already). >cannot find "ghostbuster" from any ftp sites that I know. I know I >should ask the person who e-mailed me. Unfortunately I forgot to save >the mail after I replied. So if any of you knows where I can get it That's probably me. I run ghostbuster from cron at 1 hour intervals. The best thing to do is to combine this with LogoutHook.c contained in the MOTD distrubition, and run the combination as -logoutHook to loginWindow program. ------- HERE's the source to ghostbuster.c by EPS ---------- /* * ghostbuster - log out orphaned ptys * Eric P. Scott, San Francisco State University, January 1990 * * cc -o ghostbuster -s -O -bsd ghostbuster.c -lsys_s * chown root.tty ghostbuster * chmod 4755 ghostbuster */ #include <stdio.h> #include <grp.h> #include <utmp.h> #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> #include <sys/syslog.h> main(argc, argv) int argc; char *argv[]; { char *malloc(); time_t time(); register struct utmp *ut; register char *ubuf; register struct group *gr; register int s; int u, w, p; struct stat st; char devname[12]; s=3; do close(s); while (++s<20); openlog("ghostbuster", LOG_PID, LOG_AUTH); if ((u=open("/etc/utmp", O_RDWR))<0) { syslog(LOG_ERR, "/etc/utmp: %m"); exit(1); } gr=getgrnam("tty"); endgrent(); (void)fstat(u, &st); if ((st.st_size%sizeof (struct utmp))!=0) { syslog(LOG_ALERT, "utmp corrupt"); exit(1); } if (!(ubuf=malloc(st.st_size))) abort(); if ((s=read(u, ubuf, st.st_size))!=st.st_size) { if (s<0) syslog(LOG_ERR, "read error: %m"); else syslog(LOG_ERR, "read expected %d, got %d\n", st.st_size, s); exit(1); } s/=sizeof (struct utmp); for (ut=(struct utmp *)ubuf;s>0;--s,ut++) { if (ut->ut_line[0]!='t'||ut->ut_line[1]!='t'|| ut->ut_line[2]!='y'|| ut->ut_line[3]<'p'|| ut->ut_line[3]>'s'||!ut->ut_name[0]) continue; sprintf(devname, "/dev/pty%.5s", &ut->ut_line[3]); if ((p=open(devname, O_RDWR))<0) continue; devname[5]='t'; bzero(ut->ut_name, sizeof ut->ut_name); bzero(ut->ut_host, sizeof ut->ut_host); (void)time(&ut->ut_time); if ((w=open("/usr/adm/wtmp", O_WRONLY|O_APPEND))>=0) { (void)write(w, (char *)ut, sizeof (struct utmp)); (void)close(w); } (void)lseek(u, (long)((char *)ut-ubuf), L_SET); (void)write(u, (char *)ut, sizeof (struct utmp)); (void)chmod(devname, 0666); (void)chown(devname, 0, gr ? gr->gr_gid : 0); (void)close(p); syslog(LOG_NOTICE, "%s logged out", ut->ut_line); } (void)close(u); exit(0); } ---------- end of ghostbuster.c ------- Izumi Ohzawa, izumi@violet.berkeley.edu

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.