 SYS$ANNOUNCE Surgery  F (This article was published in the Canadian DECUS magazine, DECUScope)     Abstract  M Are you tired of looking at the same old boring message that OpenVMS displays O prior to the "Username:" prompt when you log in?  You know the one, "Welcome to + OpenVMS VAX V6.2" (or something similar).     L DIGITAL gives you the capability to change this message via the SYS$ANNOUNCEK logical name.  At first glance, it would appear that this logical name only  allows for a static message.  L This article describes how to write a program that will automatically updateG SYS$ANNOUNCE every time a user attempts to log in.  A sample program is 8 provided from which your own program can be constructed.     About the Author  M Curtis Rempel, an OpenVMS systems programmer, has managed OpenVMS systems for I over 12 years and specializes in OpenVMS internals and system performance 	 issues.       (                                      ---  M Are you tired of looking at the same old boring message that OpenVMS displays O prior to the "Username:" prompt when you log in?  You know the one, "Welcome to + OpenVMS VAX V6.2" (or something similar).     L DIGITAL gives you the capability to change this message via the SYS$ANNOUNCEK logical name.  At first glance, it would appear that this logical name only  allows for a static message.  N However, as we shall see shortly, it is rather simple to write a program whichH can be used to provide dynamic information to users prior to logging in.    # From Static to Dynamic - Method #1:   E One way of displaying dynamic information prior to login is to define M SYS$ANNOUNCE to point to a text file using the "@" symbol (input redirection)  as follows:   L    $ DEFINE /SYSTEM /EXECUTIVE_MODE SYS$ANNOUNCE "@SYS$MANAGER:ANNOUNCE.TXT"  J When a login is attempted, LOGINOUT.EXE will read the contents of the fileO SYS$MANAGER:ANNOUNCE.TXT and display it prior to the "Username:" prompt.  Thus, L by updating this file periodically, you can provide important information toO users attempting to log in without being restricted to a single line of text.     J For example, if the accounting system is currently down for backup and theK system manager has disabled interactive logins, a user attempting to log in  would experience the following:       Username: JSMITH 
    Password:  G    %LOGIN-F-LOGDISABL,  logins are currently disabled - try again later   L Although this message is somewhat informative, it is still a generic message that could be made more useful.   O If SYS$ANNOUNCE is defined to point to a text file via the "@" symbol as above, M the user would see the following and thus know not to bother trying to log in  until after 10:00 p.m. :  (    XYZ Corporation - Accounting Division     D    *** ACCOUNTING SYSTEM IS CURRENTLY DOWN UNTIL 2200 FOR BACKUP ***      Username:  K NOTE: If you forget the "@" symbol in the definition of SYS$ANNOUNCE, users 8 attempting to log in will receive the following message:      SYS$MANAGER:ANNOUNCE.TXT       Username:    % A more flexible approach - Method #2:   K The dynamic SYS$ANNOUNCE program is implemented by extending the concept of L input redirection (the "@" symbol) via an inter-process communication deviceK instead of a text file. Instead of defining SYS$ANNOUNCE to point to a text J file, we define the logical name to point to a mailbox.  Thus, when a userK attempts to log in, instead of reading from a text file, input will be read  from the mailbox.   M So how does this mailbox method give us information that is more dynamic that F the text file method?  Each method requires that information be storedI somewhere so it can be retrieved when a user logs in.  With the text file N method, you simply use your favorite editor to update a text file.  But how doD you update information in a mailbox?  By queueing a "read attention"M asynchronous system trap (AST) on the mailbox, a piece of code can be defined K to execute whenever a process attempts to read data from the mailbox.  This L piece of code formats a message (with whatever dynamic information you want)M and writes it to the mailbox.  This data is then immediately transferred  and @ displayed on the users terminal prior to the "Username:" prompt.  J The sample program illustrates the set of steps necessary to implement theG mailbox method.  The main routine sets up the environment by creating a K permanent mailbox, queueing a "read attention" AST on the mailbox, and then I hibernating.  At this point, SYS$ANNOUNCE is redefined by the DCL command H procedure (see below) to point to the mailbox just created.  When a readL operation occurs on the mailbox (i.e. somebody is attempting to log in), theO AST fires and executes the  ast_handler() routine.  This routine reads a set of E system load average values from the LAV0: device and formats a string O consisting of the system time, the 1, 5, and 15 minute CPU queue load averages, L and the number of interactive and batch jobs.  The string is then written toM the mailbox to satisfy the read operation.  Finally, another "read attention" / AST is queued to handle the next login attempt.   N NOTE: If the program ever terminates abnormally for any reason, users will notO be able to log in until either you restart the program or redefine SYS$ANNOUNCE M to point to a text file or a plain old string instead of the mailbox device.  H The reason for this is that because the program has terminated, the readO request to the mailbox cannot be satisfied and the users session will appear to J have hung without ever having received the "Username:" prompt.  Thus, someO error recovery code is necessary  as shown in the file SYS$MANAGER:ANNOUNCE.COM  below.  L If you have the MultiNet TCP/IP networking product for OpenVMS VAX or Alpha M installed, the load average device driver will already be operational on your N system.  If you don't use MultiNet, you can obtain a VAX version of the driverO as a ZIP archive called LAVDRIVER.ZIP via anonymous FTP from ftp.spc.edu in the L [.MACRO32.SAVESETS] directory.  To my knowledge, an OpenVMS Alpha version isK not available via FTP.  The ZIP archive contains information about the load F average data provided and how to obtain the data from a user program.      Caveats:  E When making modifications to your system, you should always keep your W company security policy in mind.  If you don't have a security policy, there are plenty I of good resources available on the Internet and right in your own OpenVMS 4 documentation set: OpenVMS Guide to System Security.  H Be careful about what type of information you provide prior to login viaK SYS$ANNOUNCE.  Consider whether this information could be used by a hacker, M either externally or internally, to gain access to your system.  For example, L displaying the operating system version may not be acceptable as it may giveL clues as to what, if any, vulnerabilities your system may be susceptible to.    
 Installation:   E Installing the dynamic SYS$ANNOUNCE program is accomplished using the  following four simple steps:  ! 1.  Compile and link the image.           $ CC /STANDARD=VAXC ANNOUNCE         Linking on VAX systems:        $ LINK ANNOUNCE, -2            SYS$SYSTEM:SYS.STB /SELECTIVE_SEARCH, -            SYS$INPUT /OPTIONS      SYS$SHARE:VAXCRTL /SHARE         Linking on Alpha systems:        $ LINK /SYSEXE ANNOUNCE   C 2.  Create a file called SYS$MANAGER:START_ANNOUNCE.COM as follows:   +     $! File: SYS$MANAGER:START_ANNOUNCE.COM      $ RUN /DETACHED - &           /PROCESS_NAME=SYS$ANNOUNCE -            /PRIVILEGES=(PRMMBX) -           /PRIORITY=15 -           /NOSWAPPING -            /UIC=[SYSTEM] - +           /INPUT=SYS$MANAGER:ANNOUNCE.COM - ,           /OUTPUT=SYS$MANAGER:ANNOUNCE.LOG -           SYS$SYSTEM:LOGINOUT      $ WAIT 00:00:10 F     $ DEFINE /SYSTEM SYS$ANNOUNCE "@''F$TRNLNM(""SYS$ANNOUNCE_MBX"")'"
     $ EXIT  = 3.  Create a file called SYS$MANAGER:ANNOUNCE.COM as follows:   %     $! File: SYS$MANAGER:ANNOUNCE.COM      $ SET NOON
     $LOOP:     $ RUN SYS$MANAGER:ANNOUNCEJ     $ REQUEST "SYS$ANNOUNCE terminated, $STATUS=''$status', restarting..."     $ GOTO LOOP   I 4.  Modify the OpenVMS system startup procedure to include the following:   !     $ @SYS$MANAGER:START_ANNOUNCE   C     (SYS$STARTUP:SYSTARTUP_V5.COM or SYS$STARTUP:SYSTARTUP_VMS.COM)      Sample Session  L The following session illustrates the use of the sample dynamic SYS$ANNOUNCE program:  9 31-JUL-1997 13:05   Load:   1.05 0.95 0.32    Jobs: 318+5   	 Username:     
 Enhancements:   H Further enhancements can be made to this sample program such as changingK the information provided depending on time of day, terminal identification, F etc.  The program could also translate site specific logical names and$ display them as part of the message.    
 Conclusion  O A dynamic SYS$ANNOUNCE program can provide useful information to users prior to M logging on to the system.  Careful consideration with respect to security and ; continuity of operation will ensure trouble free operation.   (                                      ---  
 Questions?   Email: vmsguy@home.com        curtis.rempel@shaw.ca                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  