From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 19-MAY-1991 19:56:44.11
To:	ARISIA::EVERHART
CC:	
Subj:	A Program to set account field

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.97)
	 id AA05420; Sun, 19 May 91 19:45:47 EDT
Received: From ucbvax.Berkeley.EDU ([128.32.133.1]) by CRVAX.SRI.COM with TCP; Sun, 19 MAY 91 16:31:07 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA01849; Sun, 19 May 91 16:18:30 -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: 9 May 91 12:30:49 GMT
From: mcsun!ukc!tcdcs!swift.cs.tcd.ie!ccvax.ucd.ie!t_wade@uunet.uu.net
Organization: University College Dublin
Subject: A Program to set account field
Message-Id: <1991May9.123049.48118@ccvax.ucd.ie>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

Greetings,

Here is a program which will write an accounting record for your process so
far, and change your account field to that specified, and zero the various
accounting fields.  You can use this to charge different periods during your
session to different accounts for charging purposes. It is used via the
Foreign Command utility:

	$ SETACC :== $WHEREVER:RESET-ACCOUNT
	$ SETACC PROJ1		! sets account to PROJ1

The program should be installed with CMKRNL privileges if it is to be used
by non-privileged users.  It does no checks as to what you're setting the
account field to (note that setting this field to SYSTEM or whatever does not
confer any privileges - don't confuse ACCOUNT with USERNAME).  If you want
to control who can charge to what account, you'll have to add some code,
but feel free to ask me for any explanations.  Use MACRO and LINK/NOTRACE to
build.

****   WARNING **** WARNING **** WARNING **** WARNING **** WARNING ****
This is kernel mode code.  I have tested it on a VAXstation 3100 running VMS
5.4, without causing any crashes, however, I cannot assume any responsibility
for its behavior on your machine.

Enjoy.

Oh, and while I'm here, I'll send a copy to both comp.os.vms and INFO-VAX
to see if the gateway is really broken as reported (I have access to both
feeds, so don't send me any confirmations :-) ).

	THIS COPY POSTED TO COMP.OS.VMS

------------------------------------------------------------------------------
Tom Wade            |  Internet:    T.Wade@vms.eurokom.ie  (all domain mailers).
Speaker To VAXes    |  Bitnet:      T_WADE@CCVAX
EuroKom             |  PSI-Mail:    PSI%272431001992::T.WADE
University College  |  DEC EASYnet: DECWRL::"t.wade@vms.eurokom.ie"   (VMSMail)
Belfield            |  JANET:       t.wade%ie.eurokom.vms@UK.AC.EARN-RELAY
Dublin 4            |  X400:        [Address Exceeds 65536 byte buffer]
Ireland             |  Telex:       (0500) 91178 UCD EI  ("TO: WADE" at start)
--------------------+----------------------------------------------------------
Voice:+353-1-2697890|  Official Disclaimer:  "This is not a disclaimer"
Fax:  +353-1-2838605|          Unix  ....  Just say No !
--------------------+----------------------------------------------------------
----------File SET-ACCOUNT.MAR -- Cut Here---------------------------------
;   Program to change your account dynamically.  We must first force an
;   accounting record, then change the account field in the JIB and in P1 CTL
;   region.  We must also zero all the accounting fields.
;
;	Tom Wade <t.wade@vms.eurokom.ie>
;
;	Program runs in Kernel mode (CMKRNL privs required).
;	This program is provided as is.  No responsibility is accepted for
;	any mishaps resulting from use of this code.

		.Library	"SYS$SHARE:LIB.MLB"
		.Link		"SYS$SYSTEM:SYS.STB"

		$PCBDEF
		$JIBDEF
		$PHDDEF

Account_desc:	.Long	Jib$S_Account			; descriptor for
		.Address account			; new account.
Account:	.Blkb	Jib$S_Account
Prompt:		.Ascid	"Account:"			; optional prompt.

		.Entry	Start	0

		Pushal	account_desc			; get the account
		Pushaq	prompt				; name from the command
		Pushaq	account_desc			; line.
		Calls	#3,	G^Lib$Get_Foreign
		Blbc	R0,	10$			; abort on error

		$CMKRNL_S -				; Engage !
			routin = RESET_ACCOUNT
10$:		Ret

		.Entry	RESET_ACCOUNT	^M <R2, R3, R4, R5, R6, R7>

		Movl	#SS$_Normal, G^Ctl$GL_Finalsts	; set status to OK
		Clrl	R5				; special flag off
		Jsb	G^Exe$Prcpurmsg			; write accounting rec.
		Clrl	G^Ctl$GL_Volumes		; zero mount count
		Clrl	G^Ctl$GL_Wspeak			; work set peak.
		Clrl	G^Ctl$GL_Virtpeak		; virtual address peak.
		Movq	G^Exe$GQ_Systime, -		; reset elapsed time
			G^Ctl$GQ_Login
		Movl	Pcb$L_Phd(R4), R6		; get PHD address.
		Movl	Pcb$L_Jib(R4), R7		; get JIB address.
		Clrl	Phd$L_Cputim(R6)		; clear CPU time
		Clrl	Phd$L_Pageflts(R6)		; clear page faults
		Clrl	Phd$L_Pgfltio(R6)		; page fault I/O
		Clrl	Phd$L_Biocnt(R6)		; Buffered I/O count.
		Clrl	Phd$L_Diocnt(R6)		; Direct I/O count.
		Clrl	Phd$L_Imgcnt(R6)		; image activations.

		Movc5	account_desc, account, #^A" ",-	; move space extended
			#Jib$S_Account, G^Ctl$T_Account	; account name into
		Movc5	account_desc, account, #^A" ",-	; CTL and JIB.
			#Jib$S_Account, Jib$T_Account(R7)
		Movl	#SS$_Normal,	R0		; Finished.
		Ret					; beam me up Scotty.

		.End	Start
---------------------------------------------------------------------------

