04
Mon, Nov
6 New Articles

Lock It Up

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

I’ve always envied the PC world, with its screen savers and workstation locks. I’ve spent many hours at the local computer retailer trying to crack the screen saver password to access the latest “giga-machine” without overzealous attention from a pimply teenage wannabe computer nerd! I began to investigate whether the AS/400, one of the most secure platforms in the world, could manage the simple problem of unattended terminals and found both good and bad news.

First, the bad news: There’s no easy way to display flying stars or morphing images of Lou Gerstner on a dumb terminal. (This could actually be considered good news.) Also, the AS/400 interface provided to handle unattended workstations is uninspiring to say the least.

Now, the good news: AS/400 inactivity system values do allow user-written programs to process inactivity timeouts on the terminal. The Lock Workstation (LOCK) utility provides a way to secure a workstation manually before leaving it unattended and also allows a monitor to lock a workstation after a specified period of inactivity.

In this article, I present a tool that allows the user to lock a terminal manually and show you how to set the system to lock automatically based on inactivity. You can download the source code for these objects at www.midrangecomputing.com/mc/99/08 or download the entire object library at www.acsltd.com.

The Manual Session Lock

Figure 1 lists the objects that compose the LOCK utility. The LOCK command requires no parameters and is entered from a command line to place the session in a locked state. LOCK controls the pop-up window that allows the user to enter an AS/400 password to unlock the session. Specifying the nondisplay attribute in the DDS prevents the password from being seen as it is entered. Check Password (CHKPWD) verifies that the password entered is correct. If the password is incorrectly entered the maximum number of times (as determined by system value QMAXSIGN), the program issues a message to the system operator message queue and system history log indicating that an intruder has been detected at the workstation. This message is also issued to the user signed on to the workstation at the time. The session then ends, generating a job log using the SIGNOFF LOG(*LIST) command. To make manual locking of the workstation easier, the LOCK command can

also be associated with the Attn key by using command SETATNPGM PGM(mylib/LOCK) MODE(*ON).

Ignore System Request (IGNSYSR) sends a status message if a system request function is attempted while the terminal is locked. This status message prevents passersby from canceling the process or obtaining a command line via the System Request 3/option 16/F9 sequence of keystrokes. The LOCK program creates a temporary message file in library QTEMP with the same name as system message file QCPFMSG and overrides message processing to the new message file. All system request function commands except System Request 1 (Transfer to Secondary Job) are stored in message description CPX2313. In the temporary message file, you create a message description CPX2313 that replaces all the commands that IBM provides with IGNSYSR, rendering original system request functions unavailable. The Transfer to Secondary Job function is hardwired, but you can control its exposure by requiring a sign-on or, if a user is already signed on, requesting a separate lock. Unlike other types of override, overriding a message file really happens at the message description level. If the system needs to access any other message from QCPFMSG, the new message file is searched and, if no match is found for the required message description, IBM-supplied QCPFMSG is used.

If you have an Attn key-handling program (for example, to summon a group jobs menu), temporary reassignment of the Attn key prevents return to any group jobs menu. The original Attn key setting is reactivated upon unlocking the terminal; a setting of “Previous Invocation Level” is available to return the Attn key setting to its previous value.

The LOCK command is similar to IBM’s Disconnect Job (DSCJOB) but has the added advantage of being clear that the session is still alive behind the scenes. Disconnecting a job usually prompts a system sign-on screen indistinguishable from the normal sign-on screen. I have frequently witnessed users go to lunch and return to see this sign-on screen and assume incorrectly that they are signed off. They either power off their terminals or let the Disconnected Job Interval (QDSCJOBITV) system value expire, forcibly ending their sessions. Ending sessions in the middle of processes in this way can have serious repercussions on data integrity.

The Automatic Session Lock

The ability of the system to lock a session automatically comes ultimately from the manual session lock. The automatic lock allows the system to issue the LOCK command after a specified period of inactivity without user intervention. Figure 2 lists the objects that “upgrade” the functionality of the LOCK utility. The system provides two system values to allow you to process inactivity. System value Inactivity Interval (QINACTITV) allows you to select how much time passes before a session is considered inactive. Values range from *NONE (which is never considered inactive) to 5 minutes through 300 minutes of inactivity. After the system value is set to a value other than *NONE, the system performs the function designated by the second system value, Inactive Message Queue (QINACTMSGQ). QINACTMSGQ accepts three values: *ENDJOB (which ends the job if it is inactive), *DSCJOB (which disconnects the job if it is inactive), or the name of a message queue to be sent a message that contains the name of the session that has been inactive. This is where you step in.

