home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / xenix / sco / 2908 < prev    next >
Encoding:
Text File  |  1992-09-12  |  2.0 KB  |  48 lines

  1. Newsgroups: comp.unix.xenix.sco
  2. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!introl.introl.com!ferret!stv
  3. From: stv@ferret.uucp (Steve Manning)
  4. Subject: Re: '/etc/wtmp' how to control it's size
  5. Message-ID: <1992Sep12.134545.8289@ferret.uucp>
  6. Summary: use 'ln' instead of 'mv'
  7. Organization: The Manning's at home
  8. References: <BtyEyJ.HrE@hsi.com> <1992Sep5.013608.21192@bilver.uucp> <1992Sep05.230657.7071@chinacat.unicom.com>
  9. Date: Sat, 12 Sep 1992 13:45:45 GMT
  10. Lines: 36
  11.  
  12. In article <1992Sep05.230657.7071@chinacat.unicom.com>
  13.      chip@chinacat.unicom.com (Chip Rosenthal) writes:
  14. >I think the best scheme would be something along the following:
  15. >    >/etc/nwtmp
  16. >    chmod 644 /etc/nwtmp
  17. >    chown bin /etc/nwtmp
  18. >    chgrp bin /etc/nwtmp
  19. >    mv /etc/wtmp /etc/owtmp        # race condition opened here
  20. >    mv /etc/nwtmp /etc/wtmp        # race condition closed here
  21.  
  22. I think that using 'ln' would reduce the race condition window significantly.
  23. Replace the two 'mv' commands with the following:
  24.  
  25.     ln /etc/wtmp /etc/owtmp
  26.     ln /etc/nwtmp /etc/wtmp
  27.     rm /etc/nwtmp
  28.  
  29. The second 'ln' will effectively 'rm' /etc/wtmp and then immediately
  30. replace it with the new file.  This way, the race contidition exists
  31. only for a brief instant *during* the execution of the 'ln' command.
  32. With the first method, the condition exists *between* the execution
  33. of the two 'mv' commands, and the shell has to parse the second line
  34. before it can be executed.  (Question: would putting the two commands
  35. on the same line separated by a semi-colon be faster?  I suspect that
  36. the shell would parse both commands before executing the first one,
  37. but I'm just guessing.)
  38.  
  39. The 'ln' method would also be appropriate for the suggestion someone
  40. else posted that involved copying /etc/utmp to /etc/wtmp.
  41.  
  42. While tracking login data isn't the most crucial function in the world,
  43. I think that this technique could come in handy at other times.
  44. -- 
  45. Steve Manning   stv%ferret@introl.introl.com  stv@ferret.uucp
  46. Milwaukee, WI       ...!introl!ferret!stv   etc., etc., etc.
  47.       "...but you're wrong, Steve. You see, it's only Solitaire" I.A.
  48.