From: m_fisher@csc32.enet.dec.com (Spaceman Spiff)
Subject: Re: Wanted:Program code to SET UIC
Organization: Digital Equipment Corporation
Date: 26 SEP 92 21:48:06 MST


In article <1992Sep23.135441.265@lincoln.ac.nz>, brown@lincoln.ac.nz writes...
>We need to allow captive access to certain privileged files from users' normal
>unprivileged usercodes, as follows
> 
>The user enters a command which
>	- runs a privileged program to do a SET UIC
>	- the privileged program runs a captive command procedure to allow
>		controlled access to the privileged files
>	- the captive command procedure runs another privileged program to
>		SET UIC back to the original, before exiting.
> 
>My only problem is I can't find a system service or runtime library routine
>to set uic.  Before I code the workaround I have in mind, can anyone point
>me to reliable code for setting uic ?
>________________________________________________________________________________
>Martyn Brown, Senior Computer Consultant          Phone: 64.3.3252811 extn 8012
>Centre for Computing and Biometrics                 Fax: 64.3.3252944
>P. O. Box 84, Lincoln University                 Pacnet: 05301.30000047::brown
>Canterbury, New Zealand                 Bitnet,Internet: brown@lincoln.ac.nz

	Check out the following....this foo.mar file can be used from a
captive account to change the UIC of the user to a different process name.
This will enable the user to exectute tasks bound to a specific user ID.
This example was used to allow captive users to change there process name in
order to read their mail...



	.TITLE	FOO
;***************************************************************************
;Title:		FOO
;
;Function:	This program changes the PCB to Match the USERNAME Arguement
;
;		COMMAND:
;			$ PROCSET username
;
;
;***************************************************************************
.LIBRARY /SYS$LIBRARY:LIB/
.LIBRARY /SYS$LIBRARY:STARLET/
.LINK	'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH
$UAFDEF
$UAIDEF
$PCBDEF
$JIBDEF

.SUBTITLE	MACROS	- SOME NEEDED MACROS
.PAGE

.MACRO	ITEM	CODE, LENGTH, ADDRS, RTN
	.WORD LENGTH
	.WORD CODE
	.LONG ADDRS
	.LONG RTN
.ENDM

.SUBTITLE START	- *** MAIN ENTRY POINT***
.PAGE
.PSECT	CODE, EXE, NOWRT
.ENTRY	START, ^M<>

;	GET THE USERNAME OFF THE COMMAND LINE

	PUSHAW	USRDSC
	PUSHAQ	USRDSC
	PUSHAQ	P1DSC
	CALLS	#3, G^CLI$GET_VALUE
	BLBC	R0, 10$				;? ERROR

;	LOOK THE USER UP IN  SYSUAF

	$GETUAI_S	USRNAM=USRDSC, ITMLST=UAILST
	BLBS	R0,	20$			;? ERROR
10$:	$EXIT_S R0				;EXIT WITH ERROR
20$:	$CMKRNL_S	CMKRTN
	$EXIT_S	R0

.SUBTITLE CMKRTN	- KERNEL MODE ROUTINE
.PAGE
.ENTRY	CMKRTN, ^M<>

	MOVL	G^CTL$GL_PCB,R0			;GET THE PCB ADDRESS
	MOVL	UIC, PCB$L_UIC(R0)		;GET THE NEW UIC
	MOVL	PCB$L_JIB(R0), R0		;NOW GET THE JIB ADDRESS
	MOVC5	USRDSC+DSC$W_LENGTH, @USRDSC+DSC$A_POINTER, -
		#^A/ /, #^D12, JIB$T_USERNAME(R0) ;CHANGE THE USERNAME
	MOVL	#SS$_NORMAL,R0			;SET OK RETURN CODE
	RET

.SUBTITLE DATA	- READ / WRITE DATA SECTION
.PAGE
.PSECT	DATA, PAGE, NOEXE, WRT

USRDSC:	.LONG	32				;USERNAME DESCRIPTOR
	.LONG	USRBUF
USRBUF:	.BLKB	32
P1DSC:	.ASCID	#P1#				;CLI PARAMETER DESCRIPTORS

	; SYS$GETUAI ITEM LIST

UAILST: ITEM UAI$_UIC, 4, UIC, 0
	ITEM 0, 0, 0, 0

UIC:	.LONG	0				;SPACE FOR UIC INFO
	.END	START


*********************** foo.cld file *********************************
	This is the FOO.CLD file that enables the captive user to execute the
provious program. Just type FOO bubba and now your UIC is for bubba so bubba
can read his mail, etc....


DEFINE VERB PROCSET
	IMAGE SYS$LOGIN:FOO
	PARAMETER	P1


 sssss  ppppp  i  fffff  fffff
 s      p   p  i  f      f
 sssss  ppppp  i  fff    fff
     s  p      i  f      f
 sssss  p      i  f      f
Newsgroups: comp.os.vms,vmsnet.internals,comp.lang.fortran