home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / vmsnet / internal / 1161 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  16.1 KB

  1. Path: sparky!uunet!olivea!sgigate!psinntp!psinntp!npri6!murphy
  2. From: murphy@npri6.npri.com (David P. Murphy)
  3. Newsgroups: vmsnet.internals
  4. Subject: Re: DETACHED process -> INTERACTIVE
  5. Message-ID: <6050@npri6.npri.com>
  6. Date: 17 Aug 92 14:32:47 GMT
  7. References: <1992Aug14.193402.116675@rrz.uni-koeln.de>
  8. Organization: NPRI, Alexandria VA
  9. Lines: 601
  10.  
  11.  
  12. >How can I change the mode of a process from DETACHED
  13. >to INTERACTIVE, that would be nice for some DECwindows
  14. >related process startups (run/detached) which will run
  15. >SYLOGIN and LOGIN (now we have to check for f$mode()
  16. >= interactive or other) ? E.g. we run/detached DECW$SESSIONCOM
  17. >to startup Session manager on terminals which are also
  18. >used to connect to other (U*X) hosts and therefore should
  19. >not be hardwired to a system via DECW$START_LOGIN.
  20. >
  21. >moravec@Ph1.Uni-Koeln.De (Andreas Moravec)
  22.  
  23. here follows the .MAR file i wrote to accomplish the same thing
  24. for a VT100 interactive process.  there was a hack of a lot
  25. of bookkeeping involved (process-permanent files, various fields
  26. in the PRC and JIB structures, etc.) and i'm not promising this
  27. will work first time through for you, but it might get you started.
  28. ignore the parts you don't want, such as resetting the username.
  29. good luck.
  30.  
  31. ok
  32. dpm
  33.  
  34.     .title HackAutoLogin
  35.     .ident /V01-000/
  36.  
  37.     .library    "sys$library:starlet.mlb"
  38.  
  39.     $ssdef
  40.     $fabdef
  41.     $namdef
  42.     $rabdef
  43.     $devdef
  44.     $prvdef
  45.     $climsgdef
  46.  
  47.     .library    "sys$library:lib.mlb"
  48.  
  49.     $prcdef
  50.     $pcbdef
  51.     $jibdef
  52.     $ucbdef
  53.     $ttyucbdef
  54.  
  55. ; all of the PPD and IDF symbols, and the PRC symbols that lack a dollar sign,
  56. ; must be linked in from SYS$SYSTEM:DCLDEF.STB, since we do not have access
  57. ; to the special macro libraries that are proprietary to Digital.
  58.  
  59. $EQU    USE_MSG_FILE    1
  60.  
  61. .if defined USE_MSG_FILE
  62.     .psect    $data pic, usr, con, rel, lcl, noshr, noexe, rd, wrt, novec
  63.  
  64. msg00:    .ascii    /made it this far . . ./
  65. msg00a:    .ascii    /got to HERE . . ./
  66. msg01:    .ascii    /successfully closed sys$input/
  67. msg02:    .ascii    /successfully flushed sys$output/
  68. msg03:    .ascii    /successfully closed sys$output/
  69. msg04:    .ascii    /successfully opened new sys$input/
  70. msg05:    .ascii    /successfully connected new sys$input/
  71. msg06:    .ascii    /successfully back from HackSysIn()/
  72. msg07:    .ascii    /successfully opened new sys$output/
  73. msg08:    .ascii    /successfully connected new sys$output/
  74. msg09:    .ascii    /successfully back from HackSysOut()/
  75. msg10:    .ascii    /should return EXIT_SUCCESS from HackSysInSysOut()/
  76.  
  77. ptrfao:
  78.     .ascid    /the PPD is !XL, the PRC is !XL, and the IDF is !XL./
  79. ptrstr:
  80.     .ascid    /                                                                  /
  81. .endc
  82.  
  83.     .psect    $code pic, con, rel, lcl, shr, exe, rd, nowrt, long
  84.  
  85.     .entry    HackSysInSysOut, ^m<>
  86.  
  87. ; this is just a shell routine so that i can shift into executive mode.
  88. ; everything is done in the "real" routine, and its return value is echoed.
  89.  
  90.     $cmexec_s    routin=RealHackSysInSysOut, arglst=(ap)
  91.     ret
  92.  
  93.  
  94.     .entry    RealHackSysInSysOut, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  95.  
  96. ; the following steps need to be executed:
  97. ;
  98. ;    1.  close sys$input
  99. ;    2.  close sys$output
  100. ;    3.  open the terminal as sys$input
  101. ;    4.  move new values for sys$input into the PPD, the PRC, and the IDF
  102. ;    5.  open the terminal as sys$output
  103. ;    6.  move new values for sys$output into the PPD, the PRC, and the IDF
  104. ;    7.  set the "silent logout" flag in the PRC
  105. ;    8.  pass the new IFIs back to the caller
  106.  
  107.     devname     =  4
  108.     devnamelen  =  8
  109.     filename    = 12
  110.     filenamelen = 16
  111.     inpIFIptr   = 20
  112.     outIFIptr   = 24
  113. .if defined USE_MSG_FILE
  114.     msgrab      = 28
  115. .endc
  116.  
  117.     moval    krnerrhnd, (fp)            ; kernel-mode error handler
  118.  
  119. ; we need references to privileged structures in P1 space
  120.  
  121. .if defined USE_MSG_FILE
  122.     movl    msgrab(ap), r0            ; begin debug printf()
  123.     moval    msg00, rab$l_rbf(r0)
  124.     movw    #22, rab$w_rsz(r0)
  125.     pushl    msgrab(ap)
  126.     calls    #1, g^sys$put
  127.     pushl    msgrab(ap)
  128.     calls    #1, g^sys$flush            ; end debug printf()
  129. .endc
  130.  
  131.     movab    g^ctl$ag_clidata, r9        ; pointer to the PPD
  132.     movl    ppd$l_prc(r9), r10        ; pointer to the PRC
  133.     movl    prc_l_idflnk(r10), r11        ; pointer to the IDF
  134.  
  135. .if defined USE_MSG_FILE
  136.     $fao_s    ctrstr = ptrfao, outbuf = ptrstr, outlen = ptrstr, -
  137.         p1 = r9, p2 = r10, p3 = r11
  138.     movl    msgrab(ap), r0            ; begin debug printf()
  139.     movl    ptrstr+4, rab$l_rbf(r0)
  140.     movw    #66, rab$w_rsz(r0)
  141.     pushl    msgrab(ap)
  142.     calls    #1, g^sys$put
  143.     pushl    msgrab(ap)
  144.     calls    #1, g^sys$flush            ; end debug printf()
  145. .endc
  146.  
  147. ; now we need some local storage to play with
  148.  
  149.     movl    prc_l_inprab(r10), r7        ; pointer to a RAB
  150.     movl    rab$l_fab(r7), r6        ; pointer to a FAB
  151.     movl    fab$l_nam(r6), r8        ; pointer to a NAM
  152.  
  153. ; close the current sys$input file, which should be a mailbox.
  154.  
  155.     movw    ppd$w_inpifi(r9), fab$w_ifi(r6)        ; use the IFI
  156.  
  157. .if defined USE_MSG_FILE
  158.     movl    msgrab(ap), r0            ; begin debug printf()
  159.     moval    msg00a, rab$l_rbf(r0)
  160.     movw    #17, rab$w_rsz(r0)
  161.     pushl    msgrab(ap)
  162.     calls    #1, g^sys$put
  163.     pushl    msgrab(ap)
  164.     calls    #1, g^sys$flush            ; end debug printf()
  165. .endc
  166.  
  167.     pushl    r6
  168.     calls    #1, g^sys$close
  169.     blbs    r0, CLOSE_OUT
  170.     brw    OUCH
  171.  
  172. ; close the current sys$output file, which should be the null device.
  173.  
  174. CLOSE_OUT:
  175.  
  176. .if defined USE_MSG_FILE
  177.     movl    msgrab(ap), r0            ; begin debug printf()
  178.     moval    msg01, rab$l_rbf(r0)
  179.     movw    #29, rab$w_rsz(r0)
  180.     pushl    msgrab(ap)
  181.     calls    #1, g^sys$put
  182.     pushl    msgrab(ap)
  183.     calls    #1, g^sys$flush            ; end debug printf()
  184. .endc
  185.  
  186.     movw    ppd$w_outifi(r9), fab$w_ifi(r6)        ; use the IFI
  187.     movw    ppd$w_outisi(r9), rab$w_isi(r7)        ; use the ISI
  188.  
  189.     pushl    r7
  190.     calls    #1, g^sys$flush
  191.     blbs    r0, CLOSE
  192.     brw    OUCH
  193.  
  194. CLOSE:
  195.  
  196. .if defined USE_MSG_FILE
  197.     movl    msgrab(ap), r0            ; begin debug printf()
  198.     moval    msg02, rab$l_rbf(r0)
  199.     movw    #31, rab$w_rsz(r0)
  200.     pushl    msgrab(ap)
  201.     calls    #1, g^sys$put
  202.     pushl    msgrab(ap)
  203.     calls    #1, g^sys$flush            ; end debug printf()
  204. .endc
  205.  
  206.     pushl    r6
  207.     calls    #1, g^sys$close
  208.     blbs    r0, OPEN_IN
  209.     brw    OUCH
  210.  
  211.  
  212. ; open the terminal as the new sys$input file.
  213.  
  214. OPEN_IN:
  215.  
  216. .if defined USE_MSG_FILE
  217.     movl    msgrab(ap), r0            ; begin debug printf()
  218.     moval    msg03, rab$l_rbf(r0)
  219.     movw    #30, rab$w_rsz(r0)
  220.     pushl    msgrab(ap)
  221.     calls    #1, g^sys$put
  222.     pushl    msgrab(ap)
  223.     calls    #1, g^sys$flush            ; end debug printf()
  224. .endc
  225.  
  226.     movb    #fab$m_prn, fab$b_rat(r6)        ; set characteristics
  227.     movb    #fab$c_vfc, fab$b_rfm(r6)        ; for SYS$INPUT in
  228.     movb    #<fab$m_get ! fab$m_put>, fab$b_fac(r6)    ; the FAB
  229.     movl    #<fab$m_ppf ! fab$m_sqo ! fab$m_inp>, fab$l_fop(r6)
  230.  
  231.     movl    devname(ap), fab$l_fna(r6)    ; point to the terminal name,
  232.     movb    devnamelen(ap), fab$b_fns(r6)    ; including the length
  233.  
  234.     pushl    r6
  235.     calls    #1, g^sys$open
  236.     blbs    r0, IN_CONNECT
  237.     brw    OUCH
  238.  
  239. IN_CONNECT:
  240.  
  241. .if defined USE_MSG_FILE
  242.     movl    msgrab(ap), r0            ; begin debug printf()
  243.     moval    msg04, rab$l_rbf(r0)
  244.     movw    #33, rab$w_rsz(r0)
  245.     pushl    msgrab(ap)
  246.     calls    #1, g^sys$put
  247.     pushl    msgrab(ap)
  248.     calls    #1, g^sys$flush            ; end debug printf()
  249. .endc
  250.  
  251.     pushl    r7
  252.     calls    #1, g^sys$connect
  253.     blbs    r0, IN_OPEN_OK
  254.     brw    OUCH
  255.  
  256. IN_OPEN_OK:
  257.  
  258. .if defined USE_MSG_FILE
  259.     movl    msgrab(ap), r0            ; begin debug printf()
  260.     moval    msg05, rab$l_rbf(r0)
  261.     movw    #36, rab$w_rsz(r0)
  262.     pushl    msgrab(ap)
  263.     calls    #1, g^sys$put
  264.     pushl    msgrab(ap)
  265.     calls    #1, g^sys$flush            ; end debug printf()
  266. .endc
  267.  
  268. ; have to kick into kernel gear to move the SYS$INPUT values into the PPD.
  269.  
  270.     $cmkrnl_s    routin=HackSysIn, arglst=(ap)
  271.  
  272. .if defined USE_MSG_FILE
  273.     movl    msgrab(ap), r0            ; begin debug printf()
  274.     moval    msg06, rab$l_rbf(r0)
  275.     movw    #34, rab$w_rsz(r0)
  276.     pushl    msgrab(ap)
  277.     calls    #1, g^sys$put
  278.     pushl    msgrab(ap)
  279.     calls    #1, g^sys$flush            ; end debug printf()
  280. .endc
  281.  
  282. ; open the terminal as the new sys$output file.
  283.  
  284.     clrw    fab$w_ifi(r6)                ; clear the IFI
  285.     clrw    rab$w_isi(r7)                ; clear the ISI
  286.  
  287.     movb    #fab$m_prn, fab$b_rat(r6)        ; set characteristics
  288.     movb    #fab$c_vfc, fab$b_rfm(r6)        ; for SYS$OUTPUT in
  289.     movb    #<fab$m_get ! fab$m_put>, fab$b_fac(r6)    ; the FAB
  290.     movl    #<fab$m_ppf ! fab$m_sqo>, fab$l_fop(r6)
  291.  
  292.     movl    devname(ap), fab$l_fna(r6)    ; point to the terminal name,
  293.     movb    devnamelen(ap), fab$b_fns(r6)    ; including the length
  294.  
  295.     pushl    r6
  296.     calls    #1, g^sys$open
  297.     blbs    r0, OUT_CONNECT
  298.     brw    OUCH
  299.  
  300. OUT_CONNECT:
  301.  
  302. .if defined USE_MSG_FILE
  303.     movl    msgrab(ap), r0            ; begin debug printf()
  304.     moval    msg07, rab$l_rbf(r0)
  305.     movw    #34, rab$w_rsz(r0)
  306.     pushl    msgrab(ap)
  307.     calls    #1, g^sys$put
  308.     pushl    msgrab(ap)
  309.     calls    #1, g^sys$flush            ; end debug printf()
  310. .endc
  311.  
  312.     pushl    r7
  313.     calls    #1, g^sys$connect
  314.     blbs    r0, OUT_OPEN_OK
  315.     brw    OUCH
  316.  
  317. OUT_OPEN_OK:
  318.  
  319. .if defined USE_MSG_FILE
  320.     movl    msgrab(ap), r0            ; begin debug printf()
  321.     moval    msg08, rab$l_rbf(r0)
  322.     movw    #37, rab$w_rsz(r0)
  323.     pushl    msgrab(ap)
  324.     calls    #1, g^sys$put
  325.     pushl    msgrab(ap)
  326.     calls    #1, g^sys$flush            ; end debug printf()
  327. .endc
  328.  
  329. ; have to kick into kernel gear to move the SYS$OUTPUT values into the PPD.
  330.  
  331.     $cmkrnl_s    routin=HackSysOut
  332.  
  333. .if defined USE_MSG_FILE
  334.     movl    msgrab(ap), r0            ; begin debug printf()
  335.     moval    msg09, rab$l_rbf(r0)
  336.     movw    #35, rab$w_rsz(r0)
  337.     pushl    msgrab(ap)
  338.     calls    #1, g^sys$put
  339.     pushl    msgrab(ap)
  340.     calls    #1, g^sys$flush            ; end debug printf()
  341. .endc
  342.  
  343. ; the caller needs the two IFIs returned to him so that he can correctly
  344. ; redefine the five concealed process logicals created by VMS (sys$input,
  345. ; sys$output, sys$command, sys$error, and tt).
  346.  
  347.     movw    ppd$w_inpifi(r9), @inpIFIptr(ap)
  348.     movw    ppd$w_outifi(r9), @outIFIptr(ap)
  349.  
  350. ; finished.  get the hell out of here.
  351.  
  352. .if defined USE_MSG_FILE
  353.     movl    msgrab(ap), r0            ; begin debug printf()
  354.     moval    msg10, rab$l_rbf(r0)
  355.     movw    #49, rab$w_rsz(r0)
  356.     pushl    msgrab(ap)
  357.     calls    #1, g^sys$put
  358.     pushl    msgrab(ap)
  359.     calls    #1, g^sys$flush            ; end debug printf()
  360. .endc
  361.  
  362.     movzbl    #SS$_NORMAL, r0
  363.  
  364. OUCH:
  365.     ret
  366.  
  367.  
  368. ; move the new values for SYS$INPUT into the PPD.
  369.  
  370.     .entry    HackSysIn, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  371.  
  372.     movw    rab$w_isi(r7), ppd$w_inpisi(r9)
  373.     movw    fab$w_ifi(r6), ppd$w_inpifi(r9)
  374.     movw    fab$l_stv(r6), ppd$w_inpchan(r9)
  375.     movl    fab$l_dev(r6), ppd$l_inpdev(r9)
  376.  
  377.     movc3    #ppd$s_inpfid, nam$w_fid(r8), ppd$w_inpfid(r9)
  378.     movc3    #ppd$s_inpdid, nam$w_did(r8), ppd$w_inpdid(r9)
  379.     movc5    #nam$c_dvi, nam$t_dvi(r8), #0, #ppd$s_inpdvi, ppd$t_inpdvi(r9)
  380.  
  381.         ; need to construct an ASCIC string in the ppd's "filename"
  382.  
  383.     movb    filenamelen(ap), ppd$t_filename(r9)
  384.     movc5    filenamelen(ap), @filename(ap), #0, #<ppd$s_filename-1>, -
  385.             ppd$t_filename+1(r9)
  386.  
  387.     ret
  388.  
  389.  
  390. ; move the new values for SYS$OUTPUT into the PPD, the PRC, and the IDF.
  391. ; also move some values for SYS$INPUT that were not moved before,
  392. ; but those are moved from the PPD into something else.
  393.  
  394.     .entry    HackSysOut, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  395.  
  396. ; move the new values for SYS$OUTPUT into the PPD.
  397.  
  398.     movw    rab$w_isi(r7), ppd$w_outisi(r9)
  399.     movw    fab$w_ifi(r6), ppd$w_outifi(r9)
  400.     movl    fab$l_dev(r6), ppd$l_outdev(r9)
  401.  
  402.         ; set the "concealed i/o" bits in the "flags" word
  403.  
  404.     bisb    #<ppd$m_inpccl ! ppd$m_outccl>, ppd$w_flags(r9)
  405.  
  406.         ; copy the "file id" and the "directory id"
  407.  
  408.     movc3    #ppd$s_outfid, nam$w_fid(r8), ppd$w_outfid(r9)
  409.     movc3    #ppd$s_outdid, nam$w_did(r8), ppd$w_outdid(r9)
  410.  
  411.         ; copy the "device id" which is an ascic string
  412.  
  413.     movc5    #nam$c_dvi, nam$t_dvi(r8), #0, #ppd$s_outdvi, ppd$t_outdvi(r9)
  414.  
  415. ; also move some new values into the PRC
  416.  
  417.     movl    prc_l_inprab(r10), r4
  418.     movw    ppd$w_inpchan(r9), prc_w_inpchan(r10)
  419.     movw    ppd$w_outifi(r9), prc_w_outifi(r10)
  420.     movw    ppd$w_outisi(r9), prc_w_outisi(r10)
  421.     movl    ppd$l_outdev(r9), prc_l_outrabctx(r10)
  422.     movl    ppd$l_outdev(r9), rab$l_ctx(r4)
  423.  
  424.     movb    #<prc_m_inpccl ! prc_m_outccl>, prc_b_outflags(r10)
  425.     movl    #<prc_m_ctrlt  ! prc_m_ctrly>,  prc_l_outofband(r10)
  426.  
  427.     movc3    #ppd$s_outdvi, ppd$t_outdvi(r9), prc_t_outdvi(r10)
  428.  
  429. ; keep moving values . . . this time into the IDF
  430.  
  431.         ; change SYS$OUTPUT values in the IDF
  432.  
  433.     movw    ppd$w_outifi(r9), idf_w_outifi(r11)
  434.     movw    ppd$w_outisi(r9), idf_w_outisi(r11)
  435.     movl    ppd$l_outdev(r9), idf_l_outrabctx(r11)
  436.     movb    #<idf_m_outccl ! idf_m_inpccl>, idf_b_outflags(r11)
  437.     movc5    #ppd$s_outdvi, ppd$t_outdvi(r9), #0, #idf_s_outdvi, -
  438.             idf_t_outdvi(r11)
  439.  
  440.     tstl    idf_l_lnk(r11)
  441.     beql    CHANGE_TOP_IDF
  442.  
  443.     movl    r11, r4
  444.     movl    idf_l_lnk(r11), r11
  445.     tstl    idf_l_lnk(r11)
  446.     bneq    TOO_DEEP
  447.  
  448.     movw    idf_w_outifi(r4),    idf_w_outifi(r11)
  449.     movw    idf_w_outisi(r4),    idf_w_outisi(r11)
  450.     movb    idf_b_outflags(r4),  idf_b_outflags(r11)
  451.     movl    idf_l_outrabctx(r4), idf_l_outrabctx(r11)
  452.     movc3    #idf_s_outdvi, idf_t_outdvi(r4), idf_t_outdvi(r11)
  453.  
  454. CHANGE_TOP_IDF:
  455.  
  456.         ; change SYS$INPUT values in the IDF
  457.  
  458.     movw    ppd$w_inpifi(r9), idf_w_inpifi(r11)
  459.     movl    ppd$l_outdev(r9), idf_l_inprabctx(r11)
  460.     movc3    #ppd$s_inpfid, ppd$w_inpfid(r9), idf_w_inpfid(r11)
  461.     movc3    #ppd$s_inpdid, ppd$w_inpdid(r9), idf_w_inpdid(r11)
  462.  
  463.     movc5    #ppd$s_inpdvi, ppd$t_inpdvi(r9), #0, #idf_s_inpdvi, -
  464.             idf_t_inpdvi(r11)
  465.  
  466. ; there is a bit in the "flags" word of the PRC that is called
  467. ; the "silent logout" flag.  this bit must be clear for loginout.exe to
  468. ; issue the message "  SMITH_J     logged out at 7-MAR-1988 17:53:42.39"
  469. ; which is the desired action.  don't bother testing, just clear it.
  470. ;
  471. ; note: this does not work.
  472.  
  473.     bicw2    #prc_m_autologo, prc_w_flags(r10)
  474.  
  475.     ret
  476.  
  477. TOO_DEEP:
  478.     pushl    #0
  479.     pushl    #CLI$_STKOVF
  480.     calls    #2, g^lib$signal
  481.  
  482.     ret
  483.  
  484.  
  485. ; change values in the PCB and the JIB to resemble another process.  the only
  486. ; argument is the extended pid of the process that we want to look like, and
  487. ; it is passed by value.  we are going to change the username, the account,
  488. ; the terminal name, and the job type (from detached to local).  do *NOT* change
  489. ; the process name!  the others are pretty insignificant, at least compared to
  490. ; the process name, so hack hack hack.  but we will leave the latter to a call
  491. ; to sys$setprn() from a higher level routine.
  492. ;
  493. ; this would be a good point to also change values in the PHD,
  494. ; but there is nothing in there worth hacking at.
  495.  
  496.     .entry    HackPCBandJIB, ^m<>
  497.  
  498.     $cmkrnl_s    routin=RealHackPCBandJIB, arglst=(ap)
  499.     ret
  500.  
  501.     .entry    RealHackPCBandJIB, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  502.  
  503.     hispid = 4
  504.  
  505.     moval    krnerrhnd, (fp)            ; kernel-mode error handler
  506.  
  507.     movl    @#ctl$gl_pcb, r6        ; get a pointer to our PCB
  508.  
  509.     movl    hispid(ap), r0            ; using the pid passed to us,
  510.     jsb    g^exe$epid_to_pcb        ; get the other guy's PCB
  511.     beql    BADPID                ; if he really exists
  512.     movl    r0, r7                ; and save it
  513.  
  514.     movl    pcb$l_jib(r6), r8        ; obtain the JobInfoBlock
  515.     movl    pcb$l_jib(r7), r9        ; pointers for both processes
  516.  
  517.         ; copy the accountName, the userName and the terminal.
  518.  
  519.     movc3    #jib$s_account, jib$t_account(r9), jib$t_account(r8)
  520.     movc3    #jib$s_account, jib$t_account(r8), g^ctl$t_account
  521.  
  522.     movc3    #jib$s_username, jib$t_username(r9), jib$t_username(r8)
  523.     movc3    #jib$s_username, jib$t_username(r8), g^ctl$t_username
  524.  
  525.     movc3    #pcb$s_terminal, pcb$t_terminal(r7), pcb$t_terminal(r6)
  526.  
  527.         ; the jobType should always be "LOCAL" for our purposes.
  528.         ; likewise, make sure that the "DETACHED" flag is clear.
  529.  
  530.     movb    #jib$c_local, jib$b_jobtype(r8)
  531.     bicw2    #prc$m_detach, g^ctl$gl_creprc_flags
  532.  
  533.     movzbl    #SS$_NORMAL, r0
  534.     ret
  535.  
  536. BADPID:
  537.     movzwl    #SS$_NONEXPR, r0
  538.     ret
  539.  
  540.  
  541. ; change values in the UCB for the specified terminal.
  542.  
  543.     .entry    HackUCB, ^m<>
  544.  
  545.     $cmkrnl_s    routin=RealHackUCB, arglst=(ap)
  546.     ret
  547.  
  548.     .entry    RealHackUCB, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  549.  
  550.     devnam = 4
  551.  
  552.     moval    krnerrhnd, (fp)        ; kernel-mode error handler
  553.  
  554.     movl    @#ctl$gl_pcb, r6    ; get a pointer to our PCB
  555.     movl    r6, r4            ; the lock routine needs our PCB
  556.     jsb    g^sch$iolockw        ; lock I/O database for write access
  557.     movl    devnam(ap), r1        ; r1 = (struct STRDESC *) devnam
  558.     jsb    g^ioc$searchdev        ; search for the device name -
  559.                     ; status returned in r0, pointer to
  560.                     ; the proper UCB returned in r1
  561.     blbs    r0, OKUCB        ; whoops, couldn't find the device
  562.     cmpl    r0, #SS$_DEVALLOC    ; or maybe it's just already allocated
  563.     beql    OKUCB            ; if so, too bad for that guy
  564.     movl    r0, r9            ; a real error --- save the status
  565.     jsb    g^sch$iounlock        ; unlock the I/O database
  566.     movl    r9, r0            ; restore the error status
  567.     ret
  568.  
  569. OKUCB:
  570.     bbc    #dev$v_red, ucb$l_devchar2(r1), GOTUCB    ; skip if not redirected
  571.     movl    ucb$l_tt_logucb(r1), r1            ; ready
  572.  
  573. GOTUCB:
  574.     movl    pcb$l_pid(r6), ucb$l_pid(r1)    ; set the owner of the device
  575.     jsb    g^sch$iounlock            ; unlock I/O database
  576.     movzbl    #SS$_NORMAL, r0            ; success
  577.     ret
  578.  
  579.  
  580.     .entry    HackPrivileges, ^m<>
  581.  
  582.     $cmkrnl_s    routin=RealHackPrivileges, arglst=(ap)
  583.     ret
  584.  
  585.     .entry    RealHackPrivileges, ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
  586.  
  587.     privflag = 4
  588.     privbuf  = 8
  589.  
  590.     cmpb    privflag(ap), #1
  591.     bneq    SET_NEW_PRIVS
  592.     movq    pcb$q_priv(r4), @privbuf(ap)
  593.     ret
  594.  
  595. SET_NEW_PRIVS:
  596.     cmpb    privflag(ap), #2
  597.     bneq    RESTORE_PRIVS
  598.     bisl2    #<prv$m_sysnam ! prv$m_group ! prv$m_share>, pcb$q_priv(r4)
  599.     ret
  600.  
  601. RESTORE_PRIVS:
  602.     movq    @privbuf(ap), pcb$q_priv(r4)
  603.     bicl2    #prv$m_cmkrnl, pcb$q_priv(r4)
  604.     ret
  605.  
  606.     .end
  607. -- 
  608. murphy@npri6.npri.com 602 Cameron St. Alexandria, VA 22314 (703) 683-9090
  609.  
  610.               When every one is dead the Great Game is finished.  Not before.
  611.                               --- Hurree Babu, "Kim"
  612.