Path: utzoo!mnetor!uunet!husc6!rutgers!ames!ucbcad!ucbvax!CITHEX.CALTECH.EDU!carl From: carl@CITHEX.CALTECH.EDU (Carl J Lydick) Newsgroups: comp.os.vms Subject: Re: Synchronizing VMSMAIL.DAT with SYSUAF file Message-ID: <871209025727.01l@CitHex.Caltech.Edu> Date: 9 Dec 87 11:40:28 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 76 > We found an interesting little 'feature' of VMS Mail yesterday: > User "AAA" had his mail forwarded (using SET FORWARD) to user > "BBB". Well, last week we removed user AAA from the SYSUAF file, > only to discover we could still send mail to AAA, and it > did in fact end up in BBB's mailbox. Presuming > this is because running AUTHORIZE to remove a user does *not* > update the VMSMAIL.DAT file, we would like to know if someone can > suggest a procedure which will get our VMSMAIL.DAT file in > synch with our current SYSUAF file. I wonder how many 'ghost' > usernames are still receiving mail this way? You're correct in your presumption as to why this happens. I take it that your use of apologetic quotes implies that you consider this a bug. Well, this just goes to show that one man's bug is another man's feature. Here on CITHEX, I use this feature (actually, the fact that you can have a record in VMSMAIL.DAT that doesn't correspond to any record in SYSUAF.DAT) for three purposes: 1) We have some users who, for historical reasons, have on username on CITHEX but another username on many other machines. In these cases, I've entered a record in VMSMAIL.DAT that takes mail addressed to the user by the username he has on other systems and forwards it to his real account on CITHEX (I know, I know: this is a pernicious practice and should be avoided, but some of these users have a lot of influence in the hiring and firing of system managers :-(); 2) There are some users who used to have accounts on CITHEX but who have migrated to other machines; rather than bouncing their mail, we've chosen to forward it to their accounts on the other machines (wouldn't it be nice if VMSmail had a feature that would let you forward the message AND send a warning message back to the sender, including the user's new address?); and 3) There are some address that are commonly used (well, at least I use them a lot), that are cumbersome to type. For example, ST%"""info-vax@kl.sri.com""". On CITHEX, VMSMAIL.DAT has a record that forwards mail sent to INFOVAX to that address. The following procedure does what you want, if I understand your complaint correctly. It searches VMSMAIL.DAT (being careful not to lock records or the file against changes) for records with usernames that don't correspond to records in SYSUAF.DAT (again, while being careful not to lock records or the file, and opening SYSUAF.DAT for read access only). It keeps the usernames so found in a series of DCL variables. It then goes back through VMSMAIL.DAT and deletes the offending records. You can easily delete the code to ask before deleting the records, if you so desire. The process running the procedure must have READ access to SYS$SYSTEM:SYSUAF.DAT, and WRITE access to SYS$SYSTEM:VMSMAIL.DAT. ******************************************************************************** $! Command procedure to conform VMSMAIL.DAT to SYSUAF.DAT $! Copyright (C) 1987, Caltech Odd Hack Committee, no rights reserved. $ ON WARNING THEN GOTO DONE $ ON CONTROL_Y THEN GOTO DONE $ OPEN/READ/SHARE=WRITE UAF SYS$SYSTEM:SYSUAF.DAT $ OPEN/READ/WRITE/SHARE=WRITE MAIL SYS$SYSTEM:VMSMAIL.DAT $ N = 0 $ LBL0: READ/END=LBL1/NOLOCK MAIL RECORD $ USERNAME = F$ELEMENT(0," ",RECORD) $ READ/KEY="''USERNAME'"/IND=0/ERR=OOPS/NOLOCK UAF RECORD $ GOTO LBL0 $ OOPS: N = N + 1 $ USERNAME_'N' = USERNAME $ GOTO LBL0 $ LBL1: CLOSE UAF $ LBL2: IF N .LT. 1 THEN GOTO DONE $ USERNAME = USERNAME_'N' $ READ/ERR=LBL3/PROM="Delete record for ''username' [N]? " SYS$COMMAND X $ X = F$EXTRACT(0,1,F$EDIT(X+"N", "TRIM,UPCASE")) $ IF X .NES. "Y" THEN GOTO LBL3 $ READ/DELETE/IND=0/KEY="''USERNAME'"/ERR=LBL4 MAIL RECORD $ LBL3: N = N - 1 $ GOTO LBL2 $ LBL4: Write sys$output "Failed to delete record for ",username $ GOTO LBL3 $ DONE: ON CONTROL_Y THEN GOTO DONE $ SET NOON $ IF F$TRNLNM("MAIL") .NES. "" THEN CLOSE MAIL $ IF F$TRNLNM("UAF") .NES. "" THEN CLOSE UAF