From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 16-JUN-1989 22:37
To:	MRGATE::"ARISIA::EVERHART"
Subj:	SETUSER Utility (use at your own risk!)

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 16 JUN 89 18:46:37 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 16 Jun 89 18:33:58 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA26906; Fri, 16 Jun 89 18:21:56 -0700
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: 16 Jun 89 18:41:58 GMT
From: ecsvax!uncw!session@mcnc.org  (Zack Sessions)
Organization: Univ NC at Wilmington, CS & Math Dept.
Subject: SETUSER Utility (use at your own risk!)
Message-Id: <409@uncw.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

This posting is primarily for the benefit of Keith Burris, since I
apparently cannot get mail to him, but others may have a need/use
for it. It is a program which will change your Username only. BE
VERY CAREFUL USING THIS PROGRAM. I DO NOT SUGGEST YOU INSTALL THE
PROGRAM WITH PRIVS. Requires CMKRNL priv to run. Included are CLD
file (same file works with V4 or V5, and MACRO sources for a V4
version and a V5 version. Instructions for building the program are
included in the remarks.

--------------------beginning of CLD file--------------------------
!
! SETUSER.CLD - V4.2
!

define Verb setuser
	image sys$login:setuser
	parameter P1,prompt = "Username",value(required)
--------------------end of CLD file--------------------------------
--------------------beginning of V4 version source-----------------
		.Title SetUser		; Routine to change job username
		.Ident	'V04-000'
		.sbttl	Documentation
;++
;
; (C) 1983,1984,1985,1986,1987 Rich Emmings
;
; This software is copyrighted, but is free to use and/or distribute.
;
; This software is furnished with the following conditions:
;
;	It not be sold.
;	It not be modified.
;	All copyright and indentification data including this one, be left 
;	intact.
;
; FACILITY:
;
; 	SETUSER.MAR - Set/Change Job Username
;
; CALLING PROCEDURE:
;
;	$ SETUSER [username]	if username is ommited, you will be prompted.
;
; TO COMPILE:
;
;	$ MAC SETUSER
;	$ LINK SETUSER,SYS$SYSTEM:SYS.STB/SELECTIVE
;
;	This image must be recompiled at each major release of VAX/VMS
;
; ABSTRACT:
;
;	This routine allows any suitably priviledged user to set their
;	username to any string 1 to 12 chars.  The change will show up
;	in two places, in the JOB indentification block, and in the
;	process control area.  The JIB affects the appearence of show
;	users, etc, and the process CTL area affects the accounting record
;	that is written at image/process termination. 
;
; PRIVS REQUIRED:
;
;	CMKRNL - Change mode to kernel
;
; KNOWN BUGS/RESTRICTIONS:
;
;	This program does not change process name.
;	(either issue a set process/name command or call sys$setprn)
;
; CAVEAT:
;
;	If you install this as a priv'ed image, you can count on chaos 
;	reigning.
;
; AUTHOR:
;
;	Rich Emmings November 1983
;
; MODIFIED BY:
;
;	RE - March 1986, Change from LIB$GET_FOREIGN to CLI routines
;	     and a CLD file, whiched removed the restriction on lowercase
;	     usernames
;--
		.Page
		.Sbttl	Declarations

		.Library "SYS$LIBRARY:LIB.MLB"
		$PRVDEF
		$PCBDEF
		$SSDEF
		$JIBDEF
		.External Ctl$t_UserName
		.External Sch$Gl_CurPcb

		.page
		.sbttl	Data Storage
		 .Psect	$DATA PIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,NOVEC,LONG

Author::	.ascii /Author: Richard Emmings/ ; Credit where credit is due.

CLI_Q_Name_Desc:				; Name Descriptor
CLI_W_Name_len:	   .Word  2
CLI_W_Name_Unused: .word
CLI_L_Name_addr:   .long
CLI_T_Name:	   .Ascii /P1/

Name_Desc:					; Descriptor for Username
Name_Len:	.word	12
Name_unused:	.word
Name_addr:	.long
Name:		.ascii /            /	; of 12 bytes

		.Page
		.Sbttl	Getparams
		.Psect	$CODE PIC,USR,CON,REL,LCL,NOSHR,EXE,RD,NOWRT,NOVEC,LONG
		.Entry	Setuser,0		; Start of main code

		Movw	#12,Name_Len		; Fill descriptors for return
		Movab	Name,Name_Addr		; of value of '/NAME='

		Movw	#2, CLI_W_Name_Len	; fill descriptor for '/NAME='
		Movab	CLI_T_Name, CLI_L_Name_addr

		Pushaw	Name_len		; Push returned length
		Pushaq	Name_Desc		; push desc of new name
		Pushaq	CLI_Q_Name_Desc		; push dsc of name
		Calls	#3,Cli$get_value	; get value of '/NAME='
		blbs	R0,30$			; if low bit set, continue
		brw	error			; else abort

30$:		; Check to be sure that CMKRNL is a process priv.
		; At a later date, we may make this program an installed
		; image, only requiring world or group priv, like VMS.

		BBS	#Prv$V_Cmkrnl,Ctl$GQ_ProcPriv,50$
		$EXIT_S	#SS$_NoCmkrnl		; exit with no priv

50$:		; Now change mode to kernel and change the usernanr

		$CMKRNL_S	Routin=PRIV_CODE
		$Exit_S
Error:
		$EXIT_S	R0

		.Page
		.sbttl SetParams
		.Entry PRIV_CODE,^M<R6,R7>	; Entry for Kernel mode routine.

		MovC3	#12, Name, CTL$T_Username ; Load username
		MovL	Sch$GL_curpcb,R6	; Get PCB addr from P1
		MovL	PCB$L_Jib(R6),R7	; Get JIB addr from PCB
		MovC3	#12, Name, Jib$T_Username(R7)
						; load new username
		MovL	#SS$_NORMAL,R0		; Set status to normal
		Ret

		.End	Setuser
---------------------end of V4 Version---------------------------------
---------------------beginning of V5 version---------------------------
		.Title SetUser		; Routine to change job username
		.Ident	'V05-000'
		.sbttl	Documentation
;++
;
; (C) 1983,1984,1985,1986,1987 Rich Emmings
;
; This software is copyrighted, but is free to use and/or distribute.
;
; This software is furnished with the following conditions:
;
;	It not be sold.
;	It not be modified.
;	All copyright and indentification data including this one, be left 
;	intact.
;
; FACILITY:
;
; 	SETUSER.MAR - Set/Change Job Username
;
; CALLING PROCEDURE:
;
;	$ SETUSER [username]	if username is ommited, you will be prompted.
;
; TO COMPILE:
;
;	$ MAC SETUSER
;	$ LINK SETUSER,SYS$SYSTEM:SYS.STB/SELECTIVE
;
;	This image must be recompiled at each major release of VAX/VMS
;
; ABSTRACT:
;
;	This routine allows any suitably priviledged user to set their
;	username to any string 1 to 12 chars.  The change will show up
;	in two places, in the JOB indentification block, and in the
;	process control area.  The JIB affects the appearence of show
;	users, etc, and the process CTL area affects the accounting record
;	that is written at image/process termination. 
;
; PRIVS REQUIRED:
;
;	CMKRNL - Change mode to kernel
;
; KNOWN BUGS/RESTRICTIONS:
;
;	This program does not change process name.
;	(either issue a set process/name command or call sys$setprn)
;
; CAVEAT:
;
;	If you install this as a priv'ed image, you can count on chaos 
;	reigning.
;
; AUTHOR:
;
;	Rich Emmings November 1983
;
; MODIFIED BY:
;
;	RE - March 1986, Change from LIB$GET_FOREIGN to CLI routines
;	     and a CLD file, whiched removed the restriction on lowercase
;	     usernames
;
;	March 1989, Modified by Zack Sessions to work on V5 of VMS
;
;--
		.Page
		.Sbttl	Declarations

		.Library "SYS$LIBRARY:LIB.MLB"
		$PRVDEF
		$PCBDEF
		$SSDEF
		$JIBDEF
		.External Ctl$t_UserName
		.External CTL$GL_PCB

		.page
		.sbttl	Data Storage
		 .Psect	$DATA PIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,NOVEC,LONG

Author::	.ascii /Author: Richard Emmings/ ; Credit where credit is due.

Modifier::	.ascii /Modified by Zack Sessions/ ; to work with V5 and SMP


CLI_Q_Name_Desc:				; Name Descriptor
CLI_W_Name_len:	   .Word  2
CLI_W_Name_Unused: .word
CLI_L_Name_addr:   .long
CLI_T_Name:	   .Ascii /P1/

Name_Desc:					; Descriptor for Username
Name_Len:	.word	12
Name_unused:	.word
Name_addr:	.long
Name:		.ascii /            /	; of 12 bytes

		.Page
		.Sbttl	Getparams
		.Psect	$CODE PIC,USR,CON,REL,LCL,NOSHR,EXE,RD,NOWRT,NOVEC,LONG
		.Entry	Setuser,0		; Start of main code

		Movw	#12,Name_Len		; Fill descriptors for return
		Movab	Name,Name_Addr		; of value of '/NAME='

		Movw	#2, CLI_W_Name_Len	; fill descriptor for '/NAME='
		Movab	CLI_T_Name, CLI_L_Name_addr

		Pushaw	Name_len		; Push returned length
		Pushaq	Name_Desc		; push desc of new name
		Pushaq	CLI_Q_Name_Desc		; push dsc of name
		Calls	#3,Cli$get_value	; get value of '/NAME='
		blbs	R0,30$			; if low bit set, continue
		brw	error			; else abort

30$:		; Check to be sure that CMKRNL is a process priv.
		; At a later date, we may make this program an installed
		; image, only requiring world or group priv, like VMS.

		BBS	#Prv$V_Cmkrnl,Ctl$GQ_ProcPriv,50$
		$EXIT_S	#SS$_NoCmkrnl		; exit with no priv

50$:		; Now change mode to kernel and change the usernanr

		$CMKRNL_S	Routin=PRIV_CODE
		$Exit_S
Error:
		$EXIT_S	R0

		.Page
		.sbttl SetParams
		.Entry PRIV_CODE,^M<R6,R7>	; Entry for Kernel mode routine.

		MovC3	#12, Name, CTL$T_Username ; Load username
		MovL	CTL$GL_PCB,R6	; Get PCB addr from P1
		MovL	PCB$L_Jib(R6),R7	; Get JIB addr from PCB
		MovC3	#12, Name, Jib$T_Username(R7)
						; load new username
		MovL	#SS$_NORMAL,R0		; Set status to normal
		Ret

		.End	Setuser
------------------------end of V5 version--------------------------------


Zack Sessions                          | Utilizing the computing facilities
General Electric                       | at the University of North Carolina 
Nuclear Fuels & Component Manufacturing| at Wilmington 
Wilmington, NC                         |

"If it ain't broke, then don't fix it!"

