As an aside to the current VMS discussion, does anyone
know
of an equivalent to the Unix "su -" command for VMS?
Cheers
Al.
There is a utility called persona that will work on recent versions of
VMS which effectively works like su. You would need to install it with
priv's in order not to be running those priv's needed to run it in your
usual account.
PERSONA.MAR, you would need to
MACRO PERSONA.MAR
LINK PERSONA.MAR (LINK/SYSEXE on alpha, as I recall)
cut
;
.TITLE PERSONA
.IDENT /V1.0/
;
;***************************************************************************
;* *
;* COPYRIGHT ? 1997 BY *
;* MIKE RECHTMAN, ISRAEL *
;* *
;***************************************************************************
;+
; Be sure and LINK against the SYSTEM's symbol table and include LIB.MLB
; during assembly.
;-
.LIBRARY "SYS$LIBRARY:LIB.MLB"
.LINK "SYS$SYSTEM:SYS.STB" /SELECTIVE_SEARCH
.PSECT DATA,RD,WRT,NOEXE,LONG
;
; First, some useful texts -
;
CTRL1: .ASCID /Spawning subprocess under username !AS /
BANN1: .ASCID / /
BLEN1: .WORD 50.
BANN2: .ASCID / - Exit by typing LOGOUT when through... /
PROMP: .ASCID /Enter Username>/
CTRL2: .ASCID /Error during system call !AS, Aborting... /
ERRMS: .ASCID / /
ELEN2: .WORD 50.
ROUT1: .ASCID /GET_FOREIGN/
ROUT2: .ASCID /PERSONA_CREATE/
ROUT3: .ASCID /PERSONA_ASSUME (1)/
ROUT4: .ASCID /SPAWN/
ROUT5: .ASCID /PERSONA_ASSUME (2)/
M_DESC: .ADDRESS ROUT1 ; Pointer to current routine name
;
; Save some space for the username -
;
P_DESC: .ASCID / /
; Space to save who we want to become
; _MUST_ be valid username
U_DESC: .ADDRESS P_DESC
;
; These two LONGS hold the PERSONA data
;
PERS: .LONG 0 ; Who we want to be
ME: .LONG 1 ; Who we are now
.PSECT CODE,RD,NOWRT,EXE,BYTE
.ENTRY PERSONA,^M<>
10$:
; MOVAB ROUT1,M_DESC ; Done at initialization
PUSHAL PROMP
PUSHAL P_DESC
CALLS #2,G^LIB$GET_FOREIGN ; Get required username
BLBS R0,20$ ; of not OK, then
BRW 100$ ; jump to error - message
20$:
MOVAB ROUT2,M_DESC
$PERSONA_CREATE_S PERSONA=PERS,-
USRNAM=P_DESC ; Setup to change
BLBS R0,30$
BRW 100$
30$:
MOVAB ROUT3,M_DESC
$PERSONA_ASSUME_S PERSONA=PERS,-
FLAGS=#7 ; Change username
BLBS R0,40$
BRW 100$
40$:
$FAO_S CTRSTR=CTRL1,-
OUTBUF=BANN1,-
OUTLEN=BLEN1,-
P1=U_DESC
PUSHAB BANN1 ; Print msg
CALLS #1,G^LIB$PUT_OUTPUT ; ...
PUSHAB BANN2 ; Print another msg
CALLS #1,G^LIB$PUT_OUTPUT ; ...
50$:
MOVAB ROUT4,M_DESC
CALLS #0,G^LIB$SPAWN ; Create a sub-process
BLBS R0,60$
BRW 100$
60$:
MOVAB ROUT5,M_DESC
$PERSONA_ASSUME_S PERSONA=ME,-
FLAGS=#7 ; Revert to being ourselves
99$:
$EXIT_S R0
100$:
PUSHL R0
$FAO_S CTRSTR=CTRL2,- ; Format routine - name
OUTBUF=ERRMS,-
OUTLEN=ELEN2,-
P1=M_DESC
PUSHAB ERRMS ; Say there was an error
CALLS #1,G^LIB$PUT_OUTPUT ; ...
POPL R0 ; get saved status
$EXIT_S R0
.END PERSONA
--