home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / vmsnet / internal / 1576 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  3.8 KB

  1. Path: sparky!uunet!comp.vuw.ac.nz!zl2tnm!don
  2. From: don@zl2tnm.gen.nz
  3. Newsgroups: vmsnet.internals
  4. Subject: RE: re: idle terminal...
  5. Message-ID: <1992Nov10.234946.2101@zl2tnm.gen.nz>
  6. Date: 10 Nov 92 23:49:46 +1300
  7. References: <009635A2.6A391BA0.32551@WKUVX1.BITNET>
  8. Organization: The Wolery
  9. Lines: 107
  10.  
  11. Ehud Gavron 602-570-2546 <GAVRON@IT.SUNQUEST.COM> writes:
  12. >       HOWEVER, all those require explicit code be run by the user
  13. >       before termination can occur.  In the event that the user was
  14. >       disconnected (terminal, non vtas) or killed (batch job termination)
  15. >       then that process is STUCK until $cmkrnl intervention.
  16.  
  17. Not a problem.  Usually, your own process is deleted by a call to $EXIT
  18. from supervisor mode (eg when your batch run ends or terminal line hangs
  19. up) or exec mode (LOGINOUT.EXE), which in turn $DELPRCs us if it can't
  20. find any reason not to.  Thus, it's a simple matter to drop an exec mode
  21. exit handler to unset the bits.  Code is attached. 
  22.  
  23. Of course you still can't STOP/ID=0, but hey, them's the breaks.  8-)
  24.  
  25.  
  26. Don Stokes, ZL2TNM (DS555)                       don@zl2tnm.gen.nz (home)
  27. Network Manager, Computing Services Centre           don@vuw.ac.nz (work)
  28. Victoria University of Wellington, New Zealand             +64-4-495-5052
  29.  
  30.     .title NODIE    Save us from $DELPRC/$FORCEX/$SUSPND attempts
  31. ;++
  32. ;
  33. ; This ghastly hack protects us from attack by people without $CMKRNL and
  34. ; a fair bit of internals knowlege.  Without reaching into the PCB and
  35. ; tweaking bits, we cannot be $DELPRCed (aka STOP/ID), $SUSPNDed (aka 
  36. ; SET PROCESS/SUSPEND) or $FORCEXed (various utilities).
  37. ;
  38. ; When we log out, or the terminal line goes away, we have an exit handler
  39. ; that turns off our countermeasures so that the ensuing $DELPRC will 
  40. ; succeed.
  41. ;
  42. ;    Don Stokes <don@zl2tnm.gen.nz>            10-Nov-1992
  43. ;        Guarantee this?  You _gotta_ be kidding!
  44. ;
  45. ;--
  46.  
  47.         .link "SYS$SYSTEM:SYS.STB"/selective_search
  48.         .library "SYS$LIBRARY:LIB.MLB"
  49.         $PCBDEF
  50.  
  51. trickybits    = PCB$M_SUSPEN!PCB$M_DELPEN!PCB$M_FORCPEN ; Body-armour bits
  52. ;
  53. ; Mainline code: call exit handler stuff in exec mode
  54. ;         tweak STS field from kernel mode
  55. ;
  56.     .entry nodie, ^M<>
  57.         $CMEXEC_S routin=install_code    ; Install code to let us die
  58.         blbc R0, 99$            ; cleanly
  59.         $CMKRNL_S routin=stayalive    ; Set survivalist flags
  60. 99$:        ret                             ; Done, exit.
  61.  
  62.  
  63. ;
  64. ; Code to install an exit handler in P1 space to undo our dirty work before
  65. ; $DELPRC is called.
  66. ; Exec mode, image context.
  67. ;
  68.     .entry install_code, ^M<>
  69.         movl #undo_code_len, R1        ; R1=length of allocated block
  70.         jsb EXE$ALOP1PROC        ; Get P1 pool, pool addr in R2
  71.         movl R2, R6            ; R2 clobbered by MOVC3
  72.         moval status_o(R2), statusaddr    ; Fix up exit handler block
  73.         moval (R2), exitaddr        ; Fix up handler address
  74.         movc3 #undo_code_len, undo_code, (R2) ; Copy code to P1
  75.         $DCLEXH_S exitblock_o(R6)    ; Declare exec mode handler
  76.         blbc R0, 99$            ; ok?
  77.         movl #1, R0            ; Success.
  78. 99$:        ret
  79.  
  80.  
  81. ;
  82. ; Set the bits to protect us from suspnd, forcex or delprc attempts.
  83. ; Kernel mode, image context.
  84. ;
  85.     .entry stayalive, ^M<>
  86.         bisl #trickybits, PCB$L_STS(R4)
  87.         movl #1, R0
  88.         ret
  89.  
  90.  
  91. ;
  92. ; Code to load into P1 starts here
  93. ; Entered in exec mode, exit handler context.
  94. ;
  95. undo_code:    .word ^M<>        ; Start P1 code
  96.         $CMKRNL_S routin=1$        ; Run dirty work in kernel mode
  97.         ret                ; Done
  98.  
  99.   1$:        .word ^m<>            ; We're in kernel mode now
  100.         bicl2 #trickybits, PCB$L_STS(R4); Clear some bits
  101.         ret                ; All done, return to exec mode
  102.  
  103.   exitblock:    .long 0                ; Exit block:    Pointer
  104.   exitaddr:    .blkl                ;        Handler addr
  105.         .long 1                ;        Arg count
  106.   statusaddr:    .blkl                ;         Addr of status
  107.   status:    .blkl                ;         Status code
  108.  
  109. undo_code_len = .-undo_code        ; End of P1 code
  110.  
  111.  
  112. status_o     = status-undo_code        ; Offset into status address
  113.                         ; for fixup
  114. exitblock_o    = exitblock-undo_code        ; Offset of handler block
  115.  
  116.  
  117.         .end nodie
  118.