Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sdchema.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdchema!jwp From: jwp@sdchema.UUCP Newsgroups: net.bugs.4bsd Subject: sysline bugs Message-ID: <181@sdchema.UUCP> Date: Fri, 22-Jun-84 15:56:41 EDT Article-I.D.: sdchema.181 Posted: Fri Jun 22 15:56:41 1984 Date-Received: Sat, 23-Jun-84 07:16:36 EDT Organization: Chemistry Dept, UC San Diego Lines: 43 Description: (1) 'su' to another uid and then try to run "sysline"; it won't work. (2) If root runs "sysline" it will never exit (there's an assumption here, but I think it's generally true). Repeat By: Try both of them (don't forget to wait a while for 'sysline' to wakeup for (2) as there's up to a minute's delay before it's supposed to find out you've logged off). Cause: The function "isloggedin()" tries to determine if the tty has been logged off by checking to see if its ownership has changed since 'sysline' was started. Thus: (1) 'su' does not change the tty ownership to the new uid, therefore "isloggedin()" returns 0, therefore 'sysline' exits without doing anything [useful]. (2) In the systems I'm familiar with, root owns all unused ttys (the assumption I mentioned). Therefore, when root runs 'sysline' then logs off, the tty ownership does not change. Suggested Fix: Replace "isloggedin()" with something that works, e.g.: isloggedin() { register char *ttynm; register struct utmp *utbp; struct utmp utmpbuf; ttynm = ourtty + sizeof("/dev/") - 1; /* Above: ourtty = ttyname(2) */ utbp = &utmpbuf; lseek(ut, 0L, 0); while(read(ut, utbp, sizeof(struct utmp))) if(strcmp(ttynm, utbp->ut_line) == 0) if(utbp->ut_name[0] != '\0') return 1; else return 0; return 0; /* Should never be reached */ } John Pierce (sdchema!jwp) Chemistry, UCSD