jwp@sdchema.UUCP (06/22/84)
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