ttymon - port monitor for terminal ports
/usr/sbin/ttymon -g [-d device] [-h] [-t timeout] [-l ttylabel] [-p prompt] [-m modules] [-T termtype]
ttymon is a STREAMS-based TTY port monitor. Its function is to monitor ports, to set terminal modes, baud rates, and line disciplines for the ports, and to connect users or applications to services associated with the ports. Each instance of ttymon monitors one port, specified at startup. When an instance of ttymon is started, ttymon first initializes the line disciplines, if they are specified, and the speed and terminal settings. For ports with entries in /etc/logindevperm, device owner, group and permissions are set. (See logindevperm(4).) The values used for initialization are taken from the appropriate entry in the TTY settings file. This file is maintained by the sttydefs(1M) command. Default line disciplines on ports are usually set up by the autopush(1M) command of the Autopush Facility.
ttymon then writes the prompt and waits for user input. If the user indicates that the speed is inappropriate by pressing the BREAK key, ttymon tries the next speed and writes the prompt again. When valid input is received, ttymon creates a utmpx entry (see utmpx(4)), and execs the login service for the port. Valid input consists of a string of at least one non-newline character, terminated by a carriage return.
If autobaud is enabled for a port, ttymon will try to determine the baud rate on the port automatically. Users must enter a carriage return before ttymon can recognize the baud rate and print the prompt. Currently, the baud rates that can be determined by autobaud are 110, 1200, 2400, 4800, and 9600.
The primary smf(5) service which invokes ttymon is svc:/system/console-login, which may have multiple service instances. Instances are described in greater detail below. The service provides a number of properties within the property group ttymon to control the invocation, as follows:
NAME TYPE TTYMON OPTION ---------------------------------------------------------- device astring [-d device] nohangup boolean [-h] label astring [-l label] modules astring [-m module1,module2] prompt astring [-p prompt] timeout count [-t timeout] terminal_type astring [-T termtype]
If any value is the empty string or an integer set to zero, then the option is not passed to the ttymon invocation.
The default instance always represents the ttymon that offers login on the system hardware console.
See EXAMPLES for an example of how to modify settings for the system console.
Additional service instances are provided for the system's virtual consoles. If virtual consoles are not available, these services will automatically disable themselves. See vtdaemon(1M).
svc:/system/console-login:terma and svc:/system/console-login:termb are provided as a convenience and can assist the user in setting up login services for additional ports /dev/term/a and /dev/term/b. These services are disabled by default.
The user can configure additional service instances for additional devices. This can be accomplished in any of these ways:
Manually creating the service instance using svccfg(1M).
Creating the service in a service profile (see smf(5)).
Creating a service manifest for additional service instance(s).
See EXAMPLES for an example of manually configuring the service using svccfg.
In most cases when an instance of the console-login service is misconfigured, it will transition itself to the maintenance state. Use svcs –l (see svcs(1)) to determine the location of the service's log file and consult the log for additional information.
In some error cases, the service may respawn indefinitely. Disable the service using svcadm(1M), then consult the service log for additional messages or information to help resolve the problem.
ttymon uses pam(3PAM) for session management. The PAM configuration policy, specified in /etc/pam.conf or per-service files in /etc/pam.d/, specifies the modules to be used for ttymon. Here is a partial pam.conf file with an entry for ttymon using the UNIX session management module:
ttymon session required /usr/lib/security/pam_unix_session.so.1
The equivalent PAM configuration using /etc/pam.d/ would be the following entry in /etc/pam.d/ttymon:
session required /usr/lib/security/pam_unix_session.so.1
If there are no entries for the ttymon service in /etc/pam.conf and the /etc/pam.d/ttymon file does not exist, then the entries for the “other” service in /etc/pam.conf will be used. If there are not any entries in /etc/pam.conf for the “other” service, then the entries in /etc/pam.d/other will be used.
The following options are supported:
The –g option is required for historical reasons.
device is the full path name of the port to which ttymon is to attach. If this option is not specified, file descriptor 0 must be set up by the invoking process to a TTY port.
If the -h flag is not set, ttymon will force a hangup on the line by setting the speed to zero before setting the speed to the default or specified speed.
ttylabel is a link to a speed and TTY definition in the ttydefs file. This definition tells ttymon at what speed to run initially, what the initial TTY settings are, and what speed to try next if the user indicates that the speed is inappropriate by pressing the BREAK key. The default speed is 9600 baud.
When initializing the port, ttymon will pop all modules on the port, and then push modules in the order specified. modules is a comma-separated list of pushable modules. Default modules on the ports are usually set up by the Autopush Facility.
Allows the user to specify a prompt string. The default prompt is Login:.
Specifies that ttymon should exit if no one types anything in timeout seconds after the prompt is sent.
Sets the TERM environment variable to termtype.
Enables verbose messaging.
The following example sets the value of the terminal type (–T) option for the system console ttymon invocation:
# svccfg -s svc:/system/console-login:default \ "setprop ttymon/terminal_type = xterm" # svcadm refresh svc:/system/console-login:defaultExample 2 Creating a Service Instance for an Additional Serial Device
In this example, the user wishes to configure an additional instance of the svc:/system/console-login service in order to offer login services over a terminal connected by means of a USB serial adapter. Assume that the USB serial port is present as /dev/term/1, and the user plans to connect a vt100 terminal to it. In this case, the service instance can be named term1 (or any other name) and defined as follows:
# svccfg -s svc:/system/console-login "add term1" # SVC=svc:/system/console-login:term1 # svccfg -s $SVC "addpg ttymon application" # svccfg -s $SVC "setprop ttymon/device = /dev/term/1" # svccfg -s $SVC "setprop ttymon/terminal_type = vt100" # svcadm refresh $SVC # svcadm enable $SVC
If any of the LC_* variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of ttymon for each corresponding locale category is determined by the value of the LANG environment variable. If LC_ALL is set, its contents are used to override both the LANG and the other LC_* variables. If none of the above variables is set in the environment, the “C” (U.S. style) locale determines how ttymon behaves.
Determines how ttymon handles characters. When LC_CTYPE is set to a valid value, ttymon can display and handle text and filenames containing valid characters for that locale. ttymon can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. ttymon can also handle EUC characters of 1, 2, or more column widths. In the “C” locale, only characters from ISO 8859-1 are valid.
Contains information that is used by login(1) and ttymon to change the owner, group, and permissions of devices upon logging into or out of a console device.
See attributes(5) for descriptions of the following attributes:
svcs(1), ct(1C), cu(1C), autopush(1M), sttydefs(1M), svcadm(1M), svccfg(1M), uucico(1M), vtdaemon(1M), pam(3PAM), logindevperm(4), pam.conf(4), utmpx(4), attributes(5), environ(5), pam_authtok_check(5), pam_authtok_get(5), pam_authtok_store(5), pam_dhkeys(5), pam_passwd_auth(5), pam_unix_account(5), pam_unix_auth(5), pam_unix_session(5), smf(5)
ttymon was formerly a component of the Service Access Facility and was invoked by sac, the Service Access Controller. This facility has been removed in this release of Solaris, and a conversion to SMF of relevant portions was performed.
If a port is monitored by more than one ttymon, it is possible for the ttymons to send out prompt messages in such a way that they compete for input.
It is possible that two svc:/system/console-login service instances could refer to the same underlying device. For example, if the system's hardware console is connected (due to settings or autodetection in firmware) to serial port A, then both the svc:/system/console-login:default and svc:/system/console-login:terma services will refer to same underlying hardware device. Care should be taken when defining or enabling additional service instances to avoid this situation, or the two ttymons will compete for input.