home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / hp / 15358 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  8.3 KB

  1. From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
  2. Date: Tue, 26 Jan 1993 09:57:11 GMT
  3. Subject: Re: Problem with utmp entries
  4. Message-ID: <28510415@hpuamsa.neth.hp.com>
  5. Organization: Hewlett-Packard, The Netherlands
  6. Path: sparky!uunet!mcsun!Germany.EU.net!gmd.de!newsserver.jvnc.net!darwin.sura.net!gatech!swrinde!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpcc05!hpbbn!hpuamsa!franks
  7. Newsgroups: comp.sys.hp
  8. References: <2794@eagle.ukc.ac.uk>
  9. Lines: 196
  10.  
  11. dll@ukc.ac.uk (D.L.Lindsey) writes:
  12.  
  13. > I have a cluster of HP9000 workstations, running HP8.00.  The utmp file is 
  14. > not being cleared properly when people log out.     When I do a finger it 
  15. > looks like there are still people logged in although they have no processes 
  16. > running.  Entries for these people still exist in the utmp file.
  17. > Does anyone know what might be causing this and how I might go about 
  18. > solving it?  
  19.  
  20.   The problem is probably not that utmp is not being cleared properly,
  21. but that is is corrupt due to a previous event. Below I have attached a
  22. recent string about this subject.
  23.  
  24.   Hope this helps.
  25.  
  26. Frank Slootweg, HP, Dutch Customer Response Center
  27.  
  28. From prs9k@brain.med.virginia.edu Tue Nov  3 02:37:18 1992
  29. From: prs9k@brain.med.virginia.edu (Phil Scarr)
  30. Date: Tue, 3 Nov 1992 01:37:18 GMT
  31. Date-Received: Wed, 4 Nov 1992 03:10:55 GMT
  32. Subject: Resetting the /etc/utmp, wtmp files after crashed logins
  33. Message-ID: <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU>
  34. Organization: Neuroclinical Trials Center, University of Virginia
  35. Path: hpuamsa!hpbbn!hpcc05!hplextra!scd.hp.com!hpscdm!sdd.hp.com!caen!uvaarpa!murdoch!brain.med.virginia.edu!prs9k
  36. Newsgroups: comp.sys.hp,comp.unix.questions
  37. Sender: usenet@murdoch.acc.Virginia.EDU
  38. Lines: 15
  39. Xref: hplextra comp.sys.hp:8565 comp.unix.questions:8043
  40.  
  41. After a recent power failure, several PCs which were logged into our
  42. HP9000 system crashed but their logins still show up with the w command.
  43. There are no associated processes for these logins, they are just
  44. phantoms.  Is there any way to reset these ptys?  I would assume you
  45. could reset the /etc/utmp and wtmp files to do this, but I don't know
  46. how.  Help!
  47.  
  48.     -Phil
  49. -- 
  50. PHIL SCARR        \      We are Microsoft...     /          (o) 804.243.0229
  51.   University of   /     OS/2 is irrelevant.      \          (f) 804.243.0290
  52.    Virginia,      \     UNIX is irrelevant.      /        prs9k@Virginia.EDU
  53.      Neurosurgery /     Openness is futile.      \     prs9k@Virginia.BITNET
  54.        NTC        \ Prepare to be assimilated... /   ...uunet!virginia!prs9k
  55.  
  56.  
  57. From franks Wed Nov  4 13:41:55 1992
  58. From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
  59. Date: Wed, 4 Nov 1992 12:41:55 GMT
  60. Date-Received: Wed, 4 Nov 1992 12:41:55 GMT
  61. Subject: Re: Resetting the /etc/utmp, wtmp files after crashed logins
  62. Message-ID: <28510345@hpuamsa.neth.hp.com>
  63. Organization: Hewlett-Packard, The Netherlands
  64. Path: hpuamsa!franks
  65. Newsgroups: comp.sys.hp
  66. References: <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU>
  67.  
  68. prs9k@brain.med.virginia.edu (Phil Scarr) writes:
  69.  
  70. > After a recent power failure, several PCs which were logged into our
  71. > HP9000 system crashed but their logins still show up with the w command.
  72. > There are no associated processes for these logins, they are just
  73. > phantoms.  Is there any way to reset these ptys?  I would assume you
  74. > could reset the /etc/utmp and wtmp files to do this, but I don't know
  75. > how.  Help!
  76.  
  77.   Unless you are using accounting (or otherewise using the information
  78. from /etc/wtmp), you only have to fix the /etc/utmp file. If you want to
  79. do this neatly then use fwtmp (see fwtmp(1m)) on the /etc/utmp file. Look
  80. at the format in utmp(4). I *think* you should change the ut_type field
  81. of the unwanted entries to 8 (DEAD_PROCESS). Alternatively you can use
  82. the quick and dirty method:
  83.  
  84. # shutdown 0
  85. # >/etc/utmp
  86. # reboot
  87.  
  88. Disclaimer: No guarantee, but this should work.
  89.  
  90. Frank Slootweg, HP, Dutch Customer Response Center
  91.  
  92. From chris@rz.uni-karlsruhe.de Thu Nov  5 15:34:13 1992
  93. From: chris@rz.uni-karlsruhe.de (Christian Finger)
  94. Date: Thu, 5 Nov 1992 14:34:13 GMT
  95. Date-Received: Fri, 6 Nov 1992 02:54:29 GMT
  96. Subject: Re: Resetting the /etc/utmp, wtmp files after crashed logins
  97. Message-ID: <1992Nov5.143413.1956@rz.uni-karlsruhe.de>
  98. Organization: Computer Center, University of Karlsruhe, Germany
  99. Path: hpuamsa!hpbbn!hpcc05!hplextra!scd.hp.com!hpscdm!sdd.hp.com!caen!sol.ctr.columbia.edu!ira.uka.de!rz.uni-karlsruhe.de!rz.uni-karlsruhe.de!chris
  100. Newsgroups: comp.sys.hp,comp.unix.questions
  101. References: <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU>
  102. Sender: usenet@rz.uni-karlsruhe.de (USENET 'No news is bad news' News System)
  103. Reply-To: finger@rz.uni-karlsruhe.de
  104. Lines: 48
  105. Xref: hplextra comp.sys.hp:8678 comp.unix.questions:8211
  106.  
  107. In article <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU>, prs9k@brain.med.virginia.edu (Phil Scarr) writes:
  108. | After a recent power failure, several PCs which were logged into our
  109. | HP9000 system crashed but their logins still show up with the w command.
  110. | There are no associated processes for these logins, they are just
  111. | phantoms.  Is there any way to reset these ptys?  I would assume you
  112. | could reset the /etc/utmp and wtmp files to do this, but I don't know
  113. | how.  Help!
  114. |     -Phil
  115.  
  116. The following program will do the job for you:
  117.  
  118. /*
  119.  * this code is in the public domain.  do with it as you
  120.  * please.  - jfh. 12/19/90
  121.  */
  122.  
  123. #include <sys/types.h>
  124. #include <utmp.h>
  125. #include <fcntl.h>
  126.  
  127. main ()
  128. {
  129.     int    fd;
  130.     struct    utmp    utmp;
  131.  
  132.     if ((fd = open ("/etc/utmp", O_RDWR)) < 0)
  133.         exit (1);
  134.  
  135.     while (read (fd, &utmp, sizeof utmp) == sizeof utmp) {
  136.         if (utmp.ut_type != DEAD_PROCESS &&
  137.                 kill (utmp.ut_pid, 0) != 0) {
  138.             lseek (fd, - (long) sizeof utmp, 1);
  139.             utmp.ut_type = DEAD_PROCESS;
  140.             write (fd, &utmp, sizeof utmp);
  141.         }
  142.     }
  143.     close (fd);
  144. }
  145.  
  146. Hope that helps,
  147.     -Christian
  148. -- 
  149.   .     Christian Finger         |  Tel   : (+49) 721/608-4038
  150.  |||    Computer Center          |  Fax   : (+49) 721/32550
  151. \|||    University of Karlsruhe  |  EMail : finger@rz.uni-karlsruhe.de
  152.     /   Postfach 6980            |  X.400 : S = finger; OU = rz
  153.         D-7500 Karlsruhe 1       |          P = uni-karlsruhe; A = dpb; C = de
  154.  
  155. From daves@hpcvusd.cv.hp.com Fri Nov  6 18:35:04 1992
  156. From: daves@hpcvusd.cv.hp.com (Dave Serisky)
  157. Date: Fri, 6 Nov 1992 17:35:04 GMT
  158. Date-Received: Sun, 8 Nov 1992 02:51:23 GMT
  159. Subject: Re: Resetting the /etc/utmp, wtmp files after crashed logins
  160. Message-ID: <1992Nov6.173504.22054@hpcvusn.cv.hp.com>
  161. Organization: Hewlett-Packard Co., Corvallis, OR, USA
  162. Path: hpuamsa!hpbbn!hpcc05!hplextra!scd.hp.com!hpscdm!cupnews0.cup.hp.com!news1.boi.hp.com!hp-pcd!hpcvusn!hpcvusd.cv.hp.com!daves
  163. Newsgroups: comp.sys.hp,comp.unix.questions
  164. References: <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU> <1992Nov5.143413.1956@rz.uni-karlsruhe.de>
  165. Sender: nobody@hpcvusn.cv.hp.com (Nobody - UID must be 99999)
  166. Lines: 35
  167. Xref: hplextra comp.sys.hp:8741 comp.unix.questions:8314
  168. Nntp-Posting-Host: hpcvusd.cv.hp.com
  169.  
  170. In article <1992Nov5.143413.1956@rz.uni-karlsruhe.de>, chris@rz.uni-karlsruhe.de (Christian Finger) writes:
  171. |> In article <1992Nov3.013718.15982@murdoch.acc.Virginia.EDU>, prs9k@brain.med.virginia.edu (Phil Scarr) writes:
  172. |> | After a recent power failure, several PCs which were logged into our
  173. |> | HP9000 system crashed but their logins still show up with the w command.
  174. |> | There are no associated processes for these logins, they are just
  175. |> | phantoms.  Is there any way to reset these ptys?  I would assume you
  176. |> | could reset the /etc/utmp and wtmp files to do this, but I don't know
  177. |> | how.  Help!
  178. |> | 
  179. |> |     -Phil
  180. |> 
  181. |> The following program will do the job for you:
  182. |> 
  183. |> /*
  184. |>  * this code is in the public domain.  do with it as you
  185. |>  * please.  - jfh. 12/19/90
  186. |>  */
  187. |> ...
  188.  
  189. There are a few potential problems with the posted program.  The
  190. /etc/utmp file contains entries of types other then USER_PROCESS or
  191. DEAD_PROCESS.  The program will probably mess up the utmp entries for
  192. the various system entries.  Also, I think there are a few other fields
  193. that need to be set or cleared in order to make a "legal" DEAD_PROCESS.
  194.  
  195. Casual mucking with the /etc/utmp file can cause problems with your
  196. system.  Problems can range from growing /etc/utmp files to duplicate
  197. /etc/utmp entries for a single tty/pty (which can confuse applications)
  198. to corruption that can prevent you from logging into your system and
  199. will require a reboot to fix.
  200.  
  201. [BTW, take a look at the getutent(3C) man page for some convenient
  202. functions for working with the /etc/utmp file.]
  203.  
  204. -- Dave Serisky
  205.