home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.xenix.sco
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!introl.introl.com!ferret!stv
- From: stv@ferret.uucp (Steve Manning)
- Subject: Re: '/etc/wtmp' how to control it's size
- Message-ID: <1992Sep12.134545.8289@ferret.uucp>
- Summary: use 'ln' instead of 'mv'
- Organization: The Manning's at home
- References: <BtyEyJ.HrE@hsi.com> <1992Sep5.013608.21192@bilver.uucp> <1992Sep05.230657.7071@chinacat.unicom.com>
- Date: Sat, 12 Sep 1992 13:45:45 GMT
- Lines: 36
-
- In article <1992Sep05.230657.7071@chinacat.unicom.com>
- chip@chinacat.unicom.com (Chip Rosenthal) writes:
- >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
-
- I think that using 'ln' would reduce the race condition window significantly.
- Replace the two 'mv' commands with the following:
-
- ln /etc/wtmp /etc/owtmp
- ln /etc/nwtmp /etc/wtmp
- rm /etc/nwtmp
-
- The second 'ln' will effectively 'rm' /etc/wtmp and then immediately
- replace it with the new file. This way, the race contidition exists
- only for a brief instant *during* the execution of the 'ln' command.
- With the first method, the condition exists *between* the execution
- of the two 'mv' commands, and the shell has to parse the second line
- before it can be executed. (Question: would putting the two commands
- on the same line separated by a semi-colon be faster? I suspect that
- the shell would parse both commands before executing the first one,
- but I'm just guessing.)
-
- The 'ln' method would also be appropriate for the suggestion someone
- else posted that involved copying /etc/utmp to /etc/wtmp.
-
- While tracking login data isn't the most crucial function in the world,
- I think that this technique could come in handy at other times.
- --
- Steve Manning stv%ferret@introl.introl.com stv@ferret.uucp
- Milwaukee, WI ...!introl!ferret!stv etc., etc., etc.
- "...but you're wrong, Steve. You see, it's only Solitaire" I.A.
-