From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  6-DEC-1989 14:20
To:	MRGATE::"ARISIA::EVERHART"
Subj:	PHONE Patch

Received: From UCBVAX.BERKELEY.EDU by GIZMO.SRI.COM with TCP; Wed,  6 DEC 89 09:13:37 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.40)
	id AA05804; Wed, 6 Dec 89 09:01:47 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 6 Dec 89 15:33:24 GMT
From: snorkelwacker!ira.uka.de!iraun1.ira.uka.de!urlichs@tut.cis.ohio-state.edu
Organization: University of Karlsruhe, FRG
Subject: PHONE Patch
Message-Id: <1282@iraun1.ira.uka.de>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

Hi there,

some people on this list requested that the PHONE patch should be posted again.
We have updated it for use on VMS 5.2. It still works on VMS 4.4 to VMS 5.1.
You have to change two lines in PHONEPAT.PAT if you want to use it on VMS 5.2
(see the comments there).

Happy patching,
                Bernd

UseNet: onasch@iravcl.ira.uka.de
BITNET: ONASCH@DKAUNI0I

$! ------------------ CUT HERE -----------------------
$!
$! This archive created by VMS_SHARE Version 7.1-001  26-JUN-1989
$!   On  5-DEC-1989 17:05:34.30   By user ONASCH (Bernd Onasch)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. PHONEPAT.COM;2
$!       2. PHONEPAT.PAT;2
$!
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X$!
X$!      PHONEPAT.COM
X$!
X$! Command procedure to patch and install (replace) VMS PHONE
X$! to make PHONE much more secure
X$!
X$! created on 15-JUL-1987 by Stefan Weirauch
X$!
X$! NOTE: YOU MUST CHANGE TWO LINES IN PHONEPAT.PAT IF YOU ARE PATCHING
X$!       PHONE ON VMS 5.2 OR HIGHER!
X$!
X$! Modifications:
X$!
X$! 20-JUL-1987  Some modifications in phonepat.pat (see there)
X$!              `091Stefan Weirauch`093
X$!
X$! 01-DEC-1989  Reorganized patch kit; updated for VMS 5.2
X$!              `091Bernd Onasch`093
X$!
X$ old_privs = f$setprv("SYSPRV,CMKRNL")
X$ if f$priv("SYSPRV,CMKRNL") then goto privs_ok
X$ say "%PHONEPAT-E-NOPRIV, insufficient privilege for attempted operation"
X$ goto exit
X$privs_ok:
X$ copy sys$system:phone.exe `091`093
X$ define/user sys$output nl:
X$ patch @phonepat.pat
X$ if $status then goto patch_ok
X$ say "%PHONEPAT-E-PATCHERR, error occured during execution of PATCH"
X$ goto exit
X$patch_ok:
X$ copy phone.exe sys$common:`091sysexe`093
X$ say "%PHONEPAT-I-INSTALL, installing new phone.exe"
X$ install replace -
X   phone/priv=(cmkrnl,sysnam,prmmbx,world,oper,netmbx,sysprv)
X$ type sys$input
X
XYou still have to install the patch permanently:
X
XModify your vmsimages.dat to contain the following line:
X  sys$system:phone /priv=(cmkrnl,sysnam,prmmbx,world,oper,netmbx,sysprv)
X
X$exit:
X$ dummy = f$setprv(old_privs)
X$ exit
$ CALL UNPACK PHONEPAT.COM;2 21979389
$ create/nolog 'f'
X!
X!       PHONEPAT.PAT   Protect phone mailboxes against user manipulation
X!
X!       Patchfile for image: PHONE, identification: X-1
X!       `091Works for VMS 4.4-5.1, Stefan Weirauch`093
X!
X!       Updated to work with VMS 5.2 PHONE, 1-DEC-1989 (see comments below)
X!       `091Bernd Onasch`093
X!
X!       EC100   10-JUL-1987     (Stefan Weirauch)
X!               MODULE:         PHONE
X!               ROUTINE:        PHN$INIT_MAIN
X!               set sysprv and cmkrnl, exit if it fails
X!               create permanent mailbox without world and group access
X!               change owner uic of our mailbox to `0911,4`093
X!
X!               Modifications:
X!               20-JUL-1987     (Stefan W., with hints from Kenneth Adelman)
X!               clear cmkrnl after test it; set it only temporary
X!               during execution of MODDEVORB
X!
X!       EC101   11-JUL-1987     (Stefan Weirauch)
X!               MODULE:         INPUT
X!               ROUTINE:        PHN$CMD_PARSE
X!               clear sysprv (if it was not set) temporarily while executing
X!               PHN$FACSIMILE_CMD (MODULE FILECMDS)
X!
X!       EC102   13-JUL-1987     (Stefan Weirauch)
X!               MODULE:         LINKSUBS
X!               ROUTINE:        PHN$ESTAB_LINK
X!               create the permanent mailbox of the called person like ours
X!               including owner uic change
X!
X!       EC103   20-JUL-1987     (Stefan W., with hints from Kenneth Adelman)
X!               MODULE:         MISCCMDS
X!               ROUTINE:        PHN$MAIL_CMD
X!               add sysprv to list of temporary purged privs before
X!               spawning mail command
X!
XPHONE.EXE
X
XDEFINE  PHONE           = 0A00
XDEFINE  PHN$INIT_MAIN   = PHONE + 0DB
XDEFINE  INPUT           = 1DB0
XDEFINE  PHN$CMD_PARSE   = INPUT + 13F
X!** Uncomment the following line if you have VMS 5.2 or higher
X!DEFINE  PHN$CMD_PARSE   = INPUT + 142
XDEFINE  FILECMDS        = 288C
XDEFINE  PHN$FACSIMILE_CMD = FILECMDS
XDEFINE  LINKSUBS        = 1610
XDEFINE  PHN$ESTAB_LINK  = LINKSUBS + 97
XDEFINE  MISCCMDS        = 2368
XDEFINE  PHN$MAIL_CMD    = MISCCMDS + 408
X!** Uncomment the following line if you have VMS 5.2 or higher
X!DEFINE  PHN$MAIL_CMD    = MISCCMDS + 495
X
XDEFINE  SYS$CMKRNL      = 7FFEDE90
XDEFINE  SYS$EXIT        = 7FFEDF40
XDEFINE  SYS$SETPRV      = 7FFEE100
XDEFINE  CTL$GL_CCBBASE  = 7FFEFF38
X
XDEFINE  SS$_NORMAL      = 01
XDEFINE  SS$_NOPRIV      = 24
XDEFINE  PRV$M_CMKRNL    = 00000001
XDEFINE  PRV$M_SYSPRV    = 10000000
X
XDEFINE  UCB$L_ORB       = 1C
XDEFINE  ORB$W_PROT      = 18
X
XSET ECO 100
X
X! some data we need for sys$setprv
X
XALIGN/QUAD DATA
X
XDEPO/PATCH_AREA/INSTR DATA
X'PROC_PRIVS:    .LONG 0,0'
X'NO_PRIVS:      .LONG 0,0'
X'CMKRNL_MASK:   .LONG PRV$M_CMKRNL,0'
X'SYSPRV_MASK:   .LONG PRV$M_SYSPRV,0'
X'SYSPCMKR_MASK: .LONG PRV$M_SYSPRV+PRV$M_CMKRNL,0'
XEXIT
X
X! now some routines we need more then once
X
XALIGN/WORD SETPRIV
X
XDEPO/PATCH_AREA/INSTR SETPRIV
X! routines to set/clear current privs
X! call sequence:
X!       PUSHAQ  priv_mask
X!       CALLS   #1,SETPRIV resp. CLRPRIV
X!
X'       .WORD   0'
X'       CLRQ    -(SP)'
X'       PUSHL   B`0944(AP)'
X'       PUSHL   #1'
X'       CALLS   #4,@#SYS$SETPRV'
X'       RET'
X'CLRPRIV: .WORD 0'
X'       CLRQ    -(SP)'
X'       PUSHL   B`0944(AP)'
X'       CLRL    -(SP)'
X'       CALLS   #4,@#SYS$SETPRV'
X'       RET'
XEXIT
X
XALIGN/BYTE MODDEVORB
X
XDEPO/PATCH_AREA/INSTR MODDEVORB
X! modify the ORB of a device specied by its channel
X! (set system `0911,4`093 as owner, set dev-prot to (S:RWLP,O:RWLP,G:,W:)
X!
X! input:   R2 : address of channel number
X!
X! call:  JSB MODDEVORB
X!
X! CCB = Channel Control Block
X! UCB = Unit Control Block
X! ORB = Object Rights Block
X!
X'       PUSHR   #3'                     ! save R0, R1 - they might be import
Vant
X'       MOVZWL  (R2),R1'                ! extend chan-no to long
X'       SUBL3   R1,@#CTL$GL_CCBBASE,R1' ! get address of CCB of that channel
X'       PUSHL   (R1)'                   ! push address of UCB as par in KERN
X'       PUSHAB  CMKRNL_MASK'            ! set cmkrnl-priv
X'       CALLS   #1,SETPRIV'
X'       PUSHAB  B`094KERN'                 ! to work with the I/O database
X'       CALLS   #2,@#SYS$CMKRNL'        !    we must change to kernel mode
X'       BLBS    R0,KERNOK'
X'       PUSHL   R0'                     ! something wrong with sys$cmkrnl ca
Vll
X'       CALLS   #1,@#SYS$EXIT'          !    exit with error message
X'KERNOK:PUSHAB  CMKRNL_MASK'            ! clear cmkrnl priv, we don't need i
Vt
X'       CALLS   #1,CLRPRIV'             !    elsewhere
X'       POPR    #3'                     ! restore R0, R1
X'       RSB'
X'KERN:  .WORD   0'
X'       MOVL    B`094UCB$L_ORB(AP),R1'     ! get address of ORB
X'       MOVL    #10004,(R1)'            ! set system uic into the ORB
X'       MOVW    #0FF00,B`094ORB$W_PROT(R1)'! set prot-mask as described abov
Ve
X'       MOVL    #SS$_NORMAL,R0'         ! return success
X'       RET'
XEXIT
X
X! modifications of the original code
X
XINSERT/INSTR    PHN$INIT_MAIN + 18
X'       CLRQ    -(SP)'                  ! original code
X
X'       PUSHAB  PROC_PRIVS'             ! get current proc-privs
X'       PUSHL   #1'
X'       PUSHAB  NO_PRIVS'
X'       PUSHL   #1'
X'       CALLS   #4,@#SYS$SETPRV'
X'       PUSHAB  SYSPCMKR_MASK'          ! try to set sysprv and cmkrnl
X'       CALLS   #1,SETPRIV'
X'       CMPL    R0,#SS$_NORMAL'
X'       BEQL    PRVOK'
X'       PUSHL   #SS$_NOPRIV'            ! not installed with sysprv or cmkrn
Vl
X'       CALLS   #1,@#SYS$EXIT'          !    exit with error msg
X'PRVOK: PUSHAB  CMKRNL_MASK'            ! clear cmkrnl-priv, will be set if
X'       CALLS   #1,CLRPRIV'             !    it is needed
X'       NOP'
XEXIT
X
XREPLACE/INSTR   PHN$INIT_MAIN + 0D4
X'       CALLS   #1,@#7FFEDF00'
X'       BRB     0BCB'
XEXIT
X'       CALLS   #1,@#7FFEDF00'          ! 7FFEDF00 = SYS$DELMBX
X'       MOVL    R0,R3'                  ! correctly created mailbox
X'       BLBC    R3,ERR1'                !    successfully marked for deletio
Vn ?
X'       JSB     MODDEVORB'              ! yes : modify ORB in the named mann
Ver
X'       BRW     PHN$INIT_MAIN + 0FB'    !       continue at the right place
X'ERR1:  BRW     PHN$INIT_MAIN + 0F6'    ! no  : continue to signal error
XEXIT
X
XUPDATE
X
XSET ECO 101
X
XREPLACE/INSTR   PHN$CMD_PARSE + 0F5
X'       MOVL    B`09428(R4),R0'
X'       BEQL    PHN$CMD_PARSE + 101'
X'       PUSHAB  B`0940C(R4)'
X'       CALLS   #1,(R0)'
XEXIT
X'       MOVL    B`09428(R4),R2'
X'       BEQL    NOSET'
X'       MOVAB   PHN$FACSIMILE_CMD,R3'
X'       CMPL    R2,R3'                  ! facsimile command parsed ?
X'       BNEQ    NOCLR'                  ! no: leave sysprv on
X'       BITL    #PRV$M_SYSPRV,PROC_PRIVS' ! yes: sysprv set in proc-privs ?
X'       BNEQ    NOCLR'                  ! yes: dont clear it
X'       PUSHAB  SYSPRV_MASK'            ! no: clear it for security reasons
X'       CALLS   #1,CLRPRIV'
X'NOCLR: PUSHAB  B`0940C(R4)'               ! call command routine
X'       CALLS   #1,(R2)'
X'       CMPL    R2,R3'                  ! was it facsimile ?
X'       BNEQ    NOSET'
X'       PUSHAB  SYSPRV_MASK'            ! yes: reenable sysprv
X'       CALLS   #1,SETPRIV'
X'NOSET: NOP'
XEXIT
X
XUPDATE
X
XSET ECO 102
X
XREPLACE/INSTR PHN$ESTAB_LINK + 1AC
X'       MOVL    R0,(SP)'
X'       BLBS    (SP),1862'
XEXIT
X'       MOVL    R0,(SP)'                ! here the mbx is successfully creat
Ved
X'       BLBC    (SP),ERR2'              ! successfully marked for deletion ?
X'       JSB     MODDEVORB'              ! yes: modify ORB as above
X'       BRW     1862'
X'ERR2:  NOP'                            ! no: continue to signal error
XEXIT
X
XUPDATE
X
XSET ECO 103
X
XREPLACE/INSTR PHN$MAIL_CMD + 0B9
X'       MOVL    #150804,B`0940F8(FP)'      ! list of temporary purged cur. p
Vrivs
XEXIT
X'       MOVL    #<150804+PRV$M_SYSPRV>,B`0940F8(FP)'       ! ...added by SYS
VPRV
XEXIT
X
XUPDATE
X
XEXIT
$ CALL UNPACK PHONEPAT.PAT;2 208801380
$ EXIT

