Technical article 107693

Configure rlogind to close connection when client connection no longer exists.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

Problem

Commands such as who(C), finger(C), and ps(C) may show established rlogin sessions when the client end of the TCP connection no longer exists, as, for example, when the client computer crashes or is powered off or reset without first closing the rlogin session. Established sessions may also be shown when network connectivity to the client has failed.

Cause

The rlogin server daemon, rlogind(ADMN), arranges to use TCP transport-level keepalive probes to distinguish an inactive client from a TCP connection for which the remoted end of the connection no longer exists. When TCP finds a connection has been inactive for a specified period of time, it sends a keepalive probe to the client, and listens for a response. If there is no response to the probe, additional probes are sent at a specified frequency. If there is no response from the client after a specified number of probes have been sent, it is assumed that the connection has been lost, and the rlogin session is closed. If the client responds to a probe, the session is kept alive. This sequence of events is repeated if the session remains or again becomes idle. The timing for the sequence of events is determined by the three parameters just mentioned: idle interval, probe frequency, and number of probes. These values may be specified by rlogind, or left at the system-wide defaults.

When the who and ps commands both show an rlogin login as active, it is likely that they are correctly reporting a session that hasn't been closed by the client, and for which the sequence of events leading to automatic closing of the connection by the server, hasn't completed. That will be the case for an ordinary established connection over a properly functioning network. That will also be the case when keepalive probing hasn't yet completed for a client that has failed to disconnect properly, or with which connectivity has been lost. In the most insidious case, the client's TCP may not respond correctly to keepalive probes after failing to disconnect properly, and then rebooting. Rather than sending a reset response, the client sends an acknowledgement, causing the connection to be kept alive when it should have been closed. This article addresses the above cases. In particular, the "Solution" section of this article addresses how rlogind's keepalive parameters can be modified to minimize problems due to rlogin clients that fail to disconnect properly.

When who shows an rlogin user logged in, while ps shows that the session has in fact been closed, it is possible that /etc/utmp and related files have stale entries. Output from who and related commands is based on these files. The stale entries may be due to corruption in files that are read by utilities that update utmp, or to faulty non-SCO software. These cases are addressed in other technical articles in the SCO Support Library, listed at the end of this article. Note that it is possible to have both types of problem appear on the same system.

Solution

Use the following diagnostic to distinguish the two problem types just mentioned ("#" indicates the root command line prompt):

# kill -0 `who -u | awk '{print $7;}'`

Any output indicates a stale /etc/utmp entry associated with that process id. Consult other technical articles in this database, listed at the end of this article, for guidance in dealing with stale utmp entries. This article applies in cases for which the diagnostic produces no output.

The sending of keepalive probes can be configured to reduce the problem of rlogin sessions that haven't been disconnected properly. Some experimentation may be necessary to find the configuration that works best with the clients on a given network. The parameters that may be configured are described in the Keepalives section of the rlogind(ADMN) man page:

Keepalives
++++++++++

Transport-level keepalive messages are enabled unless the -n option is present. The use of keepalive messages allows sessions to be timed out if the client crashes or becomes unreachable.

If keepalives are being used, several parameters may be controlled using the following options:

-I n    The argument n specifies the interval (in seconds) between
        keepalive probes if no response is received.
-N n    The argument n specifies the number of unanswered keepalive probes
        that will be sent prior to dropping the connection.
-S n    The argument n specifies the time (in seconds) that a connection
        must be idle before the first keepalive probe will be sent.

The default keepalive values corresponding to these options are controlled by the parameters tcp_keepintvl (75 seconds), tcp_nkeep (8), and tcp_keepidle (7200 seconds). These can be tuned on a system-wide basis using inconfig(ADMN). These options exist solely to provide finer control of keepalives on a per-application basis.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NOTES:    The last paragraph of the man page excerpt above refers to
          system-wide defaults. The keepalive options provided by the
          rlogin server daemon allow these system-wide keepalive parameters
          to be overridden for rlogin connections, without affecting
          keepalive behavior of other applications.

The minimum value of 10 for -S is not documented in the man page. Values less than 10 for the -S flag will be ignored, and the default value will be used.

Because rlogind(ADMN) is started by inetd(ADMN), the keepalive flags need to be appended to the rlogin line in /etc/inetd.conf.

As an example, the line:
login  stream  tcp     nowait  NOLUID  /etc/rlogind    rlogind

would be edited with vi(C) to read:

login  stream  tcp     nowait  NOLUID  /etc/rlogind    rlogind -S 30 -I 1 -N 6

Execute the following command to apply the new configuration:

# kill -1 `cat /etc/inetd.pid`

The values given in this example are chosen so that a session will be idle thirty seconds (-S 30) before the first probe is sent, will probe every second (-I 1) until a response is received, or will close the session if no response is received during five seconds of probing (-N 6 and -I 1).

The values in this example might apply for an intranet with fast and reliable connectivity, and a problem client that answers keepalive probes incorrectly. If the client reboots quickly, these aggressive values may be of no avail. A shorter idle time may be configured, down to the minimum value of 10 for -S, but this will further burden the network with keepalive probe traffic, possibly leading to network performance problems.

A second example illustrates possible values for a slower and less reliable Internet connection, with a client that correctly responds to keepalive probes:

login  stream  tcp     nowait  NOLUID  /etc/rlogind   rlogind -S 60 -I 30 -N 5

In this case, a session will be idle one minute (-S 60) before the first probe is sent, will probe every thirty seconds (-I 30) until a response is received, or will close the session if no response is received during two minutes of probing (-N 5 and -I 30).

The number of seconds of probing is given by:

I * ( N -1 )

The number of seconds from the last activity to the last probe is given by:

S + ( I * ( N -1 ))

This is over two hours using the system defaults, and 35 seconds and three minutes, respectively, in the examples.

The examples are intended to be illustrative; the values chosen will depend on the specific situation. Some experimentation may be required to determine the best values.

NOTE:     The function of keepalive probes is sometimes confused with that
          of idleout(ADM). Keepalive probes serve to distinguish inactive
          connections from failed connections, for the purpose of
          automatically closing failed connections, whereas idleout serves to
          close idle logins, regardless of whether or not the connection has
          failed. Keepalives will not cause a rlogin session to be closed just
          because a user isn't typing.
NOTE:     The telnet server daemon, telnetd(ADMN), also allows configuration
          of keepalive parameters. See TA107691, "Configure telnetd to
          close connection when client connection no longer exists."

See also

The manual pages for who(C), whodo(C), finger(C), ps(C),
netstat(TC), rlogind(ADMN), inetd(ADMN), setsockopt(SSC), awk(C),
kill(C), cat(C), sh(C), telnetd(ADMN).

"TCP/IP Illustrated", Vol 1, by Richard Stevens, ISBN 0-201-63346-9, for a discussion of keepalives in detail beyond the scope of this article.

For cases involving stale /etc/utmp entries, the following articles apply:

TA105610, "I want to clear my system of users who are not logged
in."

TA104857, "Log in and get "no utmp entry. You must log in from lowest level -sh""

TA104588, "Rebuild ttys file from inittab including pseudo ttys after crash."

TA105397, ""Who" or "whodo" command sometimes returns info for users no longer logged in."

From the Xinuos technical article database, record 107693. Reproduced with permission. The original is at www.sco.com/ta/107693, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.