By running a never-ending program that awaits arrivals in the designated message queue, you can extract the name of the inactive workstation sessions. The challenge is to get the lock request to a process that can interrupt a session and perform a function. The AS/400 assigns message queues to device descriptions as well as to individuals. If you set a session’s message queue to run in *BREAK mode, it can interrupt the operation being performed at the workstation. Displaying a message won’t help you with the task at hand, but, fortunately, the message queue allows a user-written program to be executed when a message arrives in the queue. Therefore, you need only extract the name of the session

from the timeout message sent by the system and forward to the session message queue a special message instructing a custom “break message handler” to lock the session.

Nonetheless, that’s all theory; this is the reality. Executing Start Lock Workstation Server (STRLWSSVR) creates a runtime environment consisting of a subsystem (LWSSBSD), job queue (LWSJOBQ), and inactivity message queue (LWSMSGQ). STRLWSSVR has three parameters that allow you to select how the server is started:

• Server library (LIB) serves as starting point for runtime environment objects, such as the subsystem.

• Create server objects (CRTSVR) controls whether server objects are created if they don’t exist (or re-created if they do exist).

• Inactivity interval (INACTITV) controls how long a session is inactive before it is The two inactive session system values discussed earlier are set with a specified inactivity interval and inactivity message queue name (LWSMSGQ), and the continuous server job (LWSSERVER) starts.

LWSSERVER waits for arrivals in the LWSMGSQ message queue. When a message is received that indicates a session has been inactive, the system uses RPG program Retrieve Lock Workstation Information (RTVLWSINF) to see if the session is currently being monitored. If it is being monitored, a second RPG program, Retrieve Lock Workstation Status (RTVLWSSTS), is called to tell the server if the session is already locked. If the session is not locked, a lock request is forwarded to the session’s message queue, and the server job waits for the next inactive message to arrive.

By using Start Lock Workstation Monitor (STRLWSMTR), you can set a session to handle the incoming lock request. The command sets the session message queue to break mode and assigns a user-written break-handling program (LWSBREAK) to activate upon arrival of a message in the queue. LWSBREAK retrieves and checks incoming message text for a fixed message from the server job. If the message is not from the server job, Display Message (DSPMSG) is processed to allow the user to see the message as if the default message handler (*DSPMSG) were assigned to the message queue.

I recommend starting the subsystem and server job during an IPL by issuing STRLWSSVR from within the QSTRUP program. IBM does not provide the source for this program but allows its retrieval via the Retrieve CL Source (RTVCLSRC) command. Make changes to start the server job and recompile QSTRUP into a library. (Never replace the original IBM-supplied version in QSYS.) Change the system value for the startup program (QSTRUPPGM) to point to your version of the program. I have included in my source a copy of QSTRUP as of V4R3 for you to see a sample of how to integrate the command into your environment. Because STRLWSSVR changes the two inactivity system values, which are Security (*SEC) values, the program is set to run under the adopted authority of the system Security Officer (QSECOFR).

RTVLWSINF allows programs to detect the status of the server job as well as the status of a specific workstation monitor. When passing special value *SERVER, the program knows to retrieve status information about the server job. The program determines the status via two APIs. API List Jobs (QUSLJOB) initially provides the program with a list of active jobs with the name LWSSERVER. If any jobs are found with this name, a second API, Retrieve Job Information (QUSRJOBI), is called to see if any of the jobs are running in the Lock Workstation Subsystem (LWSSBSD). This second API also allows you to retrieve the name of the library that contains the server objects. If a specific workstation session is being requested, API Retrieve Non-program Message Queue Attributes (QMHRMQAT) allows you to retrieve the current break-handling program assigned to the session message queue. If the queue has the application break-handling program (LWSBREAK) assigned, you can indicate that the session is ready to process incoming lock requests.

To prevent multiple lock requests from queuing up in the workstation message queue during an extended period of inactivity, you need a means of detecting whether a

locked.

session is currently locked. RTVLWSSTS uses another system API, List Object Locks (QWCLOBJL), to list object locks currently in effect on the locked workstation’s pop-up window. When a session is locked either manually or via inactivity, it displays the pop-up password window, locking the display file. Using this information within the server job, you can ignore inactivity messages for sessions that have already been secured.

Each user profile has an initial program that is called when the user signs on to the system. By issuing Start Lock Workstation Monitor (STRLWSMTR) in the initial program, it is possible to set up the workstation message queue for timeout without user intervention.

To end monitoring for a session, use End Lock Workstation Monitor (ENDLWSMTR) to change the workstation message queue to display incoming break messages without invoking the break-handling program. To prevent someone from ending the monitor, ENDLWSMTR can be made to run only by a profile that has Security Administration (*SECADM) special authority.

To shut down the server job (for example, prior to a backup or nightly process), issue End Lock Workstation Server (ENDLWSSVR). The command processor requires that it be run by a profile that has Security Administration (*SECADM) and All Object (*ALLOBJ) special authorities. Shutdown changes the system value for QINACTITV to *NONE and also sends a message to LWSMSGQ that is received by LWSSERVER, which then ends normally. LWSSBSD ends subsequently. By specifying *YES on the Delete server objects (DLTSVR) parameter, you can optionally delete all server objects after the server has been shut down.

Am I Still Exposed?

Like most programs, however, this process has its limitations.

• If you are running multiple sessions, each session is independent. That is, if a session is locked, other active sessions at that workstation do not lock automatically.

• If you are using a PC and that PC is set to “bypass sign-on” by using a user name and password entered for an AS/400 connection, any user who knows how to start an additional session can access the system. You can reduce this exposure by keeping your device descriptions cleaned up and Auto Configure turned off during normal operations.

• PCs provide various ways to enter commands without going through the 5250 interface. CA/400’s Remote Command function and FTP can both run OS/400 commands. For environments that use PCs with additional functionality, consider the Windows screen saver approach. Modify the LOCK command to detect the type of device the user is attempting to lock, and for PCs, issue Run Remote Command (RUNRMTCMD) to initiate a Windows screen saver .SCR file that is configured to require a password for entry. This approach prevents unauthorized access to the entire PC workstation.

• All object and data locks stay in effect while the session is locked. For example, suppose a user is looking up open accounts receivable on a customer and presses Attn to lock the session before going to lunch or lets the session timeout from inactivity. The customer record and any associated records required for the application remain unavailable to other users until the lock is released and the process is completed.

• Any use of Change Message Queue (CHGMSGQ) can reset the break-handling program back to *DSPMSG, having an effect equivalent to running ENDLWSMTR. Use EDTOBJAUT to restrict user access to CHGMSGQ. Alternatively, create your own CHGMSGQ command that retrieves the current break-handling program for the session and reassigns it after processing IBM’s CHGMSGQ command. I have retrieved for you a version of IBM’s CRTMSGQ command definition to assist in this.

Note that all the above limitations (except the last) are also true when using the Disconnect Job (*DSCJOB) option on the QINACTMSGQ system value. However, by using the LOCK command, the session stays active and, therefore, is not ended until the interactive job is ended.

Locking Things Out, Locking Things In

As industries continue to connect e-business servers to the Web at a phenomenal rate, I applaud those companies that are assessing their exposure to the outside world. I must remind people, though, that the greatest threat can sometimes come from within. Unattended terminals present a danger to any company that uses an AS/400 as its business solution. They potentially expose payroll, account receivable, sales, or revenue information to anyone who happens to walk by. Even worse, a system can be rendered inoperable by a console left signed on by a security officer who says he’ll be “back in a minute.”

I hope this application has provided you with not only a tool for locking down terminals but also an idea of how the basic concept can be enhanced to provide a more complete lockdown environment for PCs.

Object name Type Description

LOCK Command Lock workstation LOCK CL program Lock workstation command processing program
LOCK Display file Pop-up window to unlock workstation IGNSYSR Command Ignore system request
IGNSYSR CL program Ignore system request command processing program
IGNATTNKEY CL program Ignore attention key

Figure 1: The LOCK utility consists of these objects.

Object Type Description

STRLWSSVR Command Start Lock Workstation Server ENDLWSSVR Command Stop Lock Workstation Server STRLWSMTR Command Start Lock Workstation Session Monitor ENDLWSMTR Command Stop Lock Workstation Session Monitor LWSSERVER CL program Lock Workstation Server Job

(never-ending program) LWSBREAK CL program Lock Workstation Break Message Queue

Handling Program RTVLWSINF RPG IV program Retrieve Lock Workstation Information RTVLWSSTS RPG IV Retrieve Lock Workstation Status

Note: These commands all consist of a command definition (*CMD), a command processing program (*PGM), and a panel group (*PNLGRP) for help text. Each component has the name of the command.

Figure 2: You need these additional objects for automatic locking.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: