[comp.os.vms] cleaning up MAILUAF and SYSUAF

JMS@MIS.ARIZONA.EDU ("That ain't no VAX; that's an 1840") (05/22/88)

EXOS%"SYSVAX%TAMSTAR.BITNET@CUNYVM.CUNY.EDU asks:

>Before I reinvent the wheel, does anyone have a program which will compare
>MAILUAF.DAT to SYSUAF.DAT and allow one to delete from the MAILUAF.DAT file
>those entries which don't match?  I thought I remembered seeing one here,
>but now I can't find it.

OK. Here's an incredibly crufty thing I wrote in 1985 as an example
for a friend.  It still works, but needs to have directory and logical
names excised from it.
There are three files -- .FOR, .COM, and .FDL.
This one takes out records from VMSMAIL that aren't in SYSUAF, but
also has an EXCEPTIONS file which it uses for some aliases which
aren't in SYSUAF but we wanted to keep in EXCEPTIONS.

+----------------------------+ BITNET: jms@arizmis.BITNET
|Joel M Snyder               | Inter: jms@mis.arizona.edu     
|Univ of Arizona Dep't of MIS| Phone: 602.621.2748   ICBM: 32 13 N / 110 58 W
|Tucson, AZ 85721            | Quote: "Design is everything. 
+----------------------------+         Implementation is trivial."

---------weed-out-vmsmail.for---------
	Program Weed_Out_Vmsmail
*
****************************************************************************
*	Function -
*	     To remove from the standard VMSMAIL.DAT file all
*	user records which do not have a entry in the SYSUAF.DAT
*	file to match them or an entry in the exceptions file
*	to explicitly save a VMSMAIL entry, despite no entry
*	in SYSUAF.DAT.
*
*	Author -
*	     Joel M Snyder
*	     Management Information Systems
*	     Business and Public Administration Building
*	     University of Arizona
*	     Tucson, Arizona
*
*	Environment -
*	     This program was designed on and for a VAX-11/7nn
*	running version V4.0 or later of VMS.
*
*	Requirements -
*	     Mail_Purge.Com is required to set up the proper logical names for 
*	the files used by this program, and also to convert the exceptions 
*	file to format INDEXED, if it is not already.
*
*	Variables -
*	     KEY -   The VMSMAIL.DAT username field is first read into
*                    KEY and KEY is then used as and index to SYSUAF.DAT
*	             and then the exceptions file, if not found in SYSUAF.
*            
*	     REST -  REST is used as a dummy character string to read the 
*		     remainder of the records in VMSMAIL and SYSUAF into.
*
*	     IOSTAT_... - The IOSTAT_... variables are integers which will 
*	               contain the IO status of each one of the logical file 
*		       units 1, 2, and 3 after an operation is performed.
*
*	     Filename Parameters -  MAILFILE, UAFFILE, XCEPTFILE, and TTY
*	               are parameter names to fortran file unit numbers
*	               1, 2, 3, and 4, respectively.  These units are related
*		       to the logical names MAIL, UAF, EXCEPT, and SYS$OUTPUT,
*		       (also respectively) the first three of which are 
*		       defined in the command procedure MAIL_PURGE.COM.
*		       SYS$OUTPUT is the VMS standard logical output device,
*		       i.e. the terminal or batch processing log file.
*
*	     FORIOSDEF - The fortran definitions are included so that the
*		       integer values in IOSTAT_... are translatable into 
*		       more understandable logical names.  The error 
*	  	       mnemonic FOR$IOS_ATTACCNON represents the condition
*		       caused by attempting to access a nonexitent record in an
*		       indexed file.  This condition is anticipated as 
*		       indicating the absence of the appropriate record in
*		       the SYSUAF or exceptions file and is therefore
*		       the grounds form removal from the VMSMAIL.DAT file.
*
*	Implementation - To use this program effectively, the user must
*	     be sure that the files represented in MAIL_PURGE.COM
*	     exist in current directory, namely, SYSUAF.DAT the system
*	     authorization file, VMSMAIL.DAT the VMS mail authorization
*	     file, and XCEPTS.DAT a list of usernames which are not, under any
*	     circumstances, to be remove from VMSMAIL.DAT by this program.
*	     XCEPTS.DAT should be created as an empty file if there are
*	     no username exceptions.
*
*	Update History -
*
*
******************************************************************************
*		       
*    All variables are explicitly defined
	implicit none
*
*    FORIOSDEF definintions included for error status returns
	include '($FORIOSDEF)'
*    
	character*31 key
	character*65535	rest
	integer iostat_mailfile,iostat_uaffile,iostat_xceptfile,mailfile
	integer uaffile,xceptfile,tty,ideb
	parameter (mailfile = 1, uaffile = 2, xceptfile = 3, tty = 4)
*
	open (unit=mailfile,file='mail',status='old',key=(1:31),
	1 access='keyed',form='formatted',organization='indexed',
	1 recordtype='variable',err=140,iostat=ideb,shared)
*
	open (unit=uaffile,file='uaf',status='old',key=(5:36),
	1 access='keyed',form='formatted',organization='indexed',
	1 recordtype='variable',err=140,iostat=ideb,shared)
*
	open (unit=xceptfile,file='xcept',status='old',key=(1:31),
	1 access='keyed',form='formatted',organization='indexed',
	1 recordtype='variable',err=140,iostat=ideb)
*
	open (unit=tty,file='SYS$OUTPUT',status='UNKNOWN')
*
*    Read VMSMAIL file sequentially to get each record, exit at the end
*
1	read (mailfile,100,err=130,iostat=iostat_mailfile,
     1  END=999) key,rest
100	format(a31,a)
*
*    Read SYSUAF file using key from mail file
*
	read (uaffile,100,key=key//' ',iostat=iostat_uaffile)rest,rest
*
*    Check to see if status code indicates no record with that key
*
	if (iostat_uaffile .eq. FOR$IOS_ATTACCNON) then
*
*    If no key match, read the exceptions file
*
		read (xceptfile,100,key=key,
     1  iostat=iostat_xceptfile)rest,rest
*
*    Check for key match here also.
*
		if (iostat_xceptfile .eq. FOR$IOS_ATTACCNON) then
*
*    If there is no key match, remove the record from Vmsmail and notify
*
		   delete (mailfile)
		   write (tty,150) key
*
*    Otherwise, if there is an error conditon other that ATTACCNON on
*    either the mailfile or the exceptions file, use format lines at the
*    bottom of the file to notify user of error and iostat code.
*
		else if (iostat_xceptfile .ne. 0) then 
		       	write (tty,157) iostat_xceptfile
		endif
	else if (iostat_uaffile .ne. 0) then 
	        write (tty,155) iostat_uaffile
	endif
*
*   Return to line 1 and read the next record
*
	goto 1
*
*   This is the error routine for an error recieved during read of VMSMAIL
*
130	write (tty,135) iostat_mailfile
135	format(1x,'Error condition occured on VMSMAIL file, Status=',i)
	stop
*
*   This is the error routine for errors encountered during the file opens,
*   presumably caused by failure to execute the command procedure 
*   MAIL_PURGE.COM.
*
140	type 145
145	format(1x,'%FILERR - Please use command procedure MAIL_PURGE.COM')
*
*   This is the format line for the user notification.
*
150	format(1x,'Username removed from VMSMAIL.DAT: ',a31)
*
*   These are the format lines for unexpected errors encountered during the
*   read of either SYSUAF or the exceptions file.
*
155	format(1x,'Error condition occured on SYSUAF file, Status=',i)
157	format(1x,'Error condition occured on EXCEPTIONS file, Status=',i)
*
*   Close all files before ending
*
999	Close (mailfile)
	Close (uaffile)
	close (xceptfile)
	close (tty)
	end
-------------------clip-here-----------mail-purge.com

$ ! MAIL_PURGE.COM
$ !    
$ !     This is the control procedure for the VMSMAIL.DAT purge program:
$ ! Weed_Out_Vmsmail.For.  It assigns program local logical names for
$ ! SYSUAF.DAT, VMSMAIL.DAT and XCEPTS.DAT, which is a list of usernames
$ ! which are not to be removed from the VMSMAIL.DAT file, regardless of
$ ! their status.  The logical names (uaf,mail,xcept) are assigned at
$ ! the beginning of the procedure, if they do not already exist, and
$ ! deassigned after the program has been run, at then end of the procedure.
$ ! If these logical names already exist, they are not superseded.
$ !
$ On control_y then $ goto Exiter
$ On Error then $ goto Exiter
$ !vfy = f$verify(0)                      ! Turn off verify, save status
$ if f$logical("UAF") .nes. "" then $ goto Check_Mail_File          
$ if f$search("sys$system:SYSUAF.DAT") .eqs. "" then $ goto No_Sysuaf
$ define uaf sys$system:SYSUAF.DAT      
$ !
$Check_Mail_File:
$ !
$ if f$logical("MAIL") .nes. "" then $ goto Check_Xcept_File                 
$ if f$search("sys$system:VMSMAIL.DAT") .eqs. "" then $ goto No_Vmsmail
$ define mail sys$system:VMSMAIL.DAT    
$!
$Check_Xcept_File:
$!
$ if f$logical("XCEPT") .nes. "" then $ goto Run_Program
$ if f$search("lib_source:[mail_purge]XCEPTS.DAT") .eqs. "" then $ goto No_Xcepts                        ! Proceed to error routine
$ if f$file("lib_source:[mail_purge]XCEPTS.DAT","ORG") .nes. "IDX" then - 
	$ convert/pad/fdl=MAIL_PURGE.FDL lib_source:[mail_purge]xcepts.dat -
		lib_source:[mail_purge]xcepts.dat 
$ define xcept lib_source:[mail_purge]XCEPTS.DAT   
$!
$Run_Program:
$!
$ run Weed_Out_Vmsmail 
$ goto exiter          
$No_Sysuaf:                             ! Error routine for uaf
$ Write sys$output "%FILERR - SYSUAF.DAT not found."
$ goto exiter
$No_Vmsmail:                            ! Error routine for mail
$ Write sys$output "%FILERR - VMSMAIL.DAT not found."
$ goto exiter
$No_Xcepts:                             ! Error routine for xcept
$ Write sys$output "%FILERR - XCEPTS.DAT not found."
$Exiter:                                
$ vfy = f$verify(vfy)                   ! Return verify to original
$ if f$logical("UAF") .nes. "" then -   ! If uaf logical exists
$ deass UAF                             ! remove definition
$ if f$logical("MAIL") .nes. "" then -  ! If mail logical exists
$ deass MAIL                            ! remove definition
$ if f$logical("XCEPT") .nes. "" then - ! If xcept logical exists
$ deass XCEPT                           ! remove definition
$ exit 1                                ! exit program
------------------clip-here-------
IDENT	"23-DEC-1985 14:55:19	VAX/VMS ANALYZE/RMS_FILE Utility"

SYSTEM
	SOURCE                  VAX/VMS

FILE
	ALLOCATION              12
	BEST_TRY_CONTIGUOUS     yes
	BUCKET_SIZE             2
	CLUSTER_SIZE            3
	CONTIGUOUS              no
	EXTENSION               10
	GLOBAL_BUFFER_COUNT     0
	NAME                    "DISK$YUMA:[JMS]VMSMAIL.DAT;1"
	ORGANIZATION            indexed
	OWNER                   [15,470]        
	PROTECTION              (system:RWED, owner:RWED, group:R, world:R)

RECORD
	BLOCK_SPAN              yes
	CARRIAGE_CONTROL        none
	FORMAT                  variable
	SIZE                    0

AREA 0
	ALLOCATION              10
	BUCKET_SIZE             2
	EXTENSION               10

KEY 0
	CHANGES                 no
	DATA_KEY_COMPRESSION    yes
	DATA_RECORD_COMPRESSION yes
	DATA_AREA               0
	DATA_FILL               100
	DUPLICATES              no
	INDEX_AREA              0
	INDEX_COMPRESSION       yes
	INDEX_FILL              100
	LEVEL1_INDEX_AREA       0
	NAME                    ""
	NULL_KEY                no
	PROLOG                  3
	SEG0_LENGTH             31
	SEG0_POSITION           0
	TYPE                    string

ANALYSIS_OF_AREA 0
	RECLAIMED_SPACE         0

ANALYSIS_OF_KEY 0
	DATA_FILL               6
	DATA_KEY_COMPRESSION    69
	DATA_RECORD_COMPRESSION 89
	DATA_RECORD_COUNT       2
	DATA_SPACE_OCCUPIED     2
	DEPTH                   1
	INDEX_COMPRESSION       84
	INDEX_FILL              2
	INDEX_SPACE_OCCUPIED    2
	LEVEL1_RECORD_COUNT     1
	MEAN_DATA_LENGTH        68
	MEAN_INDEX_LENGTH       33