[mod.computers.vax] Recent request to show which terminals are OPER enabled

WARNOCK@clemson.CSNET.UUCP (02/23/87)

There was a recent request to the net for some way to determine who's 
enabled as what...Here is a program that will do that, although it doesn't
seem to work well with LAT terminals.  If someone fixes this problem, I'd
appreciate knowing how...
I didn't write it (as the source indicates) and haven't really done much with
it.  I think it came from and old DECUS tape, but I'm not sure.  In any case,
perhaps it will solve someone's problem. 

Good luck !

Todd Warnock
Clemson University
CSnet:	Warnock@Clemson.CSnet
BITnet:	Warnock@Clemson

(154 lines of code follow)

------------------------ CUT HERE ----------------------------------------------
	.title	show_operators	See what operators are enabled.
	.sbttl	documentation
;+++
;		This routine diplays the enabled operators.  Sorry that it's
;		not well documented or clean, it was a quick hack.  R. Wells
;
;      AUTHORS: 
;
;		R. WELLS
;
;      CREATION DATE: 	10-OCT-1985
;
;
;                      C H A N G E   L O G
;
;      Date     | Name  | Description
;---------------+-------+-----------------------------------------------------
;  10-OCT-1985  | WELLS | ORIGINAL RELEASE
;---------------+-------+-----------------------------------------------------
;
;      BUILD:
;		MACRO SHOWENABLED+SYS$LIBRARY:LIB/LIB
;		LINK  SHOWENABLED,SYS$SYSTEM:SYS.STB/SEL
;
;      INVOKE:
;		RUN SHOWENABLED
; 
;---
	.sbttl data_declarations

	.psect	data, noexe

	$dcdef					; device class info
	$ucbdef					; unit control block info
	$ddbdef					; device data block info

bufsiz = 80
buffer:	.blkb	bufsiz
bufdsc:	.long	bufsiz				; fao output buffer
	.address buffer

faomsg1: .ascid	/!%D Operator enabled on terminal !AC!ZB./
faomsg2: .ascid	/!%D No operator terminals enabled./

maxops = 500					; maximum number of ops
ttname:	.blkl	maxops				; array of saved names
ttunit: .blkb   maxops				; array of saved units
ttcnt:	.long	0			

;++
;
;
;--

	.sbttl	executable
	.psect code, exe,nowrt

	.entry main,^m<>

	$cmkrnl_s routin=kernal1

	movl	ttcnt,r5
	tstl	r5
	beql	no_operators

	moval	ttname,r3
	moval	ttunit,r2

write:	$fao_s	outbuf=bufdsc, ctrstr=faomsg1,-
		p1=#0, p2=R3, p3=(R2)

	pushal	bufdsc		
	calls	#1,g^lib$put_output

	addl	#1,r2
	addl	#4,r3

	sobgtr	r5,write
	
	$exit_s	r0

no_operators:
	$fao_s	outbuf=bufdsc, ctrstr=faomsg2,-
		p1=#0
	pushal	bufdsc
	calls	#1,g^lib$put_output

	$exit_s	r0
;
;
;
	.entry	kernal1,^m<r7,r8,r9>			
	moval	nocrash,(fp)			;Establish a kernal mode 
						; excpetion handler.

	movl	ioc$gl_devlist,r9		;Get first ddb 

	clrl	r6				;Count of operators

5$:	clrl	r7				;Clear unit counter
	movl	ddb$l_ucb(r9),r8		;Get first ucb on this ddb
	cmpb	ucb$b_devclass(r8),#dc$_term	;Is this a terminal ddb/ucb?
	bneq	20$				;if neq, no
;
; Check all ucbs on all ddbs, if op bit is set, then save name of terminal,
; for output when we're not in kmode.
;
10$:	bbc	#7,ucb$l_devchar(r8),15$	;Operator enabled on this ucb?
	movl	ddb$t_name(r9),ttname[r6]	;get device name
	movb	r7,ttunit[r6]			;get unit name

	incl	r6				;Bump op count
	movl	r6,ttcnt			;Save it

15$:	incl	r7
	movl	ucb$l_link(r8),r8		;Get next ucb
	tstl	r8				;More ucbs?
	bneq	10$				;if neq, yes

20$:	movl	ddb$l_link(r9),r9		;Get next ddb
	tstl	r9				;More ddbs?
	bneq	5$				;if neq, yes

	movl	#ss$_normal,r0
	ret					;back to caller
;
	.sbttl	KMODE_EXCEPTION_HANDLER
;
; Provides some reasonable safeguard against crashing your system.
; (From Bruce Elliot, thanks.)
;
reason:	.long	80
	.address	10$
10$:	.blkb	80

control_reason:
	.ascid	/Access violation at VA = !XL & PC = !XL/

	.entry	nocrash,^m<r2>
	movl	4(ap),r2		;Get address of signal array
	cmpl	4(r2),#ss$_accvio	;if it's an access violation,
					; display and get out.
	bneq	not_access_violation
	$fao_s	outbuf=reason,outlen=reason,ctrstr=control_reason,-
		p1=12(r2),p2=16(r2)
	pushal	reason
	calls	#1,g^lib$put_output	;Display the reason for the crash.
	$exit_s				;kill the process

not_access_violation:
	movl	#ss$_resignal,r0	;Pass the buck
	ret

	.END MAIN