home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.xenix.sco
- Path: sparky!uunet!cs.utexas.edu!chinacat!chip
- From: chip@chinacat.unicom.com (Chip Rosenthal)
- Subject: Re: '/etc/wtmp' how to control it's size
- Organization: Unicom Systems Development, Austin, TX
- Date: Sat, 05 Sep 1992 23:06:57 GMT
- Message-ID: <1992Sep05.230657.7071@chinacat.unicom.com>
- References: <BtyEyJ.HrE@hsi.com> <1992Sep5.013608.21192@bilver.uucp>
- Lines: 44
-
- In article <1992Sep5.013608.21192@bilver.uucp>
- bill@bilver.uucp (Bill Vermillion) writes:
- >Don't mv /etc/wtmp to /etc/owtmp because the file is opened for writing
- >and you will be writing to the old file.
-
- I do not think this is an issue. The wtmp file is only opened briefly
- at the time getty, init, etc. need to log an event. So, yes, you
- introduce a brief subsecond race condition. However, I can't see
- where that would cause any problem unless you are doing some sort of
- multi-pass processing of the old wtmp file and there happens to be a
- blue moon out this evening.
-
- Further, if you are doing some sort of major processing of the wtmp
- file, there is an even bigger problem to this scheme. By blindly
- copying and emptying the wtmp file, you will have wiped out the login
- information for current sessions. That means that tomorrow night when
- you generate your reports you won't have any login records for all
- the people who were on the system at the time last night's cleanup
- was run. That's a more significant problem.
-
- In theory the right way to handle wtmp file cleaning is to prune out
- everything but the few records for the active sessions. This is much
- more complicated to do, and I've yet to run into a situation where I
- really needed it. Further, this is extremely difficult (if not
- impossible) to do without introducing race conditions.
-
- So either you aren't doing any fancy processing and the race introduced
- by the `mv' is not a problem, or you are doing fancy processing and
- in which case there are bigger problems than this one to deal with.
-
- With all that said and done, I pretty much do as Bill suggested.
- I think the best scheme would be something along the following:
-
- >/etc/nwtmp
- chmod 644 /etc/nwtmp
- chown bin /etc/nwtmp
- chgrp bin /etc/nwtmp
- mv /etc/wtmp /etc/owtmp # race condition opened here
- mv /etc/nwtmp /etc/wtmp # race condition closed here
-
- --
- Chip Rosenthal 512-482-8260 | The secret to a long life is
- Unicom Systems Development | knowing when it's time to go.
- <chip@chinacat.Unicom.COM> | - Michelle Shocked
-