[comp.unix.questions] Idle user logoff

bglenden@colobus.cv.nrao.edu (Brian Glendenning) (01/01/91)

I realize this has been hashed to death, but I never thought I needed
to pay attention before (and no, this isn't in the FAQ posting - maybe
it should be?).

I recently got a Decstation 3100 on my desk. It is very strict about
it's 2-user license. Could someone please forward good solutions for
how to logoff "idle" users? Unfortunately it is very easy for people
to do an rlogin and forget about it.

Please reply by email since this has been discussed so often on the
net. Thank you. If you don't know the answer either I will forward
it/them to you when I find out.

Brian
--
       Brian Glendenning - National Radio Astronomy Observatory
bglenden@nrao.edu          bglenden@nrao.bitnet          (804) 296-0286

buck@sct60a.sunyct.edu (Jesse R. Buckley, Jr.) (01/02/91)

        There is a program in comp.sources.unix called untamo that will, not
only logout idle people, but also (at your option) logout extra logins, ect.
If you can't get it send my mail and I'll send it to you.

-- 
-Buck (buck@sct60a.sunyct.edu)
"So this is a leap second?" -- Me at 6:59:60 pm on Mon Dec 31, 1990

bglenden@colobus.cv.nrao.edu (Brian Glendenning) (01/04/91)

Thanks for the many helpful replies I have gotten. I have discovered a
bug in untamo. Since I don't know who is responsible for it any more
(mail to doc at purdue bounced) I'll post it here so at least the
people who told me about untamo will see it:

In untamo.c we find the lines:

				pswd = getpwnam(utmpbuf.ut_name);
				user->ugroup = pswd->pw_gid;

but if we look in <utmp.h> we find

struct utmp {
	char	ut_line[8];		/* tty name */
	char	ut_name[8];		/* user id */
	char	ut_host[16];		/* host name, if remote */
	long	ut_time;		/* time on */
};

Thus if your user name is 8 chars, ut_name won't be null terminated
(you'll probably get ut_name and ut_host concatenated before you get a
termination). This will make getpwnam fail and return a null. Then in
the second line you will be dereferencing a null pointer. Bang. core
dump.

The cure is to at least check that pswd isn't null before
dereferencing, and probably to do something like:

		{ char name[9];
                  strncpy(name,utmpbuf.ut_name,8);
		  name[9]=0;
		  ...
		}

And check the return on getpwnam. But I can't see how to make it work
at all for user names longer than 8 chars, although I guess you could
hope that they are unique in the first 8 and look through each entry
of the passwd file.

Brian
--
       Brian Glendenning - National Radio Astronomy Observatory
bglenden@nrao.edu          bglenden@nrao.bitnet          (804) 296-0286

peirce@gumby.cc.wmich.edu (Leonard Peirce) (01/07/91)

In article <BGLENDEN.91Jan3154358@colobus.cv.nrao.edu> bglenden@colobus.cv.nrao.edu (Brian Glendenning) writes:
>
>Thanks for the many helpful replies I have gotten. I have discovered a
>bug in untamo. Since I don't know who is responsible for it any more
>(mail to doc at purdue bounced) I'll post it here so at least the
>people who told me about untamo will see it:

The "keeper" of untamo seems to have disappeared.  I sent them a fix for
the bug you mention plus a few others almost a year ago and haven't heard
anything from them.  Is anyone at Purdue still taking care of it?
--
Leonard Peirce                  Internet:  peirce@gumby.cc.wmich.edu
Western Michigan University                peirce@gw.wmich.edu
Academic Computing Services     UUCP:      ...!uunet!sharkey!wmichgw!peirce
Kalamazoo, MI  49008            Phone:     (616) 387-5469

mathisen@dali.cs.montana.edu (Jaye Mathisen) (01/07/91)

In article <1991Jan7.135259.11464@gumby.cc.wmich.edu> peirce@gumby.cc.wmich.edu (Leonard Peirce) writes:
>
>The "keeper" of untamo seems to have disappeared.  I sent them a fix for
>the bug you mention plus a few others almost a year ago and haven't heard
>anything from them.  Is anyone at Purdue still taking care of it?




If nobody steps forward, I'll be happy to track changes and keep an updated
copy around.   I have some local mods to untamo that I've found useful, perhaps
someday I'll get 'em in some semblance of order...

If you've got patches to untamo, blast 'em to me, and if somebody at purdue
raises a hand, I'll send what I've collected off to them...

Please e-mail them to osyjm@{caesar,}cs.montana.edu.
--
Jaye Mathisen,sysmgr 410 Roberts Hall,Dept. of Computer Science
Montana State University,Bozeman MT 59717         PHONE: (406) 994-{4780,3931} 

dls@mentor.cc.purdue.edu (David L Stevens) (01/09/91)

	I don't normally read this group, so if you have questions or
follow-ups, you should send them via e-mail to me (dls@cc.purdue.edu),
perhaps in addition to posting, if you think it's of general interest. Some
later articles regarding untamo bugs and support were directed to me by a
member of our staff who does read this group.

	Untamo was written by a succession of part-time student programmers
over a period of a year or so and, due to either lack of continuity or lack
of experience, it is loaded with bugs. I saw the symptoms of one and while
fixing it, turned up 3 more. The more I looked, the more I found, so I finally
decided to rewrite it from scratch.
	I've done that, but it's been fairly low on my priority list, so I
haven't quite finished testing and profiling it to my satisfaction. I have
also added quite a few new features, including the ability to allow users to
specify a range of timeout values for their terminals and a more flexible 
configuration file format.
	I expect I'll be to a point where it can be distributed by, say,
February, so I'd suggest holding bug reports until then, and then seeing if
my version has the same problem. We have no plans to support the old untamo
at all.

	Also, there is an untamo mail alias ("untamo@cc.purdue.edu") where
bug reports, diffs for new features or new platforms, etc can be sent. I'll
include that address in the distribution, so you won't be stuck with
nonexistent id's in the future.
	If you have any questions, comments, etc, regarding untamo, feel free
to send me mail. I'll answer them as I find time.
-- 
					+-DLS  (dls@mentor.cc.purdue.edu)

aem@mthvax.cs.miami.edu (a.e.mossberg) (01/09/91)

In <3236@dali> mathisen@dali.cs.montana.edu (Jaye Mathisen) writes:

>If nobody steps forward, I'll be happy to track changes and keep an updated
>copy around.   I have some local mods to untamo that I've found useful, perhaps
>someday I'll get 'em in some semblance of order...

I'll be happy to function as a ftp site for untamo as well. 

aem

-- 
aem@mthvax.cs.miami.edu .......................................................
People look ridiculous when they're in ecstasy.  	- David Byrne

sac@decuk.uvo.dec.com (Stephen A Carpenter) (01/10/91)

If you run the tcsh you can set a variable called autologout
to log off idle users.

Stephen